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
+8.2k Golang : Add build version and other information in executables
+8.8k Golang : Random integer with rand.Seed() within a given range
+7.8k Swift : Convert (cast) String to Double
+15.9k Golang : Update database with GORM example
+4.6k Linux : sudo yum updates not working
+13.9k Golang : Get dimension(width and height) of image file
+5.2k Golang : Customize scanner.Scanner to treat dash as part of identifier
+34k Golang : Proper way to set function argument default value
+22.1k Golang : Repeat a character by multiple of x factor
+7.3k Golang : Calculate how many weeks left to go in a given year
+36.3k Golang : How to split or chunking a file to smaller pieces?