golang<1.20版本的time包 time.LoadLocation(timezone)
读取某些时区会报错,升级到1.20可以解决
顺便,某些开发把error直接置为_隐藏掉的习惯真的差评
func Test3(t *testing.T) {timezone := "America/Ciudad_Juarez"timezone = "Europe/Kyiv"loc, err := time.LoadLocation(timezone)if err != nil {fmt.Println(err)return}timeObj := time.Unix(1686458071, 289000000)fmt.Println(loc)timeInLocation := timeObj.In(loc)timeString := timeInLocation.Format("15:04")fmt.Println(timeString)
}
=== RUN Test3
unknown time zone Europe/Kyiv
--- PASS: Test3 (0.01s)
PASS