重构(main.go & binance.go): 移除对time.LoadLocation的使用,优化时区设置,增强代码健壮性。

This commit is contained in:
wood chen 2024-09-18 01:56:23 +08:00
parent bb3a9c601c
commit d7407628b3
2 changed files with 1 additions and 10 deletions

View File

@ -25,12 +25,7 @@ func init() {
}
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
}
loc := time.FixedZone("Asia/Singapore", 8*60*60)
time.Local = loc
}

View File

@ -27,10 +27,6 @@ func init() {
botToken = os.Getenv("BOT_TOKEN")
chatID = mustParseInt64(os.Getenv("CHAT_ID"))
symbols = strings.Split(os.Getenv("SYMBOLS"), ",")
singaporeTZ, err = time.LoadLocation("Asia/Singapore")
if err != nil {
log.Fatal(err)
}
bot, err = tgbotapi.NewBotAPI(botToken)
if err != nil {