Golang flag.FlagSet.Uint() function example
package flag
Uint defines a uint flag with specified name(1st parameter), default value(2nd parameter), and usage string(3rd parameter). The return value is the address of a uint variable that stores the value of the flag.
Golang flag.FlagSet.Uint() function usage example
package main
import (
"flag"
"fmt"
)
var (
flagSet *flag.FlagSet
p uint
)
func main() {
flagSet = flag.NewFlagSet("example", flag.ContinueOnError)
filecounter := flagSet.Uint("counter", 0, "transferred files counter") // <-- here
flagSet.UintVar(&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
+13.9k Golang : How to determine if a year is leap year?
+10k Golang : Read file and convert content to string
+6k Golang : Experimenting with the Rejang script
+5.1k Linux : How to set root password in Linux Mint
+10.3k Golang : How to check if a website is served via HTTPS
+6.2k Linux/Unix : Commands that you need to be careful about
+12.7k Golang : Remove or trim extra comma from CSV
+16.5k Golang : File path independent of Operating System
+6.2k Golang & Javascript : How to save cropped image to file on server
+7.2k Golang : Use modern ciphers only in secure connection
+24.5k Golang : Change file read or write permission example
+8.7k Golang : How to join strings?