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 :

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

Advertisement