LoadAppConfig loads config from path. Returns nil, nil if file does not exist.
(path string)
| 336 | |
| 337 | // LoadAppConfig loads config from path. Returns nil, nil if file does not exist. |
| 338 | func LoadAppConfig(path string) (*Config, error) { |
| 339 | data, err := os.ReadFile(path) |
| 340 | if err != nil { |
| 341 | if os.IsNotExist(err) { |
| 342 | return nil, nil |
| 343 | } |
| 344 | return nil, fmt.Errorf("read app config %s: %w", path, err) |
| 345 | } |
| 346 | var cfg Config |
| 347 | if err := json.Unmarshal(data, &cfg); err != nil { |
| 348 | return nil, fmt.Errorf("parse app config: %w", err) |
| 349 | } |
| 350 | return &cfg, nil |
| 351 | } |
| 352 | |
| 353 | // supportedConfigKeys is the single source of truth for the top-level config |
| 354 | // keys accepted by setConfigValue. The unknown-key error message is generated |
no outgoing calls