The map key can be a value from any built-in or struct type as long as the value can be used in an expression with the == operator. Slices, functions, and struct types that contain slices can’t be used as a map key.
map key
可以使用任何内置类型或结构类型的值,只要这个值可以使用在==
表达式中。slice
,函数,和包含slice
的结构体不能用作key
。
参考资料:
Go in Action。