How to compare two slices in Go

1 Answer

0 votes
package main 
   
import ( 
    "fmt"
    "reflect"
) 
   
func main() { 
    slice1 := []int{1, 2, 3, 4, 5}
    slice2 := []int{1, 2, 3, 4, 6}

    fmt.Println(reflect.DeepEqual(slice1, slice2))
} 
   
    
  
     
/*
run:
      
false
  
*/

 



answered Aug 18, 2020 by avibootz

Related questions

1 answer 72 views
2 answers 266 views
266 views asked Aug 18, 2020 by avibootz
1 answer 191 views
2 answers 249 views
249 views asked Sep 4, 2020 by avibootz
1 answer 166 views
166 views asked Aug 27, 2020 by avibootz
...