123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- 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
- Udp udp
- Mail mail
- Log log
- }
- type udp struct {
- LocPort string
- JyAddr string
- JyPort int
- }
- type udpNext struct {
- Addr string
- Port int
- Stype string
- }
- type mail struct {
- Send bool
- To string
- Api string
- }
- // Log Config
- type log struct {
- LogPath string
- MaxSize int
- Compress bool
- MaxAge int
- MaxBackups int
- LogLevel string
- Format string
- }
- type db struct {
- MongoB mgo
- MongoP mgo
- MongoQ mgo
- Es es
- Oss oss
- }
- //oss oss 阿里云配置
- type oss struct {
- Endpoint string
- AccessKey string
- AccessSecret string
- BucketName string
- }
- type mgo struct {
- Addr string
- Dbname string
- Coll string
- Size int
- User string
- Password string
- }
- type es struct {
- Addr string
- AddrP string
- Size int
- Username string
- Password string
- IndexB string
- TypeB string
- IndexP string
- TypeP string
- IndexWinner string
- TypeWinner string
- IndexBuyer string
- TypeBuyer string
- FieldEs map[string]interface{}
- FieldPurchasingList map[string]interface{}
- FieldProcurementList map[string]interface{}
- FieldWinnerOrder map[string]interface{}
- DetailFilter []string
- }
- 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
- }
|