You original example has a problem that others have pointed out because
it's possible for one goroutine to step on the part of the backing array used
by others. In principle though your technique looks OK to me as long
as you prevent that happening, for example by using the three-value slice
operator to set the capacity as well as the length of the bucket items.
https://play.golang.org/p/vzQlULC1zs7
It's OK to read and write items of the same underlying array as long
as any given element of the array is only accessed by a single goroutine
(or appropriate synchronisation is used).
> --
> 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...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.