From 1203dec5aa384da3008db2826cb9f2687640c534 Mon Sep 17 00:00:00 2001 From: Sam Coe Date: Sun, 11 Sep 2022 15:45:33 +0400 Subject: [PATCH] Return correct error on config read --- pkg/config/config.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 20d0bee..15668df 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -24,8 +24,9 @@ const ( ) var ( - cfg *Config - once sync.Once + cfg *Config + once sync.Once + loadErr error ) // Config is a in memory representation of the gh configuration files. @@ -121,11 +122,10 @@ func (c *Config) Set(keys []string, value string) { // Read gh configuration files from the local file system and // return a Config. var Read = func() (*Config, error) { - var err error once.Do(func() { - cfg, err = load(generalConfigFile(), hostsConfigFile()) + cfg, loadErr = load(generalConfigFile(), hostsConfigFile()) }) - return cfg, err + return cfg, loadErr } // ReadFromString takes a yaml string and returns a Config.