I have part of a script with the following format:
func main() {
for i=0;i<1000000;i++ {
go test()
}
}
func test() {
a := test2()
}
func test2()(var int) {
//a bunch of operations
return var
}
I run a lot of iterations and it always work. I'm wondering is there any chance that two or more goroutines calling function "test2()" at the same time and cause a crash? Is the following format anyway better then the previous one?
func main() {
for i=0;i<1000000;i++ {
go test()
}
}
func test() {
test2 := func()(var int){
//a bunch of operations
return var
}
a := test2()
}
Thank you very much!