mirror of
https://github.com/woodchen-ink/Q58Bot.git
synced 2025-07-18 13:52:07 +08:00
重构(main.go & binance.go): 移除对time.LoadLocation的使用,优化时区设置,增强代码健壮性。
This commit is contained in:
parent
bb3a9c601c
commit
d7407628b3
7
main.go
7
main.go
@ -25,12 +25,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setTimeZone() {
|
func setTimeZone() {
|
||||||
loc, err := time.LoadLocation("Asia/Singapore")
|
loc := time.FixedZone("Asia/Singapore", 8*60*60)
|
||||||
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
|
time.Local = loc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,10 +27,6 @@ func init() {
|
|||||||
botToken = os.Getenv("BOT_TOKEN")
|
botToken = os.Getenv("BOT_TOKEN")
|
||||||
chatID = mustParseInt64(os.Getenv("CHAT_ID"))
|
chatID = mustParseInt64(os.Getenv("CHAT_ID"))
|
||||||
symbols = strings.Split(os.Getenv("SYMBOLS"), ",")
|
symbols = strings.Split(os.Getenv("SYMBOLS"), ",")
|
||||||
singaporeTZ, err = time.LoadLocation("Asia/Singapore")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
bot, err = tgbotapi.NewBotAPI(botToken)
|
bot, err = tgbotapi.NewBotAPI(botToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user