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 :
Advertisement
Something interesting
Tutorials
+20.2k Golang : Compare floating-point numbers
+13.8k Golang : unknown escape sequence error
+22.4k Golang : Read directory content with filepath.Walk()
+9.1k Golang : Serving HTTP and Websocket from different ports in a program example
+7.5k Golang : Shuffle strings array
+12.6k Golang : flag provided but not defined error
+22.7k Golang : Set and Get HTTP request headers example
+8.1k Golang : Variadic function arguments sanity check example
+18.4k Golang : Logging with logrus
+9.2k nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
+18k Golang : How to log each HTTP request to your web server?