package config import ( "log" "gopkg.in/ini.v1" ) type Config struct { Server struct { BaseUrl string Address string WebhookSecret string Port int } Owncast struct { BaseUrl string } Test struct { Enable bool } Twitch struct { Enable bool Channel string } } var config *Config func Get() *Config { if config == nil { config = &Config{} } return config } func (c *Config) Load(file string) { cfg, err := ini.Load(file) if err != nil { log.Fatal(err) } config.Server.Address = cfg.Section("server").Key("address").String() config.Server.Port, _ = cfg.Section("server").Key("port").Int() config.Server.BaseUrl = cfg.Section("server").Key("base_url").String() config.Server.WebhookSecret = cfg.Section("server").Key("webhook_secret").String() config.Owncast.BaseUrl = cfg.Section("owncast").Key("base_url").String() config.Test.Enable = cfg.Section("test").Key("enable").MustBool(false) config.Twitch.Enable = cfg.Section("twitch").Key("enable").MustBool(false) config.Twitch.Channel = cfg.Section("twitch").Key("channel").String() }