Skip to content

Instantly share code, notes, and snippets.

@deividaspetraitis
Created January 18, 2018 12:42
Show Gist options
  • Save deividaspetraitis/986d6cdfc9bf95d96b55ccc193944c34 to your computer and use it in GitHub Desktop.
Save deividaspetraitis/986d6cdfc9bf95d96b55ccc193944c34 to your computer and use it in GitHub Desktop.
It's working!
package main
import (
"fmt"
"time"
"runtime"
)
func main() {
fmt.Println("init")
ch := gen()
fmt.Println("run routine")
go gook(ch)
fmt.Println("continue")
runtime.Goexit()
}
func gook(ch chan string) {
for {
data := <-ch
fmt.Println(data)
}
}
func gen() chan string {
out := make(chan string)
go func() {
for {
time.Sleep(time.Second * 1)
out <- "ping"
}
}()
return out
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment