package main

import ( "fmt" "time" )

func main() { go func() { for { fmt.Println('Hello, World!') time.Sleep(500 * time.Millisecond) } }() time.Sleep(3 * time.Second) }

Golang 实现 3 秒结束的死循环代码示例