I have a go program with multiple goroutines. I am experiencing this error and I can't figure out why. This is my code logic:
main.go
for {
...
go funcFile2()
}
Where funcFile2 is defined in File2.go and is called multiple times in a sort of loop
File2.go
var wg sync.WaitGroup
func func1(){
defer wg.Done()
return
}
func func2(){
defer wg.Done()
return
}
func func3(){
defer wg.Done()
return
}
func funcFile2(){
wg.Add(3)
go func1()
go func2()
go func3()
wg.Wait()
}
GO Version: go1.12.7
How can I solve?