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