mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 17:13:51 +00:00
26 lines
414 B
Go
26 lines
414 B
Go
package config
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func LoadConfigFile(filename string, v interface{}) error {
|
|
data, err := ioutil.ReadFile(filename)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return json.Unmarshal(data, v)
|
|
}
|
|
|
|
func SaveConfigFile(filename string, v interface{}) error {
|
|
out, err := json.MarshalIndent(v, "", " ")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return ioutil.WriteFile(filename, out, 0644)
|
|
}
|
|
|