Files
HomesteadGateway/util/config/toml.go
2025-11-30 22:00:47 +01:00

22 lines
349 B
Go

package config
import (
"fmt"
"os"
"github.com/pelletier/go-toml/v2"
)
func LoadConfig(path string) (*Config, error) {
file, err := os.Open(path)
if err != nil {
return nil, fmt.Errorf("failed to open config: %w", err)
}
var cfg Config
if err = toml.NewDecoder(file).Decode(&cfg); err != nil {
return nil, err
}
return &cfg, nil
}