Is there a reasonable way to get time.Now() to always return the time in UTC regardless of the configured time zone of the host on which I’m running?
If that’s not possible the alternatives I can think of are:
just remember to call UTC() when getting a time
figure out what platform the dependent way is to change the time zone before initLocal runs – which seems trivial on linuxy environments (TZ environment variable) and looks to require changing the system TZ on Windows.
Anyway, neither of those is particularly nice so I was hoping I missed something?
That said, why did you need to force the time zone to UTC? A time.Time should work the same everywhere regardless of the time zone so this should only be relevant when printing a time - at which point following the user preferences seem preferable?
For special things like HTTP header fields that must be in UTC, calling .UTC() at that point seems appropriate.