From 4579712dbef6eeb940a9e26409dab745313b5e8a Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期五, 31 七月 2020 14:41:53 +0800 Subject: [PATCH] use yuying env --- extend/config/config.go | 70 +++++++++++++++++----------------- 1 files changed, 35 insertions(+), 35 deletions(-) diff --git a/extend/config/config.go b/extend/config/config.go index 54b3bf9..bd52bb4 100644 --- a/extend/config/config.go +++ b/extend/config/config.go @@ -1,37 +1,37 @@ package config -import ( - "github.com/spf13/viper" - "log" -) - -type server []ServerInfo - -type ServerInfo struct { - ServerId string `mapstructure: "serverId"` - ServerIp string `mapstructure: "serverIp"` - VideoPort string `mapstructure: "videoPort"` - NgxIp string `mapstructure: "ngxIp"` - NgxPort string `mapstructure: "ngxPort"` -} - -var serverList = &server{} - -var ServerMap = make(map[string]string,0) -var NgxMap = make(map[string]string,0) -func Init(env string, configPath string) { - var err error - viper.SetConfigType("yaml") - viper.SetConfigName(env) - viper.AddConfigPath(configPath) - err = viper.ReadInConfig() - if err != nil { - log.Fatal("error on parsing configuration file",err) - } - viper.UnmarshalKey("server", serverList) - for _,s :=range *serverList { - si := s - ServerMap[si.ServerId] = "http://"+si.ServerIp+":"+si.VideoPort+"/getRecordVideoPath" - NgxMap[si.ServerId] = "http://"+si.NgxIp+":"+si.NgxPort+"/videosource" - } -} \ No newline at end of file +//import ( +// "github.com/spf13/viper" +// "log" +//) +// +//type server []ServerInfo +// +//type ServerInfo struct { +// ServerId string `mapstructure: "serverId"` +// ServerIp string `mapstructure: "serverIp"` +// VideoPort string `mapstructure: "videoPort"` +// NgxIp string `mapstructure: "ngxIp"` +// NgxPort string `mapstructure: "ngxPort"` +//} +// +//var serverList = &server{} +// +//var ServerMap = make(map[string]string,0) +//var NgxMap = make(map[string]string,0) +//func Init(env string, configPath string) { +// var err error +// viper.SetConfigType("yaml") +// viper.SetConfigName(env) +// viper.AddConfigPath(configPath) +// err = viper.ReadInConfig() +// if err != nil { +// log.Fatal("error on parsing configuration file",err) +// } +// viper.UnmarshalKey("server", serverList) +// for _,s :=range *serverList { +// si := s +// ServerMap[si.ServerId] = "http://"+si.ServerIp+":"+si.VideoPort+"/getRecordVideoPath" +// NgxMap[si.ServerId] = "http://"+si.NgxIp+":"+si.NgxPort+"/videosource" +// } +//} \ No newline at end of file -- Gitblit v1.8.0