Golang flag.FlagSet.Uint64Var() function example
package flag
Uint64Var defines a uint64 flag with specified name(2nd parameter), default value(3rd parameter), and usage string(4th parameter). The argument p(1st parameter) points to a uint64 variable in which to store the value of the flag.
Golang flag.FlagSet.Uint64Var() 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")
flagSet.Uint64Var(&p, "maxcount", 50000, "maximum number of files per transfer") // <-- here
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
+30k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+22.4k Golang : How to read JPG(JPEG), GIF and PNG files ?
+8k Golang : Get all countries phone codes
+11.3k Golang : Fix fmt.Scanf() on Windows will scan input twice problem
+5.7k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+51.1k Golang : Disable security check for HTTPS(SSL) with bad or expired certificate
+26.6k Golang : Encrypt and decrypt data with AES crypto
+5.6k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+5.9k Golang : Extract unicode string from another unicode string example
+8.1k Golang : How To Use Panic and Recover
+10.8k Golang : Natural string sorting example