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.5k Golang : Handling image beyond OpenCV video capture boundary
+7.8k Golang : Scan files for certain pattern and rename part of the files
+12k Golang : Find and draw contours with OpenCV example
+4.1k Javascript : Empty an array example
+46.2k Golang : Read tab delimited file with encoding/csv package
+11.6k Android Studio : Create custom icons for your application example
+17.7k How to enable MariaDB/MySQL logs ?
+11.2k Golang : Fix - does not implement sort.Interface (missing Len method)
+13.9k Golang : convert(cast) string to float value
+39.2k Golang : How to read CSV file
+4.6k MariaDB/MySQL : How to get version information