Standard library / flag
flag.FlagSet.Uint64Var()
Registers a flag on an independent FlagSet. Binds existing uint64 storage rather than returning a pointer. Unsigned 64-bit integer; rejects values outside its range. Run with arguments: ["-x=4294967296"]. Expected stdout: '4294967296\n'.
Formal Syntax & Structure
go syntaxgo
func (f *FlagSet) Uint64Var(p *uint64, name string, value uint64, usage string)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| p | *uint64 | Pointer to storage updated during parsing. |
| name | string | Name of the flag or flag set. |
| value | uint64 | Default value for registration, or text to parse for Set. |
| usage | string | Help text describing the flag. |
Working Example
Example Snippetgo
package main
import ( "flag" "fmt" "os")
func check(e error) { if e != nil { panic(e) }}
func main() { f := flag.NewFlagSet("demo", flag.ContinueOnError) var v uint64 f.Uint64Var(&v, "x", 3, "value") check(f.Parse(os.Args[1:])) fmt.Println(v)}