golang / tour

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

playground: time.Date() isn't real time #1567

Open tehtnaz opened 6 months ago

tehtnaz commented 6 months ago

I'm not quite sure whether to post this in here or not. I was using the playground and testing code and kept getting the wrong value.... after retesting... and rewriting the block... I printed time.Date() and found the time is statically set to 2009 :/

Really? This was terribly annoying to debug. And it shouldn't be my fault for not having seen the section in the Go tour which mentions it. I don't learn effectively with tutorials such as that, so I don't go through them.

I also understand that I'm a bit stupid for not scrolling down and checking "About the Playground" (I'll understand any "RTFM" comments).

But still, c'mon, this is an artificial limitation made for no reason (deterministic output should be achieved by declaring static values). It creates an unexpected output for new users, and anybody embedding the playground in their sites most likely won't be documenting this either, causing even more confusion.

Consider removing this "feature" from the playground.