Golang flag.Bool() function example

package flag

Bool defines a bool flag with specified name (1st parameter) , default value (2nd parameter) , and usage string (3rd parameter). The return value is the address of a bool variable that stores the value of the flag.

Golang flag.Bool() function usage example

 ...
 var writeFlag = flag.Bool("write", false, "If true, will write a value to the key")

 if *writeFlag {
 // do something
 }
 ...

Reference :

http://golang.org/pkg/flag/#Bool

Advertisement