cheatsheet
← portfolio

Go Goroutines & Channels

Aug 2026#go

Goroutines

A goroutine is a lightweight thread managed by the Go runtime:

go func() {
    fmt.Println("hello")
}()

Channels

Channels send and receive values between goroutines.

ch := make(chan int)
go func() { ch <- 42 }()
v := <-ch // 42

Select

select {
case v := <-ch:
    fmt.Println(v)
case <-time.After(time.Second):
    fmt.Println("timeout")
}