This commit is contained in:
2024-08-01 02:44:06 +08:00
parent 1860e3666d
commit a8891902c6
11 changed files with 121 additions and 57 deletions

View File

@@ -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)
}