diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-06-19 16:34:59 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-06-19 16:34:59 +0200 |
| commit | 261cdc2564653b62f966466332e5d145364b4073 (patch) | |
| tree | 703f19e29ab6151925fbdda7b50533fcc0341235 /pkg/config | |
| parent | 98877a11dd1ab9e9570bfc7552140ccec8b9d326 (diff) | |
pkg/config: add SaveFile function
Diffstat (limited to 'pkg/config')
| -rw-r--r-- | pkg/config/config.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go index b31399713..fc77d2496 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -32,6 +32,14 @@ func LoadData(data []byte, cfg interface{}) error { return nil } +func SaveFile(filename string, cfg interface{}) error { + data, err := json.MarshalIndent(cfg, "", "\t") + if err != nil { + return err + } + return ioutil.WriteFile(filename, data, 0600) +} + func checkUnknownFields(data []byte, typ reflect.Type) error { if typ.Kind() != reflect.Ptr || typ.Elem().Kind() != reflect.Struct { return fmt.Errorf("config type is not pointer to struct") |
