Skip to content

Instantly share code, notes, and snippets.

@rogerwelin
Created September 12, 2018 17:04
Show Gist options
  • Select an option

  • Save rogerwelin/70a5de21a2e36ff77df53edee875049f to your computer and use it in GitHub Desktop.

Select an option

Save rogerwelin/70a5de21a2e36ff77df53edee875049f to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"sync"
)
func main() {
greeks := []string{"plato", "socrates", "aristotle", "archimedes", "pythagoras", "democritus"}
var wg sync.WaitGroup
fmt.Println("Init")
for _, ph := range greeks {
wg.Add(1)
go func() {
defer wg.Done()
fmt.Println(ph)
}()
}
wg.Wait()
fmt.Println("End")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment