From 50e8b97a00611cda95ff3e33fa57a2781f2e8162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=A5=E7=BE=8A?= Date: Mon, 26 Jun 2023 11:28:57 +0800 Subject: [PATCH] fix time bug --- Golang/main.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Golang/main.go b/Golang/main.go index 1128083..8b8fde0 100644 --- a/Golang/main.go +++ b/Golang/main.go @@ -32,8 +32,11 @@ func duanyan(adurl string, realurl any) string { } func getTestVideoUrl(c *gin.Context) { - TimeLocation, _ := time.LoadLocation("Asia/Shanghai") - str_time := time.Now().In(TimeLocation).Format("2006-01-02 15:04:05") + TimeLocation, err := time.LoadLocation("Asia/Shanghai") + if err != nil { + TimeLocation = time.FixedZone("CST", 8*60*60) + } + str_time := time.Now().In(TimeLocation).Format("2006-01-02 15:04:05") fmt.Fprintln(c.Writer, "#EXTM3U") fmt.Fprintln(c.Writer, "#EXTINF:-1 tvg-name=\""+str_time+"\" tvg-logo=\"https://cdn.jsdelivr.net/gh/youshandefeiyang/IPTV/logo/tg.jpg\" group-title=\"列表更新时间\","+str_time) fmt.Fprintln(c.Writer, "https://cdn.jsdelivr.net/gh/youshandefeiyang/testvideo/time/time.mp4") @@ -53,14 +56,14 @@ func setupRouter(adurl string) *gin.Engine { gin.SetMode(gin.ReleaseMode) r := gin.Default() - r.HEAD("/", func(c *gin.Context) { - c.String(http.StatusOK,"请求成功!") + r.HEAD("/", func(c *gin.Context) { + c.String(http.StatusOK, "请求成功!") }) - r.GET("/", func(c *gin.Context) { - c.String(http.StatusOK,"请求成功!") + r.GET("/", func(c *gin.Context) { + c.String(http.StatusOK, "请求成功!") }) - + r.GET("/douyin", func(c *gin.Context) { vrurl := c.Query("url") douyinobj := &liveurls.Douyin{}