123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- 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 {
- Serve serve
- DB Db
- Log Log
- }
- type serve struct {
- JyHref string
- }
- // Log Config
- type Log struct {
- LogPath string
- MaxSize int
- Compress bool
- MaxAge int
- MaxBackups int
- LogLevel string
- Format string
- }
- type Db struct {
- Mongo mgo
- Mysql mysql
- Es es
- }
- type mgo struct {
- Addr string
- Dbname string
- Coll string
- Size int
- User string
- Password string
- }
- type mysql struct {
- Addr string
- DbnameBasic string
- DbnameMedical string
- Size int
- User string
- Password string
- Drivename string
- Dsn string
- MaxIdle int
- MaxConn int
- MaxQueryTime duration
- }
- type es struct {
- Addr string
- Size int
- IndexM string
- TypeM string
- IndexS string
- TypeS string
- FieldM map[string]interface{}
- FieldS map[string]interface{}
- }
- 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
- }
|