2 ms·
> Would it be fair to say it should be rare to see channels passed directly in the parameters or return types of a public API? Yes, it is pretty rare. The only
by eikenberry 8y ago
> Would it be fair to say it should be rare to see channels passed directly in the parameters or return types of a public API?
Yes, it is pretty rare. The only example I know off the top of my head is the ssh library, but I would say it is an appropriate and good use of them and you can look at that as a possible example.
https://godoc.org/golang.org/x/crypto/ssh https://godoc.org/golang.org/x/crypto/ssh
> If so, it feels to me like channels are a bit of a misfeature. They work OK as a way to implement concurrency, sure, but not in a way that you want to expose in your API. They’re not very composable.
If you just look at channels and goroutines without some knowledge of CSP they will look a bit rough and low level, but once you understand CSP you'll see they are one of the better primitives available today. IMO the main problem with them is that people try to just use them without really understanding how to use them and it is pretty easy to shoot yourself in the foot with them.