mirror of
https://github.com/woodchen-ink/Q58Bot.git
synced 2025-07-18 13:52:07 +08:00
添加时区
This commit is contained in:
parent
8775ac9b7c
commit
bb3a9c601c
@ -4,6 +4,9 @@ FROM alpine:latest
|
|||||||
# 安装 ca-certificates,通常需要用于 HTTPS
|
# 安装 ca-certificates,通常需要用于 HTTPS
|
||||||
RUN apk --no-cache add ca-certificates
|
RUN apk --no-cache add ca-certificates
|
||||||
|
|
||||||
|
# 设置时区
|
||||||
|
ENV TZ=Asia/Singapore
|
||||||
|
|
||||||
# 创建工作目录
|
# 创建工作目录
|
||||||
WORKDIR /root/
|
WORKDIR /root/
|
||||||
|
|
||||||
|
18
main.go
18
main.go
@ -17,6 +17,24 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
// 设置时区
|
||||||
|
setTimeZone()
|
||||||
|
|
||||||
|
// 其他初始化逻辑
|
||||||
|
initializeVariables()
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTimeZone() {
|
||||||
|
loc, err := time.LoadLocation("Asia/Singapore")
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error loading time zone 'Asia/Singapore': %v", err)
|
||||||
|
log.Println("Falling back to UTC")
|
||||||
|
loc = time.UTC
|
||||||
|
}
|
||||||
|
time.Local = loc
|
||||||
|
}
|
||||||
|
|
||||||
|
func initializeVariables() {
|
||||||
BOT_TOKEN = os.Getenv("BOT_TOKEN")
|
BOT_TOKEN = os.Getenv("BOT_TOKEN")
|
||||||
adminIDStr := os.Getenv("ADMIN_ID")
|
adminIDStr := os.Getenv("ADMIN_ID")
|
||||||
var err error
|
var err error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user