I'm having some issues with a script of mine that dies silently once I try to make an existing function a goroutine. It seems if there is only a go routine in the main function then it doesn't run. Why is that?
After some fooling around I tried to reproduce the issue.
Heres a simple case from tour of
https://play.golang.org/p/78MQ90pp5L
package main
import (
"fmt"
"time"
)
func say(s string) {
for i := 0; i < 5; i++ {
time.Sleep(100 * time.Millisecond)
fmt.Println(s)
}
}
func main() {
go say("world")
say("hello")
}
If I comment say("hello") the program exits prematurely. Can someone explain why?