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
+10.7k Golang : Interfacing with PayPal's IPN(Instant Payment Notification) example
+12.3k Golang : How to check if a string starts or ends with certain characters or words?
+16.6k Golang : Generate QR codes for Google Authenticator App and fix "Cannot interpret QR code" error
+9.6k Golang : How to extract video or image files from html source code
+11.7k Golang : Calculations using complex numbers example
+11.7k Golang : Gorilla web tool kit secure cookie example
+13.7k Golang : Check if an integer is negative or positive
+11.2k Golang : Proper way to test CIDR membership of an IP 4 or 6 address example
+20.5k Golang : Pipe output from one os.Exec(shell command) to another command
+17.5k Golang : Linked list example
+20.2k Golang : Convert seconds to human readable time format example
+3.7k Java : Random alphabets, alpha-numeric or numbers only string generator