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 Golang : Check if os.Stdin input data is piped or from terminal
+5.6k Swift : Get substring with rangeOfString() function example
+9.2k nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
+16.3k Golang : Find out mime type from bytes in buffer
+21.5k Golang : How to read float value from standard input ?
+5.9k Golang : Use NLP to get sentences for each paragraph example
+5.5k Clean up Visual Studio For Mac installation failed disk full problem
+9.2k Golang : How to check if a string with spaces in between is numeric?
+12.3k Golang : Validate email address
+16.4k Golang : How to implement two-factor authentication?
+16.4k Golang : Test floating point numbers not-a-number and infinite example
+6.2k Golang : Get missing location after unmarshal binary and gob decode time.