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
+9.9k Golang : Sort and reverse sort a slice of integers
+8.1k Golang : Append and add item in slice
+5.9k Golang : Extract unicode string from another unicode string example
+16.8k Golang : Get own process identifier
+13.7k Golang : Tutorial on loading GOB and PEM files
+10k Golang : Get escape characters \u form from unicode characters
+18.4k Golang : How to remove certain lines from a file
+13k Golang : Calculate elapsed years or months since a date
+6k Golang : How to verify input is rune?
+26.8k Golang : Find files by extension
+14.6k Golang : Send email with attachment(RFC2822) using Gmail API example
+26.9k Golang : Force your program to run with root permissions