pkg/config/base.go

36 lines
652 B
Go
Raw Normal View History

2023-04-09 15:14:24 +00:00
package config
import (
"time"
)
const (
// DevEnv
DevEnv = "dev"
// ProdEnv
ProdEnv = "prod"
)
// BaseConf
type BaseConf struct {
AppCode string `yaml:"app_code"`
AppSecret string `yaml:"app_secret"`
TimeZone string `yaml:"time_zone"`
LanguageCode string `yaml:"language_code"`
RunEnv string `yaml:"run_env"`
Location *time.Location `yaml:"-"`
}
// Init
func (c *BaseConf) Init() error {
var err error
c.TimeZone = "Asia/Shanghai"
c.LanguageCode = "en-us"
c.RunEnv = DevEnv
c.Location, err = time.LoadLocation(c.TimeZone)
if err != nil {
return err
}
return nil
}