Golang flag.Int64Var() function example
package flag
Int64Var defines an int64 flag with specified name(2nd parameter), default value(3rd parameter), and usage(4th parameter) string. The argument p(1st parameter) points to an int64 variable in which to store the value of the flag.
Golang flag.Int64Var() function usage example
package main
import (
"flag"
"fmt"
"time"
)
var rand64seed int64
func main() {
flag.Int64Var(&rand64seed, "randomseed", time.Now().Unix() , "Seed for randomizing")
fmt.Println(flag.Lookup("randomseed")) // print Flag struct
fmt.Println("seed value : ", rand64seed)
}
Output :
&{randomseed Seed for randomizing 1413179827 1413179827}
seed value : 1413179827
Reference :
Advertisement
Something interesting
Tutorials
+18.5k Golang : Send email with attachment
+18.4k Golang : Logging with logrus
+8.1k Golang : Append and add item in slice
+37.5k Golang : Converting a negative number to positive number
+6.8k Unix/Linux : How to fix CentOS yum duplicate glibc or device-mapper-libs dependency error?
+10.1k Golang : Get login name from environment and prompt for password
+3.6k Java : Get FX sentiment from website example
+8.1k Golang : Variadic function arguments sanity check example
+11.5k Use systeminfo to find out installed Windows Hotfix(s) or updates
+6.3k Golang : Calculate US Dollar Index (DXY)
+25.6k Golang : convert rune to integer value
+15.9k Golang : Get current time from the Internet time server(ntp) example