update
parent
26bf8320e3
commit
abce1f5c8d
|
@ -2,6 +2,7 @@ package myconf
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/spf13/pflag"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -9,6 +10,13 @@ var (
|
||||||
vp = viper.New()
|
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{}) {
|
func LoadFile(confFile string, conf interface{}) {
|
||||||
vp.SetConfigFile(confFile)
|
vp.SetConfigFile(confFile)
|
||||||
err := vp.ReadInConfig()
|
err := vp.ReadInConfig()
|
||||||
|
|
Loading…
Reference in New Issue