I started to learn go language days ago. When I tried to start writing some fun codes, I am stuck by a strange behavior.
package main
import "fmt"
func recv(value int) {
if value < 0 {
return
}
fmt.Println(value)
go recv(value-1)
}
func main() {
recv(10)
}
when I run the above code, only 10
is printed. When I remove the go
before the call to recv
, 10
to 0
are printed out. I believe I am misusing go routine here, but I can not understand why it failed start a go routine this way.