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