切片和map使用==只能和nil比较,相互比较可以使用reflect.DeepEqual(a,b)
import ( "reflect" "testing" ) func TestDeepEqual(t *testing.T) { a := map[int]string{1: "one", 2: "two", 3: "three"} b := map[int]string{1: "one", 2: "two", 3: "three"} //t.Log(a == b) t.Log(reflect.DeepEqual(a, b)) s1 := []int{1, 2, 3} s2 := []int{1, 2, 3} s3 := []int{2, 3, 1} t.Log(reflect.DeepEqual(s1, s2)) t.Log(reflect.DeepEqual(s1, s3)) }