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
+34.6k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+18.5k Golang : Write file with io.WriteString
+7.1k Nginx : How to block user agent ?
+22k Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."
+7.9k Golang : Gomobile init produce "iphoneos" cannot be located error
+9.4k Golang : Timeout example
+6.3k Golang : Calculate US Dollar Index (DXY)
+30.6k Golang : Remove characters from string example
+14.6k Golang : Execute function at intervals or after some delay
+41.2k Golang : How to count duplicate items in slice/array?
+7.6k Golang : Set horizontal, vertical scroll bars policies and disable interaction on Qt image