Пример #1
0
func init() {
	cfg, err := ini.Load("/etc/yandex.cfg")
	if err != nil {
		log.Println(err)
	}

	flag.StringVar(&lang, "lang", cfg.Section("").Key("LANG").In("ru", []string{}), "Localization")
	flag.StringVar(&apikey, "apikey", cfg.Section("").Key("APIKEY").String(), "Yandex Dict.API Key")
	flag.Parse()
}
Пример #2
0
// ReadFile reads config from filename
// cfg := Config{}
// if err := cfg.ReadFile("my.conf"); err != nil {
//	log.Fataln(err)
// }
func (cfg *Config) ReadFile(filename string) error {
	c, err := ini.Load(filename)
	if err != nil {
		return err
	}
	cfg.c = c
	acc := cfg.c.Section("account")
	cfg.xmppConfig = &xmpp.Config{}
	cfg.xmppConfig.Resource = acc.Key("resource").String()
	cfg.xmppConfig.SkipTLS = acc.Key("SkipTLS").MustBool()
	cfg.xmppConfig.TrustedAddress = acc.Key("trusted").MustBool()
	cfg.xmppConfig.ServerCertificateSHA256 = FingerprintToBytes(acc.Key("FingerprintSHA256").String())
	return nil
}