If you want to run each loop in the background, nest the goroutine in the loop and use the sync.WaitGroup
structure.
import "sync"
fmt.Println("We are doing something")
//line below is my question
wg := sync.WaitGroup{}
// Ensure all routines finish before returning
defer wg.Wait()
for i := 1; i < 10; i ++ {
wg.Add(1)
go func() {
defer wg.Done()
fmt.Println("stuff running in background")
}()
}
// life goes on
fmt.Println("c'est la vie")