golang / tour

[mirror] A Tour of Go
BSD 3-Clause "New" or "Revised" License
1.55k stars 519 forks source link

tour: stop using time.Now() in flowcontrol/switch example #91

Open ovkrylov opened 8 years ago

ovkrylov commented 8 years ago

Context: http://127.0.0.1:3999/flowcontrol/10

It is Friday. And if I change code to

switch time.Sunday { ... }

it returns "Too far away." ... but correct answer is "In two days."

bgadrian commented 6 years ago

The time is fixed on go tour, see the note

Note: Time in the Go playground always appears to start at 2009-11-10 23:00:00 UTC, a value whose significance is left as an exercise for the reader.

ALTree commented 6 years ago

The explanation it's not very clear. It says:

Time in the Go playground always appears to start at 2009-11-10 23:00:00 UTC

It's not obvious what "appears to start at" means in this context. It would be easier to just say that time.Now() always returns 2009-11-10 23:00:00 UTC on the playground, and for this reason the current day it's always Tuesday.

Also I think the code example in that page is a bad choice. We're just talking about the switch statement, why complicate the matter throwing in a code snippet about time, which is fixed on the playground? It'll confuse people for no reason.