Hacker News new | past | comments | ask | show | jobs | submit login

The "chan chan Value" or "chan struct{resp chan Value}" is actually a pattern I've used in a very specific situation. It's a situation where a message bus probably could have been used instead, but then you'd have a message bus to handle...



I get "chan chan"s pretty routinely. It is when I send a message to some internal server/actor, and I also send it the channel to reply on in the message. Usually it ends up being a "chan struct { ... something with a chan in it ... }" rather than a literal "chan chan" you can grep for, but the principle is there. Very useful pattern; I consider it one of the basics in Go.

"chan chan chan" never, as far as I know.

It would be overkill to replace everything like that with a message bus. Very different performance characteristics for one thing. Go's channels are very much an internal-to-the-OS-process construct, if I'm talking internal to the OS process there's no value in "upgrading" to a message bus.


Probably similar to the concurrent chat server from gopl[0] then. The pattern is a bit surprising at first, still fairly readable.

[0]: https://github.com/adonovan/gopl.io/blob/master/ch8/chat/cha...


I used it too. It's useful to implement Promise-like semantics in Go.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: