mirror of
https://github.com/xiaoqidun/gocos.git
synced 2024-11-21 22:16:45 +08:00
feat(时区设置): 默认北京时区,支持TZ环境变量
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
f58a05391e
commit
379e65dafc
9
gocos.go
9
gocos.go
@ -11,6 +11,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
_ "time/tzdata"
|
_ "time/tzdata"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -54,6 +55,14 @@ func VarIsEmpty(a ...interface{}) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
tz := os.Getenv("TZ")
|
||||||
|
if tz == "" {
|
||||||
|
tz = "Asia/Shanghai"
|
||||||
|
}
|
||||||
|
time.Local, _ = time.LoadLocation(tz)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user