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
+5.6k Swift : Get substring with rangeOfString() function example
+23.6k Golang : minus time with Time.Add() or Time.AddDate() functions to calculate past date
+9.9k Golang : Check if user agent is a robot or crawler example
+8.8k Golang : Get final balance from bit coin address example
+14.8k Golang : Find commonalities in two slices or arrays example
+9.2k Golang : Create and shuffle deck of cards example
+19.9k Golang : Measure http.Get() execution time
+5.8k Unix/Linux : How to test user agents blocked successfully ?
+20.7k Golang : Saving private and public key to files
+6.2k Golang & Javascript : How to save cropped image to file on server
+10.3k Golang : Convert file unix timestamp to UTC time example
+14.2k Elastic Search : Mapping date format and sort by date