30 lines
566 B
Go
30 lines
566 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")
|
||
|
}
|
||
|
|
||
|
}
|