Description
pkg/config/config.go declares a package-level ConfigPath variable that
is never read anywhere in the codebase, and would be broken on Windows if
anything did try to use it.
// pkg/config/config.go
var (
InsecureTLS bool = false
CaCertPaths string
Verbose bool = false
ConfigPath = filepath.Join(os.Getenv("HOME"), ".microcks-cli", "config.yaml")
)
Why it's dead
Grep for config.ConfigPath\b across the repo: every match resolves to
globalClientOpts.ConfigPath or opts.ConfigPath — both of which are
fields on the ClientOptions struct, not the package variable.
The actual default config path comes from DefaultLocalConfigPath() in
pkg/config/localconfig.go, which uses os.UserHomeDir() correctly.
Why it would also be wrong on Windows
os.Getenv("HOME") returns "" on Windows by default — Windows uses
USERPROFILE. So if anything ever started using config.ConfigPath, it
would silently produce a broken relative path like \.microcks-cli\config.yaml
on Windows.
The cross-platform-safe alternative is os.UserHomeDir(), which is what
localconfig.go already uses.
Proposed fix
Delete the unused ConfigPath variable. No replacement needed — the
real config path is computed by DefaultLocalConfigPath().
This also lets us drop the path/filepath import from config.go (it's
only used by this one line).
Impact
Zero behavioral change. The CLI never reads this variable; removing it is
a pure cleanup.
Environment
- Branch:
master (development version 1.0.3)
- File:
pkg/config/config.go
Description
pkg/config/config.godeclares a package-levelConfigPathvariable thatis never read anywhere in the codebase, and would be broken on Windows if
anything did try to use it.
Why it's dead
Grep for
config.ConfigPath\bacross the repo: every match resolves toglobalClientOpts.ConfigPathoropts.ConfigPath— both of which arefields on the
ClientOptionsstruct, not the package variable.The actual default config path comes from
DefaultLocalConfigPath()inpkg/config/localconfig.go, which usesos.UserHomeDir()correctly.Why it would also be wrong on Windows
os.Getenv("HOME")returns""on Windows by default — Windows usesUSERPROFILE. So if anything ever started usingconfig.ConfigPath, itwould silently produce a broken relative path like
\.microcks-cli\config.yamlon Windows.
The cross-platform-safe alternative is
os.UserHomeDir(), which is whatlocalconfig.goalready uses.Proposed fix
Delete the unused
ConfigPathvariable. No replacement needed — thereal config path is computed by
DefaultLocalConfigPath().This also lets us drop the
path/filepathimport fromconfig.go(it'sonly used by this one line).
Impact
Zero behavioral change. The CLI never reads this variable; removing it is
a pure cleanup.
Environment
master(development version1.0.3)pkg/config/config.go