use yml
This commit is contained in:
@@ -72,7 +72,7 @@ func SetUp1() {
|
||||
// 设置配置文件的名称(不包括扩展名)
|
||||
viper.SetConfigName("config")
|
||||
// 设置配置文件所在的目录
|
||||
viper.AddConfigPath(".")
|
||||
viper.AddConfigPath("./conf")
|
||||
// 设置配置文件的类型为YAML
|
||||
viper.SetConfigType("yaml")
|
||||
|
||||
@@ -86,8 +86,10 @@ func SetUp1() {
|
||||
jwtSecretKey := viper.GetString("jwt.SecretKey")
|
||||
serverPort := viper.GetInt("server.Port")
|
||||
|
||||
templateGlob := viper.GetString("project.TemplateGlob")
|
||||
// 打印获取到的配置值
|
||||
fmt.Printf("MySQL Host: %s\n", mysqlHost)
|
||||
fmt.Printf("JWT Secret Key: %s\n", jwtSecretKey)
|
||||
fmt.Printf("Server Port: %d\n", serverPort)
|
||||
fmt.Printf("TemplateGlob: %s\n", templateGlob)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user