toml 总体上要比yaml和json更加优雅
包地址github.com/BurnSushi/toml
var (MySql *MySqlConfRedis *RedisConfIMService *IMServiceConfApiHttpService *ApiHttpServiceConf)type MySqlConf struct {Host stringPort intUsername stringPassword stringDb stringCharset string}type RedisConf struct {Host stringPort intPassword stringDb int}type IMServiceConf struct {Addr stringService stringPort int}type ApiHttpServiceConf struct {Addr stringPort int}type config struct {MySql MySqlConfRedis RedisConfIMService IMServiceConfApiHttp ApiHttpServiceConf}func init() {var conf configc := getConfigPath()logger.D("config path: %s", c)_, err := toml.DecodeFile(c, &conf)if err != nil {panic(fmt.Sprintf("error on load config: %s", err.Error()))}MySql = &conf.MySqlRedis = &conf.RedisIMService = &conf.IMServiceApiHttpService = &conf.ApiHttp}
