liuxiaolong
2019-08-23 ccf396d18f149c3ba1d5bb1279f29a5d6eff864c
extend/config/config.go
@@ -1,9 +1,8 @@
package config
import (
   "log"
   "github.com/spf13/viper"
   "log"
)
type server struct {
@@ -12,9 +11,19 @@
   JwtExpire string `mapstructure: "jwtExpire"`
   Url       string `mapstructure: "url"`
   ImageUrl  string `mapstructure: "imageUrl"`
   PublicDomain string `mapstructure: "publicDomain"`
   NetworkAdapter string `mapstructure: "networkAdapter"`
}
var Server = &server{}
type weedfs struct {
   Ip string `mapstructure: "ip"`
   UploadPort int `mapstructure: "uploadport"`
   VisitPort int `mapstructure: "visitport"`
}
var WeedFs = &weedfs{}
type redis struct {
   Host     string `mapstructure:"host"`
@@ -44,15 +53,34 @@
   Dbtablepersons index `mapstructure:"dbtablepersons"`
   Personaction   index `mapstructure:"personaction"`
}
type index struct {
   IndexName string `mapstructure:"index"`
   IndexType string `mapstructure:"type"`
}
type sopath struct {
   Ip string `mapstructure:"ip"`
   Port string `mapstructure:"port"`
}
var SoPath = &sopath{}
var EsInfo = &esinfo{}
var DBconf = &database{}
type dbpersoncompare struct {
   Url string `mapstructure:"url"`
}
type espersoncompare struct {
   Url []string `mapstructure:"url"`
}
var DbPersonCompInfo = &dbpersoncompare{}
var EsCompServerInfo = &espersoncompare{}
// Init is an exported method that takes the environment starts the viper
// (external lib) and returns the configuration struct.
@@ -70,4 +98,8 @@
   viper.UnmarshalKey("server", Server)
   viper.UnmarshalKey("redis", RedisConf)
   viper.UnmarshalKey("database", DBconf)
   viper.UnmarshalKey("weedfs", WeedFs)
   viper.UnmarshalKey("sopath",SoPath)
   viper.UnmarshalKey("dbpersoncompare",DbPersonCompInfo)
   viper.UnmarshalKey("espersoncompare", EsCompServerInfo)
}