Golang flag.FlagSet.Float64Var() function example

package flag

Float64Var defines a float64 flag with specified name(2nd parameter), default value(3rd parameter), and usage string(4th parameter). The argument p(1st parameter) points to a float64 variable in which to store the value of the flag.

Golang flag.FlagSet.Float64Var() function usage example

 package main

 import (
 "flag"
 "fmt"
 )

 func main() {

 flagSet := flag.NewFlagSet("check", flag.ExitOnError)

 var p float64

 flagSet.Float64Var(&p, "diskchecktimeout", 1.0, "Time before disk check process time out. Default is 1.0")

 flag.Parse()

 fmt.Println(p)

 }

Output :

1

Reference :

http://golang.org/pkg/flag/#FlagSet.Float64Var

Advertisement