- There's a section in the Little Go Book.
- I haven't reviewed it yet.
- https://github.com/golang/go/wiki/LearnConcurrency
- I haven't reviewed it yet.
- https://tour.golang.org/list
- I did this; notes below.
-
Goroutines invoked by
go f()
-
Channels
ch := make(chan int)
Now you canch <- 123
and<-ch
. -
Can give an argument to decide how much to buffer
-
Can
close(ch)
when done. Then someone else can range over it. Only needed if someone is ranging; otherwise it's unnecessary to close. You can check ifval, ok := <-ch
if needed -
select
:select { case c <- 123: fmt.Println("Sent value!") case <-quit: fmt.Println("Someone sent us a value to quit!") }
-
You can use a
default
case to be non-blocking. -
They show us how to use
sync.Mutex
which is simple.