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