From 91fe674dea64d2ff085aa9b276efbccad6a89617 Mon Sep 17 00:00:00 2001 From: wood911010 Date: Sat, 14 Feb 2026 19:22:07 +0800 Subject: [PATCH] feat: Add initial license manager backend application, configuration, and development installation documentation. --- backend/cmd/main.go | 16 +++++++++++++--- backend/docs/install/dev_install.md | 9 +++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 backend/docs/install/dev_install.md diff --git a/backend/cmd/main.go b/backend/cmd/main.go index 56531c5..e3b89ef 100644 --- a/backend/cmd/main.go +++ b/backend/cmd/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" "log" "os" @@ -36,10 +37,19 @@ import ( // @description Bearer token for authentication func main() { + // 定义命令行参数 + var customPath string + flag.StringVar(&customPath, "config", "", "path to configuration file") + flag.StringVar(&customPath, "c", "", "path to configuration file (shorthand)") + flag.Parse() + // 加载配置 - configPath := "config.yaml" // Docker 环境默认路径 - if _, err := os.Stat(configPath); os.IsNotExist(err) { - configPath = "../configs/config.yaml" // 本地开发环境 + configPath := customPath + if configPath == "" { + configPath = "config.yaml" // Docker 环境默认路径 + if _, err := os.Stat(configPath); os.IsNotExist(err) { + configPath = "../configs/config.yaml" // 本地开发环境 + } } if err := config.Load(configPath); err != nil { diff --git a/backend/docs/install/dev_install.md b/backend/docs/install/dev_install.md new file mode 100644 index 0000000..e653c88 --- /dev/null +++ b/backend/docs/install/dev_install.md @@ -0,0 +1,9 @@ +## 本地开发环境 + +```bash +# 使用默认配置 +go run cmd/main.go + +# 指定配置文件 +go run . -config configs/config.dev.yaml +``` \ No newline at end of file