3 ms·
> This means that once we send a pointer on a channel, it's game over Yes, as long as you keep sharing the references. So just don't reference that stuff you s
by blablabla123 7y ago
> This means that once we send a pointer on a channel, it's game over
Yes, as long as you keep sharing the references. So just don't reference that stuff you sent across a channel. Usually there is little reason to use pointers in Go anyway [1] except when building methods to mutate the associated type (think: struct).
That said, it's fairly easy to build cascaded structures that are automatically deep-copied during assignment by not using pointers. So that's a pretty safe way to go, moreover one should keep in mind that Go doesn't try to be functional in any way, so immutable data is not such a thing there.
[1] https://medium.com/@vCabbage/go-are-pointers-a-performance-optimization-a95840d3ef85 https://medium.com/@vCabbage/go-are-pointers-a-performance-o...
- xyzzy_plugh 7y agoUntil you blow out the stack.