Standard library / flag
flag.FlagSet.Float64()
Registers a flag on an independent FlagSet. 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 (f *FlagSet) Float64(name string, value float64, usage string) *float64Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| 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. |
Return Value
*float64
Registers a flag on an independent FlagSet.
Working Example
Example Snippetgo
package main
import ( "flag" "fmt" "os")
func check(e error) { if e != nil { panic(e) }}
func main() { f := flag.NewFlagSet("demo", flag.ContinueOnError) v := f.Float64("x", 0.5, "value") check(f.Parse(os.Args[1:])) fmt.Println(*v)}