This repository has been archived on 2024-11-28. You can view files and clone it, but cannot push or open issues or pull requests.
Files
schisandra-cloud-album/core/config.go
landaiqing f4b69b5d31 🎨 set up routes
2024-08-04 13:11:54 +08:00

26 lines
481 B
Go

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)
}
global.CONFIG = c
}