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
+20.3k Swift : Convert (cast) Int to int32 or Uint32
+6k Golang : Experimenting with the Rejang script
+6.9k Nginx : Password protect a directory/folder
+10.3k Golang : Convert file unix timestamp to UTC time example
+8.6k Golang : Convert(cast) []byte to io.Reader type
+8.3k Golang : Implementing class(object-oriented programming style)
+12.3k Golang : Validate email address
+7.4k Golang : Hue, Saturation and Value(HSV) with OpenCV example
+26.9k Golang : Force your program to run with root permissions
+10.3k Golang : Embed secret text string into binary(executable) file
+8.3k Golang : Check if integer is power of four example
+19.2k Golang : Delete item from slice based on index/key position