Concurrency in Golang
· One min read
- Concurrency in A Tour of Go
- go routines are kind of like fancy queues designed for concurrency
selectis kind of like a switch statement for channels(<-)= "the channel operator"- when left operand is a channel, read
ch <- dataas "sending"datato the channelch - when right operand is a channel, read
data := <- chas "receiving" from the channelchand assigning todata- when left operand is missing, then we are "receiving" without assignment e.g. when passing the result directly to another function
- when left operand is a channel, read
- https://gobyexample.com/channel-buffering
- https://gobyexample.com/channel-directions
func pong(pings <-chan string, pongs chan<- string)<-chan stringmeans a channel that can only receivechan<- stringmeans a channel that can only send
- https://www.sohamkamani.com/golang/context/
- https://www.sohamkamani.com/golang/channels/