123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- 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"`
- }
|