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
+14.6k Golang : Convert(cast) int to float example
+13.9k Golang : Get current time
+10.9k Golang : Removes punctuation or defined delimiter from the user's input
+19.2k Golang : Execute shell command
+6.5k PHP : Shuffle to display different content or advertisement
+6.9k Golang : How to setup a disk space used monitoring service with Telegram bot
+7.5k Golang : Get YouTube playlist
+7.9k Golang : Gomobile init produce "iphoneos" cannot be located error
+17.9k Golang : Qt image viewer example
+12k Golang : Clean formatting/indenting or pretty print JSON result
+11.7k Golang : Calculations using complex numbers example
+10.2k Golang : How to get quoted string into another string?