Now i have cross compile the golang for ARM v7. And I found the time in golang is 8 hour later than linux system on arm.
When I use “date” commad, the result is below, which is right
root@TinaLinux:/# date
Tue Jul 25 12:24:57 CST 2017
But in golang program, the result is below:
Code:
a := time.Now()
fmt.Println(a)
Result:
2017-07-25 04:17:35.689998326 +0000 UTC
I think maybe golang can’t get the correct timezone information from my linux system on ARM v7.
Does everyone know how the mechanism for golang getting timezone information from linux system?
If this still prints UTC, I would guess that Go reads the kernel’s timezone (which appears to be UTC in this case), whereas date uses the current user’s timezone.
If it were a timezone-issue, it should result in a full hour shift, I believe. But you have a fuzzy deviation of 8 hours, 7 minutes and some seconds. Perhaps it is a matter of the missing realtime clock in the raspberry Pi? I would try to fix it on OS-Level by installing the “fake-hwclock”-package for example.
It is my mistake .i haven’t executed the go program and shell command at the same time. I just put the go result and shell result here for 8 hours different information only.