Re: [go-nuts] Is there a better way to write this?

2022-09-15 Thread K. Alex Mills
The only alternatives that I see would each introduce an extra call to Add, like the below. I'm not sure if this is much less "clunky", but it at least avoids the reassignment to s. func collectStringsetMap(m map[string]*stringset.Set, key string, value ...string) *stringset.Set { if s, ok :=

[go-nuts] Is there a better way to write this?

2022-09-13 Thread 'Aaron Spangler' via golang-nuts
I seem to be regularly working with maps of stringsets and I have found myself writing the same pattern over and over and I ended up having my own utility function. More importantly the syntax seems clunky when a key doesn't exist in the map. Is there a better way (go idiomatically way) to write