package insertdata import ( "github.com/spf13/viper" "log" ) type weedfs struct { Ip string `mapstructure: "ip"` UploadPort int `mapstructure: "uploadport"` VisitPort int `mapstructure: "visitport"` } var WeedFs = &weedfs{} // wp add es 索引 以及 IP port type esinfo struct { Masterip string `mapstructure:"masterip"` Httpport string `mapstructure:"httpport"` Shards string `mapstructure:"shards"` EsIndex esindexlist `mapstructure:"index"` } type esindexlist struct { VideoPersons index `mapstructure:"videopersons"` DbTables index `mapstructure:"dbtables"` 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{} // Init is an exported method that takes the environment starts the viper // (external lib) and returns the configuration struct. func Init(env string) { var err error viper.SetConfigType("yaml") viper.SetConfigName(env) viper.AddConfigPath("/opt/vasystem/config/") viper.AddConfigPath("") err = viper.ReadInConfig() if err != nil { log.Fatal("error on parsing configuration file") } viper.UnmarshalKey("es", EsInfo) viper.UnmarshalKey("weedfs", WeedFs) viper.UnmarshalKey("sopath",SoPath) //InitInsertEs() }