Last active
December 19, 2015 09:59
-
-
Save tmc/5937579 to your computer and use it in GitHub Desktop.
This file contains 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
// parses arguments into a time duration and prints the number of seconds it represents | |
package main | |
import ( | |
"fmt" | |
"os" | |
"strings" | |
"time" | |
) | |
func main() { | |
d, err := time.ParseDuration(strings.Join(os.Args[1:], "")) | |
if err != nil { | |
fmt.Fprintln(os.Stderr, "error parsing duration:", err) | |
os.Exit(1) | |
} | |
fmt.Println(d.Seconds()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment