Includes solved 02-worker-pool and 09-safe-counter (mutex, atomic, sharded). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GbnJj9ZqEx9nUvzkjdwfMq
17 lines
243 B
Go
17 lines
243 B
Go
// PREDICT: which case fires? What if b were nil too?
|
|
package main
|
|
|
|
import "fmt"
|
|
|
|
func main() {
|
|
var a chan int // nil
|
|
b := make(chan int, 1)
|
|
b <- 42
|
|
select {
|
|
case v := <-a:
|
|
fmt.Println("a", v)
|
|
case v := <-b:
|
|
fmt.Println("b", v)
|
|
}
|
|
}
|