package options import ( "gopkg.in/yaml.v3" "os" ) type Config struct { DB DBOption `yaml:"db"` Proxy ProxyOption `yaml:"proxy"` } func LoadConfig() (*Config, error) { var opt Config f, err := os.Open("/data/cfg.yaml") if err != nil { return nil, err } defer f.Close() return &opt, yaml.NewDecoder(f).Decode(&opt) }