LoadConfig loads the configuration from disk.
(file string)
| 41 | |
| 42 | // LoadConfig loads the configuration from disk. |
| 43 | func LoadConfig(file string) (*Config, error) { |
| 44 | cfg := &Config{ |
| 45 | Listen: "unix:///var/run/app.sock", |
| 46 | Protocol: "socket", |
| 47 | PersistInterval: 1, |
| 48 | } |
| 49 | _, err := toml.DecodeFile(file, &cfg) |
| 50 | if err != nil { |
| 51 | return nil, fmt.Errorf("failed to load config from %q: %w", file, err) |
| 52 | } |
| 53 | return cfg, cfg.Validate() |
| 54 | } |
| 55 | |
| 56 | // Validate validates the configuration. We don't do exhaustive config |
| 57 | // validation here, instead relying on Testnet.Validate() to handle it. |