企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
#### goroutime ``` func main() { go func() { for i:=0;i<5;i++ { fmt.Println("go funce .....") time.Sleep(time.Second) } }() fmt.Println("main......") for{ ; } } ``` #### gosched ``` func main() { go func() { for{ fmt.Println("this is goroutime test") } }() for{ runtime.Gosched()//出让当前cpu时间片 fmt.Println("this is main test") } } ``` #### goexit ``` func test() { defer fmt.Println("ccccccccccccccccc") //return runtime.Goexit() // 退出当前go程。 defer fmt.Println("ddddddddddddddddd") } func main() { go func() { defer fmt.Println("aaaaaaaaaa") test() fmt.Println("bbbbbbbbbbbbb") }() for { ; } } ``` ####