mysql
This commit is contained in:
20
models/config.go
Normal file
20
models/config.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var Viper *viper.Viper
|
||||
|
||||
func init() {
|
||||
viper.SetConfigName("config") // 设置配置文件的名字
|
||||
viper.SetConfigType("yaml") // 设置配置文件的格式
|
||||
viper.AddConfigPath("./data") // 设置配置文件所在的路径
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
log.Println("读取配置文件失败", err)
|
||||
panic(err)
|
||||
}
|
||||
Viper = viper.GetViper()
|
||||
}
|
Reference in New Issue
Block a user