Last active
December 10, 2022 07:22
-
-
Save ehfeng/aca1c74502b801099ca0f7ba8f89b4cc to your computer and use it in GitHub Desktop.
Revisions
-
ehfeng revised this gist
Dec 10, 2022 . No changes.There are no files selected for viewing
-
ehfeng revised this gist
Dec 10, 2022 . No changes.There are no files selected for viewing
-
ehfeng revised this gist
Dec 10, 2022 . No changes.There are no files selected for viewing
-
ehfeng created this gist
Dec 10, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ package main import "fmt" func f(x, y, z chan string) { defer close(x) a := make(chan bool) go func() { for i := 0; i < 3; i++ { x <- "hi" } a <- true }() <-a y <- "hello" z <- "hola" } func main() { x, y, z := make(chan string), make(chan string), make(chan string) go f(x, y, z) go func() { for m := range x { fmt.Println("m", m) } }() select { case b := <-y: fmt.Println("b", b) case c := <-z: fmt.Println("c", c) } fmt.Println("end") }