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
+6k Golang : Function as an argument type example
+14k Golang : convert rune to unicode hexadecimal value and back to rune character
+21.8k SSL : How to check if current certificate is sha1 or sha2
+24.5k Golang : Time slice or date sort and reverse sort example
+13k Golang : Get terminal width and height example
+8.7k Golang : Combine slices but preserve order example
+8.7k Golang : How to join strings?
+28.6k Golang : Read, Write(Create) and Delete Cookie example
+11.3k Golang : Intercept and process UNIX signals example
+17.1k Golang : XML to JSON example
+14.2k Golang : syscall.Socket example
+5.8k Golang : List all packages and search for certain package