Skip to content

Instantly share code, notes, and snippets.

@Israel-Miles
Created September 27, 2021 15:16
Show Gist options
  • Save Israel-Miles/a909ccf206ae8ffb6d27cf3186b5082d to your computer and use it in GitHub Desktop.
Save Israel-Miles/a909ccf206ae8ffb6d27cf3186b5082d to your computer and use it in GitHub Desktop.
func main() {
var wg sync.WaitGroup
channel := make(chan string)
wg.Add(2)
go func(channel chan string, wg *sync.WaitGroup) {
defer wg.Done()
fmt.Println(<-channel)
}(channel, &wg)
go func(channel chan string, wg *sync.WaitGroup) {
defer wg.Done()
channel <- "Sending message to channel"
}(channel, &wg)
wg.Wait()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment