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.4k Golang : Convert word to its plural form example
+5.9k Golang : Shuffle array of list
+25.6k Golang : convert rune to integer value
+9k Golang : Build and compile multiple source files
+6.4k PHP : Proper way to get UTF-8 character or string length
+18.8k Golang : Delete duplicate items from a slice/array
+25.7k Golang : missing Mercurial command
+5.8k Unix/Linux : How to test user agents blocked successfully ?
+8.7k Golang : Find duplicate files with filepath.Walk
+4.7k JavaScript: Add marker function on Google Map
+10.8k PHP : Convert(cast) bigInt to string
+31.5k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions