Created
March 25, 2020 20:12
-
-
Save ilyabrin/25307f019b06f378500e005b364d687b 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
// When chan chan usefull in Go | |
package main | |
import "fmt" | |
import "time" | |
func main() { | |
request := make(chan chan string) | |
go first(request) | |
go second(request) | |
time.Sleep(time.Second) | |
} | |
func first(request chan chan string) { | |
response := make(chan string) | |
request <- response | |
result := <- response | |
fmt.Println(result) | |
} | |
func second(request chan chan string) { | |
response := <- request | |
response <- "input string" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment