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
+6.4k PHP : Proper way to get UTF-8 character or string length
+9.7k Golang : Format strings to SEO friendly URL example
+25.6k Golang : convert rune to integer value
+5k Golang : Calculate a pip value and distance to target profit example
+10.2k Golang : Bcrypting password
+5.4k Golang : Get S3 or CloudFront object or file information
+7.9k Golang : Ways to recover memory during run time.
+24.5k Golang : Change file read or write permission example
+17.2k Golang : Find file size(disk usage) with filepath.Walk
+17k Golang : How to save log messages to file?
+20k Golang : How to run your code only once with sync.Once object