Skip to content

refactor(cmd): use an injected viper instance instead of the global singleton - #64

Merged
sbldevnet merged 1 commit into
mainfrom
agent/go-dev/d44205cc70c8
Sep 28, 2026
Merged

sbldevnet merged 1 commit into
mainfrom
agent/go-dev/d44205cc70c8

Conversation

@sbldevnet

Copy link
Copy Markdown
Owner

Summary

  • Replace the global Viper singleton (viper.*) in internal/cmd/cmd.go and internal/cmd/logger.go with a *viper.Viper instance created via viper.New() in Run()'s RunE, threaded through initConfig and logOptions.withConfig.
  • Remove viper.Reset() / t.Cleanup(viper.Reset) from cmd_test.go and logger_test.go; tests now create their own viper.New() instance, eliminating cross-test global state.

Test plan

  • go build ./...
  • go vet ./...
  • go test -race ./... (also ran -count=5 on internal/cmd)
  • Confirmed no package-level viper.* calls remain in internal/cmd

…ingleton

Thread *viper.Viper through initConfig and logOptions.withConfig instead of
calling package-level viper functions, removing the need for viper.Reset()
between tests.
@sbldevnet
sbldevnet merged commit 5a3a66c into main Sep 28, 2026
4 checks passed
@sbldevnet
sbldevnet deleted the agent/go-dev/d44205cc70c8 branch September 28, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant