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