48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
// Code generated by minotaur-config-export. DO NOT EDIT.
|
|
package configs
|
|
import (
|
|
jsonIter "github.com/json-iterator/go"
|
|
"github.com/kercylan98/minotaur/utils/log"
|
|
"go.uber.org/zap"
|
|
"os"
|
|
)
|
|
|
|
var json = jsonIter.ConfigCompatibleWithStandardLibrary
|
|
var (
|
|
ISystemConfig *SystemConfig
|
|
iSystemConfig *SystemConfig
|
|
IWelcomeConfig map[int]*WelcomeConfig
|
|
iWelcomeConfig map[int]*WelcomeConfig
|
|
)
|
|
|
|
func LoadConfig(handle func(filename string, config any) error) {
|
|
var err error
|
|
iSystemConfig = new(SystemConfig)
|
|
if err = handle("SystemConfig.json", iSystemConfig); err != nil {
|
|
log.Error("Config", zap.String("Name", "SystemConfig"), zap.Bool("Invalid", true), zap.Error(err))
|
|
}
|
|
|
|
iWelcomeConfig = make(map[int]*WelcomeConfig)
|
|
if err = handle("WelcomeConfig.json", &iWelcomeConfig); err != nil {
|
|
log.Error("Config", zap.String("Name", "WelcomeConfig"), zap.Bool("Invalid", true), zap.Error(err))
|
|
}
|
|
|
|
}
|
|
|
|
func Refresh() {
|
|
ISystemConfig = iSystemConfig
|
|
IWelcomeConfig = iWelcomeConfig
|
|
}
|
|
|
|
func DefaultLoad(filepath string) {
|
|
LoadConfig(func(filename string, config any) error {
|
|
bytes, err := os.ReadFile(filepath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return json.Unmarshal(bytes, &config)
|
|
})
|
|
}
|
|
|