Standard library / flag
flag.Float64Var()
Registers a flag on the default command line. Binds existing float64 storage rather than returning a pointer. 64-bit floating-point number parsed using strconv. Run with arguments: ["-x=1.25"]. Expected stdout: '1.25\n'.
Formal Syntax & Structure
go syntaxgo
func Float64Var(p *float64, name string, value float64, usage string)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| p | *float64 | Pointer to storage updated during parsing. |
| name | string | Name of the flag or flag set. |
| value | float64 | Default value for registration, or text to parse for Set. |
| usage | string | Help text describing the flag. |
Working Example
Example Snippetgo
package main
import ( "flag" "fmt")
func main() { var v float64; flag.Float64Var(&v, "x", 0.5, "value"); flag.Parse(); fmt.Println(v) }