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
2024-08-03 22:09:19 +08:00

27 lines
517 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)
}
log.Println("config init success")
global.CONFIG = c
}