Golang flag.FlagSet.Float64Var() 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.FlagSet.Float64() function usage example

 package main

 import (
 "flag"
 "fmt"
 )

 func main() {

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


 diskchecktime := flagSet.Float64("diskchecktime", 1.0, "Amount of time to allow for a single disk check process")

 flag.Parse()

 fmt.Println(*diskchecktime)

 }

Output :

1

Reference :

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

Advertisement