News for hackers. Stuff that matters.
Re:Topo – A library to create in-process topologies of gorou... by patcoll on Saturday November 15, 2014 @12:13PM (#8612073)
I've been using this library which helps with composing channels, and also has some nice implementations of useful patterns:

https://github.com/eapache/channels

Unfortunately Go's lack of generics hurts in letting me use these helpers in a way that guarantees the data types going in/out of the generic channels.

Re:Topo – A library to create in-process topologies of gorou... by Animats on Saturday November 15, 2014 @01:08PM (#8612212)
Right. Everything gets converted to Go's "any" type, "Interface{}". At the output end you have to use a type assertion to get it back into the actual type. Note that an "Interface{}" is a pointer; you're not queuing the data, you're queuing a pointer to the data. So you're sharing data between goroutines. The sender must allocate a new variable for each send.

(This is my biggest complaint about Go. It's too easy to accidentally share data between goroutines, because so many things are implicitly references to mutable objects. Slices, for example, are references. Erlang and Rust, which also use queues heavily, avoid doing this.)