ax(mining): replace copy builtin shadow with settingsCopy, comment as usage example
AX Principle 1 — predictable names over short names: variable `copy` shadows the Go builtin and carries no semantic meaning. Renamed to `settingsCopy`. AX Principle 2 — comments as usage examples: replaced prose description on SettingsManager.Get with a concrete call showing how the return value is used. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
4a586f4dad
commit
79a48a3a18
1 changed files with 4 additions and 3 deletions
|
|
@ -150,14 +150,15 @@ func (sm *SettingsManager) Save() error {
|
|||
return os.WriteFile(sm.settingsPath, data, 0600)
|
||||
}
|
||||
|
||||
// Get returns a copy of the current settings
|
||||
// settings := sm.Get()
|
||||
// if settings.Theme == "dark" { ... }
|
||||
func (sm *SettingsManager) Get() *AppSettings {
|
||||
sm.mu.RLock()
|
||||
defer sm.mu.RUnlock()
|
||||
|
||||
// Return a copy to prevent concurrent modification
|
||||
copy := *sm.settings
|
||||
return ©
|
||||
settingsCopy := *sm.settings
|
||||
return &settingsCopy
|
||||
}
|
||||
|
||||
// Update applies changes to settings and saves
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue