From c2f25422ea2043aa8eff9ad7118430a3fb26af7c Mon Sep 17 00:00:00 2001 From: Kersten Burkhardt Date: Wed, 26 Mar 2025 07:01:34 +0100 Subject: [PATCH] fix: avoid shadowing of 'err' in CLI options, YAML store, and external plugin helpers Replaced short variable declarations with assignments in pkg/cli/options.go, pkg/config/store/yaml/store.go, and pkg/plugins/external/helpers.go to avoid shadowing the outer 'err' variable. These changes improve error traceability and follow Go best practices for scoped variable reuse and readability. --- pkg/cli/options.go | 2 +- pkg/config/store/yaml/store.go | 2 +- pkg/plugins/external/helpers.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/cli/options.go b/pkg/cli/options.go index 208b1c748da..7f8730ee079 100644 --- a/pkg/cli/options.go +++ b/pkg/cli/options.go @@ -203,7 +203,7 @@ func getPluginsRoot(host string) (pluginsRoot string, err error) { // if user provides specific path, return if pluginsPath := os.Getenv("EXTERNAL_PLUGINS_PATH"); pluginsPath != "" { // verify if the path actually exists - if _, err := os.Stat(pluginsPath); err != nil { + if _, err = os.Stat(pluginsPath); err != nil { if os.IsNotExist(err) { // the path does not exist return "", fmt.Errorf("the specified path %s does not exist", pluginsPath) diff --git a/pkg/config/store/yaml/store.go b/pkg/config/store/yaml/store.go index c7a133f44b0..cfd8274de75 100644 --- a/pkg/config/store/yaml/store.go +++ b/pkg/config/store/yaml/store.go @@ -89,7 +89,7 @@ func (s *yamlStore) LoadFrom(path string) error { // Check the file version var versioned versionedConfig - if err := yaml.Unmarshal(in, &versioned); err != nil { + if err = yaml.Unmarshal(in, &versioned); err != nil { return store.LoadError{Err: fmt.Errorf("unable to determine config version: %w", err)} } diff --git a/pkg/plugins/external/helpers.go b/pkg/plugins/external/helpers.go index dd06629f6f3..fdf733a5966 100644 --- a/pkg/plugins/external/helpers.go +++ b/pkg/plugins/external/helpers.go @@ -127,7 +127,7 @@ func getUniverseMap(fs machinery.Filesystem) (map[string]string, error) { } defer func() { - if err := file.Close(); err != nil { + if err = file.Close(); err != nil { return } }()