From abce1f5c8d0d745c8dfdce410ae92cbb74222c4f Mon Sep 17 00:00:00 2001 From: kzkzzzz Date: Sun, 23 Jun 2024 13:15:47 +0800 Subject: [PATCH] update --- myconf/conf.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/myconf/conf.go b/myconf/conf.go index 9a12b11..0e31646 100644 --- a/myconf/conf.go +++ b/myconf/conf.go @@ -2,6 +2,7 @@ package myconf import ( "fmt" + "github.com/spf13/pflag" "github.com/spf13/viper" ) @@ -9,6 +10,13 @@ var ( vp = viper.New() ) +func LoadFlag() { + err := vp.BindPFlags(pflag.CommandLine) + if err != nil { + panic(fmt.Errorf("load command line fail: %s", err)) + } +} + func LoadFile(confFile string, conf interface{}) { vp.SetConfigFile(confFile) err := vp.ReadInConfig()