Golang flag.FlagSet.Uint64() function example
package flag
Uint64 defines a uint64 flag with specified name(1st parameter), default value(2nd parameter), and usage string(3rd parameter). The return value is the address of a uint64 variable that stores the value of the flag.
Golang flag.FlagSet.Uint64() function usage example
package main
import (
"flag"
"fmt"
)
var (
flagSet *flag.FlagSet
p uint64
)
func main() {
flagSet = flag.NewFlagSet("example", flag.ContinueOnError)
filecounter := flagSet.Uint64("counter", 0, "transferred files counter") // <--here
flagSet.Uint64Var(&p, "maxcount", 50000, "maximum number of files per transfer")
err := flagSet.Parse([]string{"counter", "maxcount"})
if err != nil {
fmt.Println(err)
}
fmt.Println(*filecounter)
fmt.Println(p)
}
Output :
0
50000
Reference :
Advertisement
Something interesting
Tutorials
+12.7k Golang : Remove or trim extra comma from CSV
+20.2k Golang : How to get own program name during runtime ?
+14k Golang: Pad right or print ending(suffix) zero or spaces in fmt.Printf example
+10k Golang : Get escape characters \u form from unicode characters
+12.3k Golang : Print UTF-8 fonts on image example
+7.7k Golang : Command line ticker to show work in progress
+8.2k Golang : Find relative luminance or color brightness
+13.3k Golang : Linear algebra and matrix calculation example
+7.4k Golang : Check to see if *File is a file or directory
+5.6k Unix/Linux : How to find out the hard disk size?
+4k Detect if Google Analytics and Developer Media are loaded properly or not