Golang flag.Uint64() function example

package flag

Uint64 defines a uint64 flag with specified name(1st parameter), default value(2nd parameter), and usage string(3rd parameter). The return value is the address of a uint64 variable that stores the value of the flag.

Golang flag.Uint64() function usage example

 package main

 import (
 "flag"
 "fmt"
 "strconv"
 )

 func main() {

 hotDataSize := flag.Uint64("hotDataSize", 0, "Hot data size in bytes. 0 disables hot data optimization")

 flag.Parse()

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

 fmt.Printf("Hot Data Size is %s\n ", strconv.FormatUint(uint64(*hotDataSize), 3))

 }

Output :

&{hotDataSize Hot data size in bytes. 0 disables hot data optimization 0 0}

Hot Data Size is 0

Reference :

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

Advertisement