This commit is contained in:
白茶清欢 2024-11-08 16:56:54 +08:00
parent 4ed113337f
commit 3ea314dc09

View File

@ -13,6 +13,7 @@ import (
"github.com/caarlos0/env/v9" "github.com/caarlos0/env/v9"
"github.com/jessevdk/go-flags" "github.com/jessevdk/go-flags"
"github.com/joho/godotenv" "github.com/joho/godotenv"
"os"
) )
// Init 初始化配置 // Init 初始化配置
@ -65,7 +66,8 @@ func parseCliParam(cliReceiver any) error {
return nil return nil
} }
// 解析命令行参数 // 解析命令行参数
if _, err := flags.Parse(cliReceiver); nil != err { parser := flags.NewParser(cliReceiver, flags.Default)
if _, err := parser.ParseArgs(os.Args[1:]); nil != err {
return errors.New("cli param parse fail : " + err.Error()) return errors.New("cli param parse fail : " + err.Error())
} }
return nil return nil