From 744205afa60332a89cfc95b41036fe76607a11c1 Mon Sep 17 00:00:00 2001 From: Diogo Matsubara Date: Wed, 23 Aug 2023 16:30:02 +0200 Subject: [PATCH] Fix nil pointer error opening config file (#34) In case the config file exists in the home dir, use that one and return early, otherwise try to use the config file in xdg.ConfigFile("mctl/config.yaml") --- internal/app/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/app/app.go b/internal/app/app.go index b962fba9..32ac6b5a 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -49,7 +49,7 @@ func openConfig(path string) (*os.File, error) { path = filepath.Join(xdg.Home, ".mctl.yml") f, err := os.Open(path) - if err != nil { + if err == nil { return f, nil } if !errors.Is(err, os.ErrNotExist) {