diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-06 23:40:21 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-06 23:40:21 +0800 |
commit | 548e1041718ffc0ee0659f1ff99b37cad38190c0 (patch) | |
tree | dc354aae2e364e4a2a426efc0ca5f6412acfa980 /ethutil | |
parent | 8d9be18b296afb8302249dcc96651aabb0975e26 (diff) | |
parent | e64f727529287b7414af6d1f482ea5f318cbd2eb (diff) | |
download | dexon-548e1041718ffc0ee0659f1ff99b37cad38190c0.tar.gz dexon-548e1041718ffc0ee0659f1ff99b37cad38190c0.tar.zst dexon-548e1041718ffc0ee0659f1ff99b37cad38190c0.zip |
Merge branch 'poc-9' of github.com-obscure:ethereum/go-ethereum into poc-9
Diffstat (limited to 'ethutil')
-rw-r--r-- | ethutil/config.go | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/ethutil/config.go b/ethutil/config.go index fc8fb4e3f..c45c310ce 100644 --- a/ethutil/config.go +++ b/ethutil/config.go @@ -20,30 +20,27 @@ type ConfigManager struct { conf *globalconf.GlobalConf } -var Config *ConfigManager - // Read config // // Initialize Config from Config File func ReadConfig(ConfigFile string, Datadir string, EnvPrefix string) *ConfigManager { - if Config == nil { - // create ConfigFile if does not exist, otherwise globalconf panic when trying to persist flags - if !FileExist(ConfigFile) { - fmt.Printf("config file '%s' doesn't exist, creating it\n", ConfigFile) - os.Create(ConfigFile) - } - g, err := globalconf.NewWithOptions(&globalconf.Options{ - Filename: ConfigFile, - EnvPrefix: EnvPrefix, - }) - if err != nil { - fmt.Println(err) - } else { - g.ParseAll() - } - Config = &ConfigManager{ExecPath: Datadir, Debug: true, conf: g, Paranoia: true} + if !FileExist(ConfigFile) { + // create ConfigFile if it does not exist, otherwise + // globalconf will panic when trying to persist flags. + fmt.Printf("config file '%s' doesn't exist, creating it\n", ConfigFile) + os.Create(ConfigFile) + } + g, err := globalconf.NewWithOptions(&globalconf.Options{ + Filename: ConfigFile, + EnvPrefix: EnvPrefix, + }) + if err != nil { + fmt.Println(err) + } else { + g.ParseAll() } - return Config + cfg := &ConfigManager{ExecPath: Datadir, Debug: true, conf: g, Paranoia: true} + return cfg } // provides persistence for flags |