. , , , .
: Spec: :
== != ; , , .
, , , . struct, struct:
, . , blank .
struct ( ), . , .
, .
, , , , :
type MyType struct {
S string
i int
notComparable []int
}
MyType :
m := map[MyType]int{}
:
invalid map key type MyType
:
. : (- , ), , , :
p1, p2 := MyType{}, MyType{}
fmt.Println(p1 == p2)
:
invalid operation: p1 == p2 (struct containing []int cannot be compared)
, , . , -, ; , , :
type myType struct {
S string
i int
}
type MyType struct {
myType
notComparable []int
}
func main() {
p1, p2 := MyType{}, MyType{}
fmt.Println(p1.myType == p2.myType)
}
, MyType , - MyType .