Create config file when it's missing

This commit is contained in:
Arturo Filastò
2018-06-25 17:49:17 +02:00
parent a6b95f50c9
commit 78cf8d6ca2
3 changed files with 35 additions and 16 deletions
+2 -3
View File
@@ -3,7 +3,6 @@ package config
import (
"encoding/json"
"io/ioutil"
"path/filepath"
"sync"
"github.com/ooni/probe-cli/utils"
@@ -14,7 +13,7 @@ import (
func ReadConfig(path string) (*Config, error) {
b, err := ioutil.ReadFile(path)
if err != nil {
return nil, errors.Wrap(err, "reading file")
return nil, err
}
c, err := ParseConfig(b)
@@ -93,7 +92,7 @@ func (c *Config) Default() error {
return err
}
c.path = filepath.Join(home, "config.json")
c.path = utils.ConfigPath(home)
return nil
}