Skip to content

Instantly share code, notes, and snippets.

@r2p2
Created October 6, 2012 16:14
Show Gist options
  • Select an option

  • Save r2p2/3845344 to your computer and use it in GitHub Desktop.

Select an option

Save r2p2/3845344 to your computer and use it in GitHub Desktop.
gotp cmd
package main
import (
"flag"
"fmt"
"github.com/r2p2/rfc868"
)
var daemon = flag.Bool("daemon", false, "run application as daemon. share your time.")
var address = flag.String("address", "localhost:1024", "connect/listen to/on address.")
var dry = flag.Bool("dry", false, "on dry run time won't be updates. atm every run is a dry run.")
func main() {
flag.Parse()
if *daemon == true {
err := rfc868.ServeTime(*address)
if err != nil {
fmt.Println("error: " + err.Error())
return
}
} else {
c, err := rfc868.NewClient(*address)
if err != nil {
fmt.Println(err.Error())
return
}
time, err := c.RequestTime()
if err != nil {
fmt.Println("error: " + err.Error())
return
}
fmt.Println(time)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment