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
+19.5k Golang : How to Set or Add Header http.ResponseWriter?
+14.2k Golang : Chunk split or divide a string into smaller chunk example
+12.6k Golang : flag provided but not defined error
+21.8k Golang : Convert string slice to struct and access with reflect example
+25.7k Golang : How to write CSV data to file
+25.4k Golang : Convert long hexadecimal with strconv.ParseUint example
+15.6k Golang : Convert date format and separator yyyy-mm-dd to dd-mm-yyyy
+17.4k Golang : Check if IP address is version 4 or 6
+7.3k Golang : alternative to os.Exit() function
+41.4k Golang : Convert string to array/slice
+12.3k Golang : How to display image file or expose CSS, JS files from localhost?