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
+21.8k Golang : Upload big file (larger than 100MB) to AWS S3 with multipart upload
+25.7k Golang : How to write CSV data to file
+14.8k Golang : Normalize unicode strings for comparison purpose
+12.1k Golang : Save webcamera frames to video file
+6.9k How to let Facebook Login button redirect to a particular URL ?
+23.1k Golang : Randomly pick an item from a slice/array example
+5.2k JavaScript/JQuery : Redirect page examples
+16.4k Golang : Test floating point numbers not-a-number and infinite example
+7.9k Swift : Convert (cast) String to Float
+25.8k Golang : Daemonizing a simple web server process example
+17.2k Golang : Find file size(disk usage) with filepath.Walk
+6.1k Golang : Scan forex opportunities by Bollinger bands