github.com/traefik/yaegi@v0.15.1/_test/issue-1442.go (about) 1 package main 2 3 import ( 4 "context" 5 ) 6 7 func main() { 8 ctx, _ := context.WithCancel(context.Background()) 9 ch := make(chan string, 20) 10 defer close(ch) 11 12 go func(ctx context.Context, ch <-chan string) { 13 for { 14 select { 15 case <-ctx.Done(): 16 return 17 case tmp := <-ch: 18 _ = tmp 19 } 20 } 21 }(ctx, ch) 22 23 for _, i := range "abcdef" { 24 for _, j := range "0123456789" { 25 // i, j := "a", "0" 26 for _, k := range "ABCDEF" { 27 select { 28 case <-ctx.Done(): 29 return 30 default: 31 tmp := string(i) + string(j) + string(k) 32 ch <- tmp 33 } 34 } 35 } 36 } 37 return 38 } 39 40 // Output: 41 //