github.com/hamba/timex@v1.2.1-0.20240304044353-56d3de3a9ed9/time_now.go (about) 1 //go:build !go1.17 2 // +build !go1.17 3 4 package timex 5 6 import _ "unsafe" // for go:linkname 7 8 //go:linkname walltime runtime.walltime 9 func walltime() (int64, int32) 10 11 // Now returns the current time in nanoseconds. 12 func Now() int64 { 13 sec, nsec := walltime() 14 return sec*1000000000 + int64(nsec) 15 } 16 17 // Unix returns the current time in seconds. 18 func Unix() int64 { 19 sec, _ := walltime() 20 return sec 21 }