Created
April 9, 2023 10:52
-
-
Save dumindu/f55615445af5ad98f5ba170877cf9b69 to your computer and use it in GitHub Desktop.
This file contains 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 characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
ch1 := make(chan string) | |
ch2 := make(chan string) | |
go func() { | |
ch1 <- "Hello world!" | |
}() | |
go func() { | |
ch2 <- "こんにちは世界!" | |
}() | |
for i := 0; i < 2; i++ { | |
select { | |
case greet1 := <-ch1: | |
fmt.Println(greet1) | |
case greet2 := <-ch2: | |
fmt.Println(greet2) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment