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
+46.5k Golang : Marshal and unmarshal json.RawMessage struct example
+21.1k Golang : Sort and reverse sort a slice of strings
+18.8k Golang : Implement getters and setters
+10.9k Golang : Removes punctuation or defined delimiter from the user's input
+5.4k Golang : Intercept, inject and replay HTTP traffics from web server
+4k Detect if Google Analytics and Developer Media are loaded properly or not
+36.5k Golang : Save image to PNG, JPEG or GIF format.
+7.7k Golang : Mapping Iban to Dunging alphabets
+16.7k Golang : Gzip file example
+24.6k Golang : How to validate URL the right way
+11.7k Golang : Gorilla web tool kit secure cookie example
+16.5k Golang : File path independent of Operating System