Skip to content

Instantly share code, notes, and snippets.

@cyantarek
Created June 24, 2018 17:12
Show Gist options
  • Save cyantarek/9508e8bb51d1f4b26437cd6762376907 to your computer and use it in GitHub Desktop.
Save cyantarek/9508e8bb51d1f4b26437cd6762376907 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
)
func main() {
var ch = make(chan string)
go countFruit("Apple", ch)
ch <- "go man go"
time.Sleep(time.Second * 5)
fmt.Println(<-ch)
}
func countFruit(name string, ch chan string) {
data := <- ch
fmt.Println(name)
fmt.Println(data)
ch <- "stopped"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment