diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-07-28 19:29:42 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-07-28 19:29:42 +0800 |
commit | 1fad8798ec043b9b829caea96dd7a2c5e7b1ed36 (patch) | |
tree | 8ff1d0588ec33c9d3d2f0a031fe92daa33fb8c14 /common/config.go | |
parent | 572e78cee056951c12cfc1c941b48b0fcc1ed6ed (diff) | |
parent | cd657b98780a74d08c110291dcf8d1183b64be15 (diff) | |
download | go-tangerine-1fad8798ec043b9b829caea96dd7a2c5e7b1ed36.tar go-tangerine-1fad8798ec043b9b829caea96dd7a2c5e7b1ed36.tar.gz go-tangerine-1fad8798ec043b9b829caea96dd7a2c5e7b1ed36.tar.bz2 go-tangerine-1fad8798ec043b9b829caea96dd7a2c5e7b1ed36.tar.lz go-tangerine-1fad8798ec043b9b829caea96dd7a2c5e7b1ed36.tar.xz go-tangerine-1fad8798ec043b9b829caea96dd7a2c5e7b1ed36.tar.zst go-tangerine-1fad8798ec043b9b829caea96dd7a2c5e7b1ed36.zip |
Merge pull request #1515 from fjl/license-fixes
all: fix license headers one more time
Diffstat (limited to 'common/config.go')
-rw-r--r-- | common/config.go | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/common/config.go b/common/config.go deleted file mode 100644 index d2a0d4fa3..000000000 --- a/common/config.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2014 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// go-ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. - -package common - -import ( - "flag" - "fmt" - "os" - - "github.com/rakyll/globalconf" -) - -// Config struct -type ConfigManager struct { - ExecPath string - Debug bool - Diff bool - DiffType string - Paranoia bool - VmType int - - conf *globalconf.GlobalConf -} - -// Read config -// -// Initialize Config from Config File -func ReadConfig(ConfigFile string, Datadir string, EnvPrefix string) *ConfigManager { - 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() - } - cfg := &ConfigManager{ExecPath: Datadir, Debug: true, conf: g, Paranoia: true} - return cfg -} - -// provides persistence for flags -func (c *ConfigManager) Save(key string, value interface{}) { - f := &flag.Flag{Name: key, Value: newConfValue(value)} - c.conf.Set("", f) -} - -func (c *ConfigManager) Delete(key string) { - c.conf.Delete("", key) -} - -// private type implementing flag.Value -type confValue struct { - value string -} - -// generic constructor to allow persising non-string values directly -func newConfValue(value interface{}) *confValue { - return &confValue{fmt.Sprintf("%v", value)} -} - -func (self confValue) String() string { return self.value } -func (self confValue) Set(s string) error { self.value = s; return nil } |