Golang flag.FlagSet.IntVar() function example
package flag
IntVar defines an int flag with specified name(2nd parameter), default value(3rd parameter), and usage string(4th parameter). The argument p(1st parameter) points to an int variable in which to store the value of the flag.
Golang flag.FlagSet.IntVar() function usage example
package main
import (
"flag"
"fmt"
)
func main() {
flagSet := flag.NewFlagSet("check", flag.ExitOnError)
var p int
flagSet.IntVar(&p, "diskchecktimeout", 1, "Disk check process time out. Default is 1 hour.")
flag.Parse()
fmt.Println(p)
}
Reference :
Advertisement
Something interesting
Tutorials
+14.8k Golang : Find commonalities in two slices or arrays example
+12k Golang : Convert a rune to unicode style string \u
+13.6k Android Studio : Password input and reveal password example
+13.4k Golang : Generate Code128 barcode
+17.1k Golang : Capture stdout of a child process and act according to the result
+10.2k Golang : How to profile or log time spend on execution?
+7.3k Golang : How to iterate a slice without using for loop?
+21.1k Golang : For loop continue,break and range
+7.4k Golang : Word limiter example
+38.1k Golang : Read a text file and replace certain words
+21.2k Golang : How to get time zone and load different time zone?
+13.3k Golang : Date and Time formatting