This is a creation in Article, where the information may have evolved or changed.
Premise
1. Docker image (or similar environment)
2, the Go application uses theloc, _ := time.LoadLocation("Asia/Chongqing")
Problem
$ go run ./xxxpanic: time:missing Location in call to Time.In
Reason
The location information for the time is extracted from the local file system, which is supported by most systems, but still depends on the current system. Specific Configuration Storage path:
$ cd /usr/share/zoneinfo
Enter the directory to see the configuration information for each time zone
$ ls+VERSION Australia EET Factory Greenwich Jamaica Mexico Poland US posixrulesAfrica Brazil EST GB HST Japan NZ Portugal UTC zone.tabAmerica CET EST5EDT GB-Eire Hongkong Kwajalein NZ-CHAT ROC UniversalAntarctica CST6CDT Egypt GMT Iceland Libya Navajo ROK W-SUArctic Canada Eire GMT+0 Indian MET PRC Singapore WETAsia Chile Etc GMT-0 Iran MST PST8PDT Turkey ZuluAtlantic Cuba Europe GMT0 Israel MST7MDT Pacific UCT iso3166.tab
However, these time zone profiles do not exist in an empty image (or similar scenario), and this error occurs when the program is referenced.
(accurately, this problem occurs because the local system does not exist Asia/Chongqing
for a time zone profile)
Solve
Installation
$ apk add --no-cache tzdata
After the package is installed, /usr/share/zoneinfo
configuration information for each time zone is generated under the directory
Note that if you do not have a timezone, locatime configuration, you need to manually handle
At last
Do you know what Tzdata is? In short, it's a time zone database (as files and modules)
The purpose of this package is to distribute the standard Time zone database in the Cabal package so that it can be used uniformly for Haskell programs on all platforms.