Remove unused cached var in config package
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -53,10 +53,7 @@ var defaults = Config{
|
|||||||
LastEventID: 0,
|
LastEventID: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var mu sync.Mutex
|
||||||
mu sync.Mutex
|
|
||||||
cached *Config
|
|
||||||
)
|
|
||||||
|
|
||||||
// Load reads config from disk, merging with defaults.
|
// Load reads config from disk, merging with defaults.
|
||||||
func Load() Config {
|
func Load() Config {
|
||||||
@@ -71,7 +68,7 @@ func Load() Config {
|
|||||||
if err := json.Unmarshal(data, &cfg); err != nil {
|
if err := json.Unmarshal(data, &cfg); err != nil {
|
||||||
log.Printf("config: parse error: %v", err)
|
log.Printf("config: parse error: %v", err)
|
||||||
}
|
}
|
||||||
cached = &cfg
|
|
||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +85,7 @@ func Save(cfg Config) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cached = &cfg
|
|
||||||
return os.WriteFile(ConfigPath(), data, 0o644)
|
return os.WriteFile(ConfigPath(), data, 0o644)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,11 +39,6 @@ func TestSaveLoadRoundTrip(t *testing.T) {
|
|||||||
t.Fatalf("Save failed: %v", err)
|
t.Fatalf("Save failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear cache so Load reads from disk
|
|
||||||
mu.Lock()
|
|
||||||
cached = nil
|
|
||||||
mu.Unlock()
|
|
||||||
|
|
||||||
loaded := Load()
|
loaded := Load()
|
||||||
if loaded.SyncthingAPIKey != "test-key-12345" {
|
if loaded.SyncthingAPIKey != "test-key-12345" {
|
||||||
t.Errorf("API key not round-tripped: got %q", loaded.SyncthingAPIKey)
|
t.Errorf("API key not round-tripped: got %q", loaded.SyncthingAPIKey)
|
||||||
|
|||||||
Reference in New Issue
Block a user