5 ms·
I use it for shutdown channels. It doesn't matter what you're putting in the channel if you're never putting anything in the channel
by RSZC 7y ago
I use it for shutdown channels. It doesn't matter what you're putting in the channel if you're never putting anything in the channel
- zeeboo 7y agoUsing chan struct{} is more efficient, and guarantees there is nothing being put into the channel. That's why you see it used on the Context type's Done method, for example. https://golang.org/pkg/context/#Context https://golang.org/pkg/context/#Context