// +build ignore,OMIT | |
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"time" | |
) | |
func init() { | |
rand.Seed(time.Now().UnixNano()) | |
} | |
func main() { | |
a, b := make(chan string), make(chan string) | |
go func() { a <- "a" }() | |
go func() { b <- "b" }() | |
if rand.Intn(2) == 0 { | |
a = nil // HL | |
fmt.Println("nil a") | |
} else { | |
b = nil // HL | |
fmt.Println("nil b") | |
} | |
select { | |
case s := <-a: | |
fmt.Println("got", s) | |
case s := <-b: | |
fmt.Println("got", s) | |
} | |
} |