Skip to content

Instantly share code, notes, and snippets.

@lisa
Created September 13, 2017 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lisa/7620c8cd47a428b911aa8f2ad9b1a512 to your computer and use it in GitHub Desktop.
Save lisa/7620c8cd47a428b911aa8f2ad9b1a512 to your computer and use it in GitHub Desktop.
settimeofday.go
package main
import (
"fmt"
"syscall"
"time"
)
func main() {
t := time.Now()
fmt.Println("Current time: ", t)
sec := t.Unix()
usec := t.UnixNano()
fmt.Println(sec, usec)
tv := syscall.Timeval{sec, usec}
}
// Line 15 fails with:
// # command-line-arguments
// set_time.go:15: cannot use usec (type int64) as type int32 in field value
// set_time.go:15: too few values in struct initializer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment