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
+8.9k Golang : GMail API create and send draft with simple upload attachment example
+20.9k Golang : Convert PNG transparent background image to JPG or JPEG image
+6.8k Swift : substringWithRange() function example
+12.1k Golang : md5 hash of a string
+14.5k Golang : Rename directory
+8.2k Golang : Metaprogramming example of wrapping a function
+12.3k Golang : Display list of countries and ISO codes
+9.1k Golang : Get curl -I or head data from URL example
+9.7k Golang : Eroding and dilating image with OpenCV example
+29.3k Golang : Save map/struct to JSON or XML file
+14.1k Golang : Check if a file exist or not