Golang flag.FlagSet.Int() function example
package flag
Int defines an int flag with specified name(1st parameter), default value(2nd parameter), and usage string(3rd parameter). The return value is the address of an int variable that stores the value of the flag.
Golang flag.FlagSet.Int() function usage example
package main
import (
"flag"
"fmt"
)
func main() {
flagSet := flag.NewFlagSet("check", flag.ExitOnError)
hour := flagSet.Int("diskchecktimeout", 1, "Disk check process time out. Default is 1 hour.")
flag.Parse()
fmt.Println(*hour)
}
Output :
1
Reference :
Advertisement
Something interesting
Tutorials
+16.9k Golang : Read integer from file into array
+12.3k Golang : List running EC2 instances and descriptions
+22.1k Golang : Match strings by wildcard patterns with filepath.Match() function
+6.1k Golang : How to write backslash in string?
+8.5k Golang : How to check if input string is a word?
+6.8k Golang : Join lines with certain suffix symbol example
+16.5k Golang : Check if a string contains multiple sub-strings in []string?
+10.3k Golang : Detect number of faces or vehicles in a photo
+19.2k Golang : Check whether a network interface is up on your machine
+7.9k Golang : Trim everything onward after a word
+8.3k Golang : Implementing class(object-oriented programming style)