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
+10.6k Android Studio : Simple input textbox and intercept key example
+12.9k Python : Convert IPv6 address to decimal and back to IPv6
+8.2k Golang : Get final or effective URL with Request.URL example
+5.3k Golang : Pad file extension automagically
+12.5k Golang : Forwarding a local port to a remote server example
+6.9k Golang : Decode XML data from RSS feed
+19.2k Golang : Check if directory exist and create if does not exist
+5.8k Golang : Find change in a combination of coins example
+11.2k Golang : Calculate Relative Strength Index(RSI) example
+14.6k Golang : Execute function at intervals or after some delay
+13.9k Golang : Get dimension(width and height) of image file
+10.6k Golang : Flip coin example