1 Star 0 Fork 53

jo-y / smscode

forked from xluohome / smscode 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
config.go 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
xluo 提交于 2017-03-26 22:12 . 1:优化了程序
package main
import (
"io/ioutil"
"time"
"gopkg.in/yaml.v2"
)
type Config struct {
Bind string `yaml:"bind"`
Timezone string `yaml:"timezone"`
TimeOut time.Duration `yaml:"timeout"`
Vendors map[string]map[string]string `yaml:"vendors"`
Juheapikey string `yaml:"juheapikey"`
ServiceList map[string]*ServiceConfig `yaml:"servicelist"`
Errormsg map[string]string `yaml:"errormsg"`
}
type ServiceConfig struct {
Vendor string `yaml:"vendor"`
Group string `yaml:"group"`
Tpl string `yaml:"smstpl"`
Signname string `yaml:"signname"`
Allowcity []string `yaml:"allowcitys"`
MaxSendNums uint64 `yaml:"maxsendnums"` //每天最大发送数量
Callback string `yaml:"callback"` //成功后回调URL
Mode byte `yaml:"mode"`
Validtime int64 `yaml:"validtime"`
Outformat string `yaml:"outformat"`
}
func (cfg *Config) ParseConfigData(data []byte) error {
if err := yaml.Unmarshal([]byte(data), &cfg); err != nil {
return err
}
return nil
}
func (cfg *Config) ParseConfigFile(fileName string) error {
data, err := ioutil.ReadFile(fileName)
if err != nil {
return err
}
return cfg.ParseConfigData(data)
}
Go
1
https://gitee.com/jo_y/smscode.git
git@gitee.com:jo_y/smscode.git
jo_y
smscode
smscode
master

搜索帮助