细节说明
xxx_test.go
测试结果
代码
package aaa
import (
"reflect"
"testing"
)
func TestSlice(t *testing.T) {
m1 := map[string]int{"id": 1, "pid": 0}
m2 := map[string]int{"pid": 0, "id": 1}
//t.Log(m1 == m2)//invalid operation: m1 == m2 (map can only be compared to nil)
//map变量只能和空(nil)比较
t.Log(m1 == nil) //false
t.Log(m2 != nil) //true
t.Log(reflect.DeepEqual(m1, m2)) //true
}