1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- package config
- import (
- "fmt"
- "os"
- "time"
- "github.com/BurntSushi/toml"
- )
- var (
- // Conf crocodile conf
- Conf *conf
- )
- // Init Config
- func Init(conf string) {
- _, err := toml.DecodeFile(conf, &Conf)
- if err != nil {
- fmt.Printf("Err %v", err)
- os.Exit(1)
- }
- }
- type conf struct {
- DB Db
- Log Log
- Buyer Buyer
- Winner Winner
- }
- // Log Config
- type Log struct {
- LogPath string
- MaxSize int
- Compress bool
- MaxAge int
- MaxBackups int
- LogLevel string
- Format string
- }
- // Buyer
- type Buyer struct {
- }
- // Winner
- type Winner struct {
- }
- type Db struct {
- Drivename string
- Dsn string
- MaxIdle int
- MaxConn int
- MaxQueryTime duration
- }
- type duration struct {
- time.Duration
- }
- // UnmarshalText parse 10s to time.Time
- func (d *duration) UnmarshalText(text []byte) error {
- var err error
- d.Duration, err = time.ParseDuration(string(text))
- return err
- }
|