> > type Y struct { > //some fields > } > > This rather depends on what those some fields ARE, and whether type Y is conceptually mutable or immutable.
For example, I might make a lightweight struct just to group a pair of values; X/Y coordinates, or Latitude and Longitude: type LatLon struct { Latitude, Longitude float64 } or the like, and in that case, I might treat it as immutable, and just make a new one if I needed changes, in which case doing a map[string]LatLon would be fine. If the struct is larger or is mutable, then a pointer makes more sense. BUT! There is one *critical* case to consider. type Something struct { guard sync.Mutex ... guarded things } This one MUST be done as a pointer, otherwise you are copying the mutex when you assign to the map, or assign from the map to a variable. As the docs say, "A Mutex must not be copied after first use." So if you have mutexes or mutable values in the struct, best to use *. "Only use the non-pointer map when your structs are simple, small, and immutable" is probably a reasonable rule of thumb. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.