create config

This commit is contained in:
2023-04-07 03:44:59 +08:00
parent d4262026d3
commit b20e864b37
2 changed files with 15 additions and 2 deletions

View File

@@ -14,7 +14,21 @@ func init() {
viper.AddConfigPath("./data") // 设置配置文件所在的路径
if err := viper.ReadInConfig(); err != nil {
log.Println("读取配置文件失败", err)
panic(err)
生成配置文件()
}
Viper = viper.GetViper()
}
func 生成配置文件() {
viper.Set("mysql.host", "")
viper.Set("mysql.port", 3306)
viper.Set("mysql.user", "")
viper.Set("mysql.password", "")
viper.Set("mysql.dbname", "")
viper.Set("mysql.charset", "utf8mb4")
viper.Set("mysql.maxOpenConns", 100)
viper.Set("oss.host", "")
viper.Set("oss.accessKeyId", "")
viper.Set("oss.accessKeySecret", "")
}