2024-12-17 22:28:48 +08:00

34 lines
623 B
Go

package lightCore
import "code.zhecent.com/gopkg/light-core/pkg/myViper"
type Start struct {
config *Config
}
func NewByConfig(config *Config) *Start {
return &Start{config: config}
}
func NewByYAML(fileName string, path string) *Start {
c := &Config{}
myViper.NewSimpleViper(c, "yaml", fileName, path).Apply()
return &Start{config: c}
}
func (t *Start) Start() {
//校验配置
if t.config.App.JwtSecret == "" {
panic("App JwtSecret Empty")
}
if t.config.Server.RunMode == "" || t.config.Server.HttpPort == 0 {
panic("Server Config Error")
}
ConfigValue = t.config
//初始化数据库
InitDB()
}