From 2ddb3d454efdd2ffc29ec6e00879e3fb3f641d5c Mon Sep 17 00:00:00 2001 From: akuma06 Date: Sat, 22 Jul 2017 01:24:13 +0200 Subject: [PATCH] Fix config load order. Configor has a reverted config files load priority :') --- config/config.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index f485fe99..d7b0d6ec 100644 --- a/config/config.go +++ b/config/config.go @@ -5,13 +5,15 @@ import ( "io" "sync" + "fmt" + "github.com/jinzhu/configor" yaml "gopkg.in/yaml.v2" ) var config *Config var once sync.Once -var Configpaths = []string{"config/default_config.yml", "config/config.yml"} +var Configpaths = []string{"config/config.yml", "config/default_config.yml"} func Get() *Config { once.Do(func() { @@ -53,6 +55,8 @@ func init() { // Reload the configuration from the files provided in the config variables func Reload() { + fmt.Println("Config reload") + fmt.Println(Configpaths) configor.Load(Get(), Configpaths...) } @@ -67,7 +71,7 @@ func BindFlags() func() { flag.StringVar(&Get().DBLogMode, "dblogmode", Get().DBLogMode, "database log verbosity (errors only by default)") return func() { if *confFile != "" { - Configpaths = append(Configpaths, *confFile) + Configpaths = append([]string{*confFile}, Configpaths...) Reload() } }