Golang flag.Flag64() function example
package flag
Float64 defines a float64 flag with specified name(1st parameter), default value (2nd parameter), and usage string(3rd parameter). The return value is the address of a float64 variable that stores the value of the flag.
Golang flag.Flag64() function usage example
package main
import (
"flag"
"fmt"
)
var throttle = flag.Float64("throttle", 0.75, "throttle value; 0.0 = no time allocated, 1.0 = full throttle [default : 0.75]")
func main() {
fmt.Println(flag.Lookup("throttle")) // print Flag struct
fmt.Printf("Throttle value : %.6f\n ", *throttle)
}
Output :
&{throttle throttle value; 0.0 = no time allocated, 1.0 = full throttle [default : 0.75] 0.75 0.75}
Throttle value : 0.750000
Reference :
Advertisement
Something interesting
Tutorials
+10.1k Golang : Edge detection with Sobel method
+18.1k Golang : Convert IPv4 address to decimal number(base 10) or integer
+5.7k Get website traffic ranking with Similar Web or Alexa
+19.6k Golang : Get current URL example
+9.9k Golang : Turn string or text file into slice example
+51.4k Golang : Check if item is in slice/array
+7.9k Setting $GOPATH environment variable for Unix/Linux and Windows
+28.2k Golang : Connect to database (MySQL/MariaDB) server
+5.9k Golang : Shuffle array of list
+10.2k Golang : Find and replace data in all files recursively
+6.8k Golang : Calculate pivot points for a cross