| 12345678910111213141516171819202122232425262728293031 |
- // package app 应用信息包
- package app
- import (
- "time"
- "github.com/runningwater/gohub/pkg/config"
- )
- func IsLocal() bool {
- // 判断是否是本地环境
- return config.Get("app.env") == "local"
- }
- func IsProduction() bool {
- return config.Get("app.env") == "production"
- }
- func IsTesting() bool {
- return config.Get("app.env") == "testing"
- }
- // TimenowInTimezone 获取当前时间, 支持时区
- func TimenowInTimezone() time.Time {
- timezone := config.GetString("app.timezone")
- if timezone == "" {
- timezone = "Asia/Shanghai"
- }
- chinaTimeZone, _ := time.LoadLocation(timezone)
- return time.Now().In(chinaTimeZone)
- }
|