2 ms·
map[rhubarb]bool is how Go does sets and []interface{} is how Go does heterogenous lists. Also you can unmarshal JSON into an interface{} variable and get a mi
by JulianMorrison 14y ago
map[rhubarb]bool is how Go does sets and []interface{} is how Go does heterogenous lists.
Also you can unmarshal JSON into an interface{} variable and get a mix of map[string]interface{} and []interface{} that you can deconstruct via type assertion if you know what to expect, so you can be a bit python-ish about JSON if you don't want to read it into structs.
- stevvooe 14y ago> map[rhubarb]bool is how Go does sets Actually, you should use map[rhubarb]struct{} since a struct{} requires no storage. You can test membership with this: _, ok := m[strawberryRhubarb]