首次提交:初始化项目代码

This commit is contained in:
sunct
2026-07-31 15:18:32 +08:00
commit d6393266b0
193 changed files with 14287 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
package main
import (
"fmt"
"time"
)
// 简单的 Goroutine 任务:打印数字
func printNums(prefix string, count int) {
for i := 0; i < count; i++ {
time.Sleep(100 * time.Millisecond)
fmt.Printf("%s: %d\n", prefix, i)
}
}
func main() {
// 启动两个 Goroutine
go printNums("Goroutine A", 5)
go printNums("Goroutine B", 5)
// 主 Goroutine 等待子 Goroutine 完成(实际开发用更可靠的同步方式)
time.Sleep(1 * time.Second)
fmt.Println("主程序退出")
}