|
|
|
|
|
by Animats
4234 days ago
|
|
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.) |
|