Junior — Middle
Millises elutsükli etapis käivitatakse Go-s goroutine?
sobes.tech AI
Vastus AI-lt
Goroutine in Go starts at the moment when the go keyword is called before a function or method. This happens during program execution, when the control flow reaches this statement. For example:
func sayHello() {
fmt.Println("Hello")
}
func main() {
go sayHello() // here the goroutine starts
// the main function can continue working
}
Thus, the goroutine starts dynamically during execution, not at compile or initialization time.