package main import ( "fmt" "sync" ) func main() { defer func() { fmt.Println("defer") }() var wg sync.WaitGroup wg.Add(1) go func(wg *sync.WaitGroup) { defer wg.Done() //time.Sleep(1000000) fmt.Println("gogoggogogo") }(&wg) wg.Wait() } 结果: gogoggogogo defer