package main
import ( "fmt"; "time" )
func main() {
then := time.Seconds()
time.Sleep(2)
now := time.Seconds()
fmt.Println(then, now)
}
on the playground always gives this: 1257894000 1257894000
I suspect this is on purpose, to make Playground useless for
benchmarking, but it might be nice if your hacked time.Seconds()
printed a warning, or paniced or something instead of blatantly lying.
Thanks for a classic (one might even say, "timeless") toy. :)
-jeff
The time is fixed so that any given program's execution is
deterministic. This means we can cache the result of any program and
the cache will always be correct.
Andrew
To give a pseudo-time you could make the first value be a nice big number
and subsequent values increment by 1. Still deterministic but programs
can pretend to make progress against the clock.
Chris
--
Chris "allusive" Dollin
Yes, that was an important moment for Go.
Russ