update
This commit is contained in:
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user