@cryptotaxi247 / kubo / commits / bbcbf46ce

fix(repo/config) detect strings that represent ints

Brian Tiger Chow committed Feb 3, 2015 at 17:18 UTC bbcbf46ce739d628b7547e9c8052e9384eb2cbbc
1 file changed +8
repo/fsrepo/component/config.go
+8
@@ -1,6 +1,8 @@
1 package component
2
3 import (
4 + "strconv"
5 +
6 common "github.com/jbenet/go-ipfs/repo/common"
7 config "github.com/jbenet/go-ipfs/repo/config"
8 serialize "github.com/jbenet/go-ipfs/repo/fsrepo/serialize"
@@ -86,6 +88,12 @@ func (c *ConfigComponent) SetConfigKey(key string, value interface{}) error {
88 if err != nil {
89 return err
90 }
91 + switch v := value.(type) {
92 + case string:
93 + if i, err := strconv.Atoi(v); err == nil {
94 + value = i
95 + }
96 + }
97 var mapconf map[string]interface{}
98 if err := serialize.ReadConfigFile(filename, &mapconf); err != nil {
99 return err