Structs as keys in Go maps

前端 未结 2 1726
自闭症患者
自闭症患者 2021-02-04 00:10

I was looking into using structs as keys in golang maps. A field in this struct is supposed to be a map also and this seems to go against the documentation provided here which s

2条回答
  •  你的背包
    2021-02-04 00:55

    only comparable type can be used as a key (== ,!=). struct (not a pointer) is comparable in case it contains only comparable types.

提交回复
热议问题