fix: return fs errors on config creation

This commit is contained in:
Luke K 2020-08-29 01:20:39 +09:00
parent 6fdbb649ba
commit adcd93d70c
No known key found for this signature in database
GPG Key ID: 4896F75BAF2E1966
1 changed files with 6 additions and 3 deletions

View File

@ -29,9 +29,12 @@ type config struct {
// empty value of Config.
func newConfig(root string) (c config, err error) {
filename := filepath.Join(root, ConfigFile)
if _, err = os.Stat(filename); os.IsNotExist(err) {
err = nil // do not consider a missing config file an error
return // return the zero value of the config
if _, err = os.Stat(filename); err != nil {
// do not consider a missing config file an error. Just return.
if os.IsNotExist(err) {
err = nil
}
return
}
bb, err := ioutil.ReadFile(filename)
if err != nil {