move config initialization to func
This commit is contained in:
parent
346763caea
commit
7243a5a95f
@ -124,14 +124,7 @@ func printVersion() {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func initConfig() {
|
||||||
setupViper()
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
if showVer {
|
|
||||||
printVersion()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a configuration file if set.
|
// Add a configuration file if set.
|
||||||
if config != "" {
|
if config != "" {
|
||||||
cfg := strings.TrimSuffix(config, filepath.Ext(config))
|
cfg := strings.TrimSuffix(config, filepath.Ext(config))
|
||||||
@ -152,6 +145,17 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
setupViper()
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
if showVer {
|
||||||
|
printVersion()
|
||||||
|
}
|
||||||
|
|
||||||
|
initConfig();
|
||||||
|
|
||||||
// Set up process log before anything bad happens.
|
// Set up process log before anything bad happens.
|
||||||
switch viper.GetString("Logger") {
|
switch viper.GetString("Logger") {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user