Answer the question
In order to leave comments, you need to log in
How to synchronize routines in golang?
for results.Next() {
var amx Amx_servers
// for each row, scan the result into our tag composite object
err = results.Scan(&amx.Id, &amx.Serverip, &amx.Serverport)
if err != nil {
amx.Serverport = 0
}
//fmt.Println(amx.Serverip, amx.Serverport)
go gol(amx.Serverip, amx.Serverport, amx.Id)
//fmt.Println(amx.Id)
}
Answer the question
In order to leave comments, you need to log in
sync.WaitGroup from stdlib
func WaitForWorkers(){
var wg sync.WaitGroup
for range{
...
wg.Add(1)
go gol(...)
}
wg.Wait()
}
func gol(...){
...
wg.Done()
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question