LoadAppConfig loads config from path. Returns nil, nil if file does not exist.
(path string)
| 380 | |
| 381 | // LoadAppConfig loads config from path. Returns nil, nil if file does not exist. |
| 382 | func LoadAppConfig(path string) (*Config, error) { |
| 383 | data, err := os.ReadFile(path) |
| 384 | if err != nil { |
| 385 | if os.IsNotExist(err) { |
| 386 | return nil, nil |
| 387 | } |
| 388 | return nil, fmt.Errorf("read app config %s: %w", path, err) |
| 389 | } |
| 390 | var cfg Config |
| 391 | if err := json.Unmarshal(data, &cfg); err != nil { |
| 392 | return nil, fmt.Errorf("parse app config: %w", err) |
| 393 | } |
| 394 | return &cfg, nil |
| 395 | } |
| 396 | |
| 397 | // supportedConfigKeys is the single source of truth for the top-level config |
| 398 | // keys accepted by setConfigValue. The unknown-key error message is generated |
no outgoing calls