Created
October 6, 2012 16:14
-
-
Save r2p2/3845344 to your computer and use it in GitHub Desktop.
gotp cmd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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