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()