package config import ( "flag" "time" "github.com/BurntSushi/toml" "kpt.notice/pkg/log" ) var ( confPath string Conf = &Config{} ) func init() { flag.StringVar(&confPath, "conf", "conf.toml", "default config path") } func Init(p string) (err error) { if p != "" { confPath = p } if _, err = toml.DecodeFile(confPath, &Conf); err != nil { panic(err) } return } type Config struct { // Log *log.Config `toml:"log"` DB *MySQLConfig `toml:"db"` Listen string `toml:"listen"` Log *log.Config `toml:"log"` Env string `toml:"env"` } type MySQLConfig struct { DSN string `toml:"dsn"` Active int `toml:"active"` Idle int `toml:"idle"` IdleTimeout time.Duration `toml:"idle_timeout"` } type Conifg struct { Level string `toml:"level"` File string `toml:"file"` Stdout bool `toml:"stdout"` }