Skip to content

Instantly share code, notes, and snippets.

@yumed15
Created November 22, 2023 12:09
Show Gist options
  • Save yumed15/650ac349c1949d81d07b8ba605ae2700 to your computer and use it in GitHub Desktop.
Save yumed15/650ac349c1949d81d07b8ba605ae2700 to your computer and use it in GitHub Desktop.
var wg sync.WaitGroup
sayHello := func() {
defer wg.Done() // <- before we exit the goroutine, we indicate
// to the WaitGroup that we have exited
fmt.Println("hello")
}
wg.add(1) // <- one goroutine is starting
go sayHello()
wg.Wait() // <---- join point
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment