What you are doing is what sync.Once was invented for:
https://play.golang.org/p/erZqwFYgIR
On Tue, Oct 17, 2017 at 11:37 PM, Juliusz Chroboczek wrote:
> > The answer depends on whether you have just one value or many. For a
> single
> > value (sometimes known as a "future"), I tend to pair a ch
> The answer depends on whether you have just one value or many. For a single
> value (sometimes known as a "future"), I tend to pair a chan of struct{}
> with a value to be set. To make the value available, set it, then close the
> channel. Readers wait on the channel, then read the value.
That's