Browse Source

feat(时区设置): 默认北京时区,支持TZ环境变量

main
xiaoqidun 4 weeks ago
parent
commit
379e65dafc
1 changed files with 9 additions and 0 deletions
  1. 9
      gocos.go

9
gocos.go

@ -11,6 +11,7 @@ import (
"os"
"path/filepath"
"strings"
"time"
_ "time/tzdata"
)
@ -54,6 +55,14 @@ func VarIsEmpty(a ...interface{}) bool {
return false
}
func init() {
tz := os.Getenv("TZ")
if tz == "" {
tz = "Asia/Shanghai"
}
time.Local, _ = time.LoadLocation(tz)
}
func main() {
var (
err error

Loading…
Cancel
Save