mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
go-ipfs-config: fix(config): avoid clobbering user-provided key value pairs
let me know if this looks off @whyrusleeping @jbenet
This commit is contained in:
parent
ea5243400c
commit
058c999ba0
@ -219,3 +219,15 @@ func FromMap(v map[string]interface{}) (*Config, error) {
|
||||
}
|
||||
return &conf, nil
|
||||
}
|
||||
|
||||
func ToMap(conf *Config) (map[string]interface{}, error) {
|
||||
var buf bytes.Buffer
|
||||
if err := json.NewEncoder(&buf).Encode(conf); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var m map[string]interface{}
|
||||
if err := json.NewDecoder(&buf).Decode(&m); err != nil {
|
||||
return nil, fmt.Errorf("Failure to decode config: %s", err)
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user