Files
deep_go/lessons/channels/goroutine_leak_2/main.go

16 lines
242 B
Go

package main
// Need to show solution and describe close
// First-response-wins strategy
func request() int {
ch := make(chan int)
for i := 0; i < 5; i++ {
go func() {
ch <- i // 4 goroutines will be blocked
}()
}
return <-ch
}