add log config and gorm config

This commit is contained in:
landaiqing
2024-08-03 22:09:19 +08:00
parent 908a9d10f2
commit 3dac34d307
10 changed files with 232 additions and 31 deletions

26
core/config.go Normal file
View File

@@ -0,0 +1,26 @@
package core
import (
"fmt"
"gopkg.in/yaml.v3"
"log"
"os"
"schisandra-cloud-album/config"
"schisandra-cloud-album/global"
)
// InitConfig 初始化配置
func InitConfig() {
const ConfigFile = "config.yaml"
c := &config.Config{}
yamlCOnf, err := os.ReadFile(ConfigFile)
if err != nil {
panic(fmt.Errorf("get yaml config error: %s", err))
}
err = yaml.Unmarshal(yamlCOnf, c)
if err != nil {
log.Fatal("config init unmarshal error: ", err)
}
log.Println("config init success")
global.CONFIG = c
}