package config import ( "fmt" "os" "gopkg.in/yaml.v3" ) type Config struct { Server ServerConfig `yaml:"server"` MMDB MMDBConfig `yaml:"mmdb"` Log LogConfig `yaml:"log"` } type ServerConfig struct { Host string `yaml:"host"` Port int `yaml:"port"` } type MMDBConfig struct { FilePath string `yaml:"filePath"` } type LogConfig struct { Level string `yaml:"level"` } func Load(path string) (Config, error) { var cfg Config data, err := os.ReadFile(path) if err != nil { return cfg, fmt.Errorf("read config: %w", err) } if err := yaml.Unmarshal(data, &cfg); err != nil { return cfg, fmt.Errorf("parse yaml: %w", err) } return cfg, nil }