Standard library / flag

flag.UintVar()

Registers a flag on the default command line. Binds existing uint storage rather than returning a pointer. Unsigned machine-width integer; negative values are invalid. Run with arguments: ["-x=7"]. Expected stdout: '7\n'.

Formal Syntax & Structure

go syntaxgo
func UintVar(p *uint, name string, value uint, usage string)

Parameters & Attributes

NameTypeDescription
p*uintPointer to storage updated during parsing.
namestringName of the flag or flag set.
valueuintDefault value for registration, or text to parse for Set.
usagestringHelp text describing the flag.

Working Example

Example Snippetgo
package main
import (  "flag"  "fmt")
func main() { var v uint; flag.UintVar(&v, "x", 3, "value"); flag.Parse(); fmt.Println(v) }
Go Reference