Golang flag.FlagSet.Duration() function example
package flag
Duration defines a time.Duration flag with specified name(1st parameter), default value(2nd parameter), and usage string(3rd parameter). The return value is the address of a time.Duration variable that stores the value of the flag.
Golang flag.FlagSet.Duration() function usage example
package main
import (
"flag"
"fmt"
"time"
)
func main() {
flagSet := flag.NewFlagSet("check", flag.ExitOnError)
syncTimeout := flagSet.Duration("sync-timeout", 2*time.Second, "Duration of time for sync process to time out")
flag.Parse()
fmt.Println(syncTimeout)
}
Output :
2s
Reference :
Advertisement
Something interesting
Tutorials
+9.8k Golang : Qt get screen resolution and display on center example
+28k Golang : Move file to another directory
+5.4k Golang *File points to a file or directory ?
+6.2k Golang : Get missing location after unmarshal binary and gob decode time.
+5.6k Python : Print unicode escape characters and string
+36.7k Golang : Display float in 2 decimal points and rounding up or down
+11.6k Golang : Simple file scaning and remove virus example
+5.2k Responsive Google Adsense
+6.8k Golang : Join lines with certain suffix symbol example
+9.6k Golang : Validate IPv6 example
+8.2k Golang : Reverse text lines or flip line order example
+8.2k Android Studio : Rating bar example