Golang flag.Float64Var() function example
package flag
Float64Var defines a float64 flag with specified name(2nd parameter), default value(3rd parameter), and usage(4th parameter) string. The argument p(1st parameter) points to a float64 variable in which to store the value of the flag.
Golang flag.Float64Var() function usage example
package main
import (
"flag"
"fmt"
)
var boostvalue float64
func init() {
flag.Float64Var(&boostvalue, "throttle", 0.2, "Value to boost current throttle [default :0.2]")
}
func main() {
fmt.Println(flag.Lookup("throttle")) // print Flag struct
fmt.Printf("%.6f\n", boostvalue)
}
Output :
&{throttle Value to boost current throttle [default :0.2] 0.2 0.2}
0.200000
Reference :
Advertisement
Something interesting
Tutorials
+9.6k Golang : Copy map(hash table) example
+10.4k Golang : cannot assign type int to value (type uint8) in range error
+18.9k Golang : Read input from console line
+7.6k Android Studio : AlertDialog to get user attention example
+7.4k Linux : How to fix Brother HL-1110 printing blank page problem
+13k Golang : Calculate elapsed years or months since a date
+17.2k Google Chrome : Your connection to website is encrypted with obsolete cryptography
+11.5k Golang : Format numbers to nearest thousands such as kilos millions billions and trillions
+19.2k Golang : Delete item from slice based on index/key position
+22.7k Golang : Set and Get HTTP request headers example
+6.4k Golang : Break string into a slice of characters example
+8.1k Golang : Tell color name with OpenCV example