您好,我有一个包含 Go Routine 的以下 Golang 程序。
func main() {
go func(){
fmt.Println("Break Point 1")
}()
fmt.Println("Break Point 2")
time.Sleep(100 * time.Second)
fmt.Println("hello")
}
现在我的程序不会在断点 1 处中断。我还如何调试例程?
最佳答案
func main() {
go func() {
fmt.Println("Break Point 1")
}()
fmt.Println("Break Point 2")
time.Sleep(1 * time.Second)
fmt.Println("hello")
}
似乎在 go 例程被调度之前程序终止,这就是未到达断点的原因。您可以尝试在主例程中添加 sleep 吗?
关于go - 在 Intellij 中调试 Go 例程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54944390/