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

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
+32
View File
@@ -0,0 +1,32 @@
package main
import (
"flag"
"fmt"
"os"
"strconv"
)
func main() {
port := flag.Int("port", 8080, "服务端口")
host := flag.String("host", "localhost", "服务绑定主机")
flag.Parse()
// 环境变量仅覆盖未手动传参的配置
if !flag.IsSet("port") {
if envPort := os.Getenv("SERVICE_PORT"); envPort != "" {
if p, err := strconv.Atoi(envPort); err == nil {
*port = p
}
}
}
if !flag.IsSet("host") {
if envHost := os.Getenv("SERVICE_HOST"); envHost != "" {
*host = envHost
}
}
fmt.Printf("最终生效配置:主机=%s,端口=%d\n", *host, *port)
}