Golang time.Now () is always 2009-11-10 23:00:00 +0000 UTC

im running Go version 1.3 on windows 7x64, after running the following code I always get 2009-11-10 23:00:00 +0000 UTC

package main import ( "fmt" "time" ) func main() { fmt.Println(time.Now()) } 

I know that gog play has this fixed time for one reason, but I don’t understand why I get this date in my box

UPDATE: I realized this problem by updating the go version from 1.2.2 to 1.3

Trying to reproduce the problem, I realized that it was fixed after the shutdown and on the computer the next day.

I recommend restarting your computer after upgrading to version 1.3

+21
datetime time go
source share
3 answers

This time is the fixed time used in the Go Tour, as stated in the limitations of the Go Tour

On the playground, time starts at 2009-11-10 23:00:00 UTC (determining the syntax of this date is an exercise for the reader). This facilitates caching of programs, providing them with a deterministic result.

Are you sure the code is not running there? Perhaps the local version - you can download and run the tour.

+22
source share

I can not reproduce your problem:

 C:\gopath\src\timenow>go version go version go1.3 windows/amd64 C:\gopath\src\timenow>go env set GOARCH=amd64 set GOBIN=C:\go\bin set GOCHAR=6 set GOEXE=.exe set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOOS=windows set GOPATH=C:\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 set CXX=g++ set CGO_ENABLED=1 C:\gopath\src\timenow>type timenow.go package main import ( "fmt" "time" ) func main() { fmt.Println(time.Now()) } C:\gopath\src\timenow>go run timenow.go 2014-07-02 17:33:20.3270287 -0400 EDT C:\gopath\src\timenow>time The current time is: 17:33:23.60 Enter the new time: C:\gopath\src\timenow> 

What result do you get when you execute these commands?

+4
source share

This is the date and time of birth of Go Langs.

They use this as a fixed time on the Go Tour, so maybe you are starting a tour.

0
source share

All Articles