Skip to content

Instantly share code, notes, and snippets.

@ilyabrin
Created March 25, 2020 20:12
Show Gist options
  • Save ilyabrin/25307f019b06f378500e005b364d687b to your computer and use it in GitHub Desktop.
Save ilyabrin/25307f019b06f378500e005b364d687b to your computer and use it in GitHub Desktop.
// 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