Skip to content

Instantly share code, notes, and snippets.

@minhphong306
Created November 29, 2020 15:54
Show Gist options
  • Save minhphong306/33cf8db953fdab4d30b55b34d177a26a to your computer and use it in GitHub Desktop.
Save minhphong306/33cf8db953fdab4d30b55b34d177a26a to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"sync"
)
func read(wg *sync.WaitGroup, data <-chan string) {
fmt.Println(<-data)
wg.Done()
}
func write(data chan<- string) {
data <- "Có làm thì mới có ăn"
}
func main() {
wg := &sync.WaitGroup{}
wg.Add(1)
unbuffer := make(chan string)
go write(unbuffer)
go read(wg, unbuffer)
wg.Wait()
//time.Sleep(1 * time.Second)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment