package main import ( "fmt" "os" "gopkg.in/yaml.v3" ) type Config struct { Server struct { Port int `yaml:"port"` RefreshInterval int `yaml:"refresh_interval"` } `yaml:"server"` Stations []Station `yaml:"stations"` } type Station struct { Name string `yaml:"name"` Code string `yaml:"code"` } func LoadConfig(filename string) (*Config, error) { data, err := os.ReadFile(filename) if err != nil { return nil, fmt.Errorf("failed to read config file: %w", err) } var config Config err = yaml.Unmarshal(data, &config) if err != nil { return nil, fmt.Errorf("failed to parse config file: %w", err) } return &config, nil }