Golang flag.UintVar() function example

package flag

UintVar defines a uint flag with specified name(2nd parameter), default value(3rd parameter), and usage string(4th parameter). The argument p (1st parameter) points to a uint variable in which to store the value of the flag.

Golang flag.UintVar() function usage example

 package main

 import (
 "flag"
 "fmt"
 )

 func main() {
 var appID uint

 flag.UintVar(&appID, "FBAppID", 108, "Facebook Application ID")

 flag.Parse()

 fmt.Println(flag.Lookup("FBAppID")) // print the Flag struct

 fmt.Println(appID)

 }

Output :

&{FBAppID Facebook Application ID 108 108}

108

Reference :

http://golang.org/pkg/flag/#UintVar

Advertisement