pkg/config/base.go

36 lines
652 B
Go

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
}