Skip to content

Instantly share code, notes, and snippets.

@blanchonvincent
Last active July 12, 2019 10:02
Show Gist options
  • Save blanchonvincent/e3347fca2f581b6558c47f11b34a433b to your computer and use it in GitHub Desktop.
Save blanchonvincent/e3347fca2f581b6558c47f11b34a433b to your computer and use it in GitHub Desktop.
Medium - channel unbuffered channel
package main
import (
"sync"
"time"
)
func main() {
c := make(chan string)
var wg sync.WaitGroup
wg.Add(2)
go func() {
defer wg.Done()
c <- `foo`
}()
go func() {
defer wg.Done()
time.Sleep(time.Second * 1)
println(`Message: `+ <-c)
}()
wg.Wait()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment