-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Problem
The current implementation uses a global exported variable var C Config. This can cause a few issues
- The global variable can be overwritten by any package importing
config. - Doesn't respect naming clarity according to "Effective Go" principles.
config.Cis often mistaken for CGo calls.
Proposed Solution
Refactor the config package to hide the global state and expose it through a read-only getter.
Changes in config/config.go
- Change
var C Configtovar instance Config. - Implement a
Get()function.
func Get() Config {
return instance
}- Ensure
Load()populates the unexportedinstanceand returns(*Config, error)for better accessibility throughout project.
Project-wide Impact
Replace all instances of config.C with config.Get().
| Current | Refactored |
|---|---|
| config.C.LogLevel | config.Get().LogLevel |
| config.C.Paths.Database | config.Get().Paths.Database |
Definition of Done
-
config.Cis no longer exported. - No direct modification of configuration is possible from external packages.
- All existing tests run successfully
go test ./.... - Application compiles successfully with
config.Get().
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels