From e12bca22ef82aa5a2df0448a4715b1a948604156 Mon Sep 17 00:00:00 2001 From: sunty <1172534965@qq.com> Date: 星期二, 07 四月 2020 14:57:38 +0800 Subject: [PATCH] first commit --- config/config.go | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-) diff --git a/config/config.go b/config/config.go new file mode 100644 index 0000000..6fdffad --- /dev/null +++ b/config/config.go @@ -0,0 +1,34 @@ +package config + +import ( + "github.com/spf13/viper" + "log" +) + +type server struct { + EsServerIp string `mapstructure: "esServerIp"` + EsServerPort string `mapstructure: "esServerPort"` +} + +type elastic struct { + IndexName string `mapstructure: "indexName"` + IndexType string `mapstructure: "indexType"` +} + +var Server = &server{} +var BasicFS = &elastic{} + +func Init(env string) { + var err error + viper.SetConfigType("yaml") + viper.SetConfigName(env) + viper.AddConfigPath("/opt/vasystem/config") + err = viper.ReadInConfig() + if err != nil { + log.Fatal("error on parsing configuration file", err) + } + viper.UnmarshalKey("server", Server) + viper.UnmarshalKey("elastic.basicFS", BasicFS) + //fmt.Println(AiOcean) + //fmt.Println(BasicFS) +} -- Gitblit v1.8.0