初始化Go学习项目

This commit is contained in:
liumangmang
2025-12-26 17:56:02 +08:00
commit 7f4527d501
90 changed files with 3436 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package main
import (
"fmt"
"time"
)
func main() {
stop := make(chan struct{})
go func() {
select {
case <-stop:
fmt.Println("worker 收到停止信号,退出")
}
}()
time.Sleep(2 * time.Second)
fmt.Println("main: 关闭 stop channel")
close(stop)
time.Sleep(1 * time.Second)
}