Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time: LoadLocation: ZONEINFO variable without effect on Windows #14276

geoko86 opened this issue Feb 9, 2016 · 3 comments

time: LoadLocation: ZONEINFO variable without effect on Windows #14276

geoko86 opened this issue Feb 9, 2016 · 3 comments


Copy link

@geoko86 geoko86 commented Feb 9, 2016

When you try to execute time.LoadLocation() on Windows program panic unless it finds file in $GOROOT/lib/time/ Even with ZONEINFO environment variable set you get the same panic.

Test program can be found here:

Using golang 1.5.3 on Windows x86_64


  1. Take program from playground, and compile locally on windows. (Cross compiling will result in $GOROOT pointing to $GOROOT of the original Mac OS X machine)
  2. Compile with go build and execute. Output should be something like this:

Found zoneinfo env: false, location: '' .

  1. Copy from $GOROOT\lib\time\ to another location. E.g. C:\
  2. Set ZONEINFO environment variable to point to previously copied zoneinfo E.g. set ZONEINFO=C:\
  3. Move or delete your $GOROOT directory, so that it cannot be found anymore.
  4. Execute again

Expected output
Similar to output in step 2

Observed behavior
Program panics.

Found zoneinfo env: true, location: 'E:\' .
open C:\Go\lib\time\ The system cannot find the path specified.
panic: time: missing Location in call to Date

@geoko86 geoko86 changed the title time.LoadLocation: ZONEINFO variable without effect on Windows time: LoadLocation: ZONEINFO variable without effect on Windows Feb 9, 2016
@bradfitz bradfitz added this to the Unplanned milestone Feb 9, 2016
Copy link

@bradfitz bradfitz commented Feb 9, 2016

Copy link

@alexbrainman alexbrainman commented Feb 11, 2016

@geoko86 I tried to follow your instructions. But I cannot reproduce your problem.

C:\a>go version
go version go1.5.3 windows/386

C:\a>type main.go
package main

import (

func main() {
        zi, found := syscall.Getenv("ZONEINFO")
        fmt.Printf("Found zoneinfo env: %v, location: '%v' .\n", found, zi)

        str := getTimeString("Asia/Hong_Kong", time.Now())

func getTimeString(strLocation string, ts time.Time) string {
        const MyRFC3339 = "2006-01-02T15:04:05.0000Z07:00"

        var loc *time.Location
        loc, err := time.LoadLocation(strLocation)
        if err != nil {
                return ""

        return ts.In(loc).Format(MyRFC3339)

C:\a>copy %GOROOT%\lib\time\ c:\
        1 file(s) copied.

C:\a>set ZONEINFO=C:\

C:\a>go run main.go
Found zoneinfo env: true, location: 'C:\' .

C:\a>del %GOROOT%\lib\time\

C:\a>go run main.go
Found zoneinfo env: true, location: 'C:\' .


What did I do wrong?


Copy link

@geoko86 geoko86 commented Feb 11, 2016

@alexbrainman Thanks for checking.
It figured out what went wrong. I double checked the that i was using and it turned out, that the copy was incomplete, only 105kB vs some 352kB.

When I copied it again and pointed ZONEINFO to it, it works.

The error message was not completely clear to me, would have expected something along the line "found, but I cannot read it".

It is safe to close this as user error. :)

@golang golang locked and limited conversation to collaborators Feb 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.