From 6ee2c904644e0a1429808c5da7dd442567914781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Tue, 18 Jun 2024 12:24:05 +0800 Subject: [PATCH] update cli --- cli.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cli.go b/cli.go index 899a93d..8722d38 100644 --- a/cli.go +++ b/cli.go @@ -23,7 +23,9 @@ type cli struct { func (c *cli) ParseCLIParameter(parameterNameList []string) map[string]string { cliParameterTable := make(map[string]*string) for _, parameterName := range parameterNameList { - cliParameterTable[parameterName] = flag.String(parameterName, "", parameterName) + var val string + flag.StringVar(&val, parameterName, "", parameterName) + cliParameterTable[parameterName] = &val } // 这里有一个非常中的操作,转换,必须调用该方法 flag.Parse()