remove number for source

This commit is contained in:
Mark McGranaghan
2012-10-07 02:00:54 -04:00
parent beaad143c4
commit 2c4dea2b8e
134 changed files with 0 additions and 0 deletions

23
src/epochs/epochs.go Normal file
View File

@@ -0,0 +1,23 @@
// ## Epochs
// A common requirement in programms is getting the number
// of seconds, milliseconds, or nanoseconds since the Unix
// epoch. Here's how to do it in Go.
package main
import "time"
func main() {
// Use `time.Now` with `Unix` or `UnixNano` to get
// elapsed time since the Unix epoch.
now := time.Now()
secs := now.Unix()
nanos := now.UnixNano()
// Note that there is no `UnixMillis`.
millis := nanos / 1000000
println("Secs: ", secs)
println("Millis:", millis)
println("Nanos: ", nanos)
}

4
src/epochs/epochs.sh Normal file
View File

@@ -0,0 +1,4 @@
$ go run epochs.go
Secs: 1348240948
Millis: 1348240948517
Nanos: 1348240948517870000