-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Hi,
On Windows, timezone calculations require presence of zoneinfo.zip file, which is found via the ZONEINFO environment variable. But in my situation, I am unable to set env vars, and it's not possible to re-set ZONEINFO after Go execution has already begun.
Would it be possible to add a method to time package to allow re-loading ZONEINFO from a custom path?
I tried os.Setenv() in main.init(), but, it had no effect, as below.
Right now i can only perform a workaround relaunching the binary with different environment.
Thanks
What version of Go are you using (go version)?
go version go1.7.3 windows/amd64
What operating system and processor architecture are you using (go env)?
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\cygwin\tmp\go-build715340254=/tmp/go-build -gno-record-gcc-switches
set CXX=g++
set CGO_ENABLED=1
What did you do?
package main
import (
"fmt"
"time"
"os"
)
func init() {
os.Setenv("ZONEINFO", `C:\valid\path\to\zoneinfo.zip`)
}
func main() {
loc, err := time.LoadLocation("Europe/London")
fmt.Printf("%v %v\n", loc, err)
}
What did you expect to see?
Europe/London <nil>
What did you see instead?
UTC open C:\Go\\lib\time\zoneinfo.zip: The system cannot find the file specified.