1.如果结构体成员包含 map, slice, 不可比较
2.int string 普通类型,如果变量顺序不一样,则不可比较
package mainimport "fmt"func main() {s1 := struct {//a map[int]int// a []inta stringb int}{}s2 := struct {//a map[int]int// a []intb inta string}{}fmt.Println(s1 == s2)
}
invalid operation: cannot compare s1 == s2 (struct containing map[int]int cannot be compared
invalid operation: cannot compare s1 == s2 (struct containing []int cannot be compared)