Created
June 24, 2018 17:12
-
-
Save cyantarek/9508e8bb51d1f4b26437cd6762376907 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" | |
"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