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

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
+26
View File
@@ -0,0 +1,26 @@
package main
import (
"flag"
"fmt"
)
func main() {
port := flag.Int("port", 8080, "服务端口")
flag.Parse()
fmt.Println("动态修改前端口:", *port)
// 动态覆盖参数值
if err := flag.Set("port", "9090"); err != nil {
fmt.Println("参数设置失败:", err)
}
fmt.Println("动态修改后端口:", *port)
// 精准查询参数元信息
if f := flag.Lookup("port"); f != nil {
fmt.Printf("参数详情:名称=%s, 当前值=%s, 默认值=%s, 用途=%s\n",
f.Name, f.Value.String(), f.DefValue, f.Usage)
}
}