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
+12.1k Golang : md5 hash of a string
+8.9k Golang : GMail API create and send draft with simple upload attachment example
+11.2k CodeIgniter : How to check if a session exist in PHP?
+39.2k Golang : How to read CSV file
+20.9k Golang : Convert PNG transparent background image to JPG or JPEG image
+11.4k Golang : Delay or limit HTTP requests example
+6.3k Apt-get to install and uninstall Golang
+15.2k JavaScript/JQuery : Detect or intercept enter key pressed example
+19.3k Golang : Get RGBA values of each image pixel
+20.9k PHP : Convert(cast) int to double/float
+9.9k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral
+14.9k Golang : How to check for empty array string or string?