Skip to content

Commit

Permalink
fix: return fs errors on config creation
Browse files Browse the repository at this point in the history
  • Loading branch information
lkingland committed Aug 28, 2020
1 parent 6fdbb64 commit adcd93d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit adcd93d

Please sign in to comment.