Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dumindu/a77b2fe75e82d3991eb21a34805d4d8e to your computer and use it in GitHub Desktop.
Save dumindu/a77b2fe75e82d3991eb21a34805d4d8e to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"sync"
)
var wg sync.WaitGroup
func main() {
ch := make(chan string)
wg.Add(2)
go write(ch)
go read(ch)
wg.Wait()
}
func read(ch <-chan string) {
fmt.Println(<-ch)
wg.Done()
}
func write(ch chan<- string) {
ch <- "Hello world!"
wg.Done()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment