LoadAppConfig loads config from path. Returns nil, nil if file does not exist.
(path string)
| 584 | |
| 585 | // LoadAppConfig loads config from path. Returns nil, nil if file does not exist. |
| 586 | func LoadAppConfig(path string) (*Config, error) { |
| 587 | data, err := os.ReadFile(path) |
| 588 | if err != nil { |
| 589 | if os.IsNotExist(err) { |
| 590 | return nil, nil |
| 591 | } |
| 592 | return nil, fmt.Errorf("read app config %s: %w", path, err) |
| 593 | } |
| 594 | var cfg Config |
| 595 | if err := json.Unmarshal(data, &cfg); err != nil { |
| 596 | return nil, fmt.Errorf("parse app config: %w", err) |
| 597 | } |
| 598 | return &cfg, nil |
| 599 | } |
| 600 | |
| 601 | // supportedConfigKeys is the single source of truth for the top-level config |
| 602 | // keys accepted by setConfigValue. The unknown-key error message is generated |
no outgoing calls