Standard library / flag

flag.Float64()

Registers a flag on the default command line. 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 Float64(name string, value float64, usage string) *float64

Parameters & Attributes

NameTypeDescription
namestringName of the flag or flag set.
valuefloat64Default value for registration, or text to parse for Set.
usagestringHelp text describing the flag.

Return Value

*float64

Registers a flag on the default command line.

Working Example

Example Snippetgo
package main
import (  "flag"  "fmt")
func main() { v := flag.Float64("x", 0.5, "value"); flag.Parse(); fmt.Println(*v) }
Go Reference