I'm trying to modify golang timezone for my application
I have took a look at time package, initializing timezone happens in
time/zoneinfo_unix.go @ initLocal
The function simply tries to read environment variable TZ
and if it's valid it loads it
and if it's not it falls back /etc/localtime
and if it's not valid it falls back to UTC
what i have tried so far
1- works fine -But i don't want to use either of those approaches - :
- in my docker file i pass an ENV to the container,
TZ = Africa/Cairo
- getting into the container bash, running
$ export TZ = Africa/Cairo
2- Didn't work
- in my app initialization (the app initialization is in a separate package that is being imported in the main), i use os.SetEnv("TZ", "Africa/Cairo")
When i simplify the main and use os.SetEnv("TZ", "Africa/Cairo") without importing any other packages other than "os - time" it works as expected
Any ideas about how to make the second approache work ?
Docker image: golang:1.11.2