Because the gorouting call ends before the second one you spawned. This causes the second to be disabled. To illustrate this, slightly modify your code:
package main
import (
"fmt"
"time"
)
func say(s string) {
for i := 0; i < 5; i++ {
time.Sleep(100 * time.Millisecond)
fmt.Print(i)
fmt.Println(":"+s)
}
}
func main() {
go say("world")
say("hello")
}
Try inserting "wait" or sleep at the end of the main function.
source
share