throwawaymaths 1 day ago

The thing is that go channels themselves are shared state (if the owner closes the channel and a client tries to write you're not gonna have a good time)! Erlang message boxes are not.

3
tombert 15 hours ago

Strictly speaking they’re shared state, but the way you model your application around channels is generally to have independent little chunks of work and the channels are just a means of communicating. I know it’s not one-for-one with Erlang.

Kubuxu 15 hours ago

You can think of closing the channel as sending a message “there will be no further messages”, the panic on write is enforcement of that contract.

Additionally the safe way to use closing of a channel is the writer closing it. If you have multiple writers, you have to either synchronise them, or don’t close the channel.

kbolino 16 hours ago

You don't have to close a channel in Go and in many cases you actually shouldn't.

Even if you choose to close a channel because it's useful to you, it's not necessarily shared state. In a lot of cases, closing a channel behaves just like a message in its queue.