diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-08 20:40:47 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-08 20:40:47 +0000 |
| commit | db1ebb7a3f9310ca2cc483d65e9c0e578c2eb4ff (patch) | |
| tree | dd232a65b1a9b963df62eb431d79432ca1739cf2 /internal/config/config.go | |
| parent | 7914153d3e65cec7a178e7454c9d4addbbbbdd3f (diff) | |
config: Default() returns error
Default() now returns (*Config, error) so callers can detect TOML parse
failures rather than silently falling back to zero values.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/config/config.go')
| -rw-r--r-- | internal/config/config.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index da7f264..12adf68 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1,6 +1,8 @@ package config import ( + "errors" + "fmt" "os" "path/filepath" ) @@ -16,8 +18,14 @@ type Config struct { WebhookURL string `toml:"webhook_url"` } -func Default() *Config { - home, _ := os.UserHomeDir() +func Default() (*Config, error) { + home, err := os.UserHomeDir() + if err != nil { + return nil, fmt.Errorf("cannot determine home directory: %w", err) + } + if home == "" { + return nil, errors.New("cannot determine home directory: HOME is empty") + } dataDir := filepath.Join(home, ".claudomator") return &Config{ DataDir: dataDir, @@ -27,7 +35,7 @@ func Default() *Config { MaxConcurrent: 3, DefaultTimeout: "15m", ServerAddr: ":8484", - } + }, nil } // EnsureDirs creates the data directory structure. |
