go: time: misleading "zoneinfo.zip: no such file or directory" error when trying to load non-existent timezone
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version
)?
go version devel +be855e3f28 Mon Jun 19 23:26:32 2017 +0000 linux/amd64
What operating system and processor architecture are you using (go env
)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/dieter/go"
GORACE=""
GOROOT="/home/dieter/code/go"
GOTOOLDIR="/home/dieter/code/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -fmessage-length=0 -fdebug-prefix-map=/tmp/dieter/go-build409613068=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="0"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
What did you do?
> cat main.go
package main
import (
"fmt"
"time"
)
func main() {
tz, err := time.LoadLocation("America/New_York")
fmt.Printf("New_York %q %q\n", tz, err)
tz, err = time.LoadLocation("America/New_Yaark")
fmt.Printf("New_Yaark %q %q\n", tz, err)
}
> cat Dockerfile
FROM alpine
RUN apk add -U tzdata
COPY main /usr/bin/
ENTRYPOINT ["/usr/bin/main"]
go build -o main
docker build .
docker run ea1f31431e4d
What did you expect to see?
New_York "America/New_York" %!q(<nil>)
New_Yaark "UTC" "can't find timezone America/New_Yaark or something"
What did you see instead?
New_York "America/New_York" %!q(<nil>)
New_Yaark "UTC" "open /home/dieter/code/go/lib/time/zoneinfo.zip: no such file or directory"
note that when I run it on my host which does have a zoneinfo.zip I get:
go run main.go
New_York "America/New_York" %!q(<nil>)
New_Yaark "UTC" "cannot find America/New_Yaark in zip file /home/dieter/code/go/lib/time/zoneinfo.zip"
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 17 (9 by maintainers)
Commits related to this issue
- time: return ENOENT from androidLoadTzinfoFromTzdata if zone not found This makes Android consistent with the change in CL 121877. Updates #20969 Change-Id: I1f114556fd1d4654c8e4e6a59513bddd5dc3d1a... — committed to golang/go by ianlancetaylor 6 years ago
- time: return ENOENT if a zoneinfo zip file is not found Updates #20969 Change-Id: Ibcf0bf932d5b1de67c22c63dd8514ed7a5d198fb Reviewed-on: https://go-review.googlesource.com/c/155538 Run-TryBot: Ian L... — committed to golang/go by ushakov 6 years ago
@pagidi This issue was closed months ago. For help with Go, please see https://golang.org/wiki/Questions.
On Ubuntu timezone information comes from files in the /usr/share/zoneinfo directory. So if a timezone works on one system but not another, it means that the two systems have different zoneinfo files.