Hacker News new | ask | show | jobs
by vrosas 68 days ago
There are a lot of places where channels look like the correct primitive but may actually be overkill. One of my favorite examples is collecting results from a group of goroutines. If you know the number of results up front, you can just define a slice and give each thread an index of the slice to write to (and a waitgroup of course). No channels, no mutexes, and completely thread safe.
1 comments

Wouldn't the example you described result in false sharing?
if you just want to return results from a couple of goroutines, shouldn't be a problem I think?