Golang flag.FlagSet.Lookup() function example
package flag
Lookup returns the Flag structure of the named flag, returning nil if none exists.
Golang flag.FlagSet.Lookup() function usage example
package main
import (
"flag"
"fmt"
)
func main() {
flagSet := flag.NewFlagSet("check", flag.ExitOnError)
var boostvalue float64
flagSet.Float64Var(&boostvalue, "throttle", 0.2, "Value to boost current throttle [default :0.2]")
fmt.Println(flagSet.Lookup("throttle")) // <-- here
}
Output :
&{throttle Value to boost current throttle [default :0.2] 0.2 0.2}
Reference :
See also : Golang flag.Lookup() function example
Advertisement
Something interesting
Tutorials
+4.6k JavaScript : Rounding number to decimal formats to display currency
+6.5k Grep : How to grep for strings inside binary data
+6.9k Android Studio : Hello World example
+18.2k Golang : Get command line arguments
+8.1k Golang : How To Use Panic and Recover
+17.7k How to enable MariaDB/MySQL logs ?
+6k Golang : Experimenting with the Rejang script
+7.9k Golang : Gomobile init produce "iphoneos" cannot be located error
+9.6k Golang : Quadratic example
+7.1k Golang : Gorrila mux.Vars() function example
+29.9k Golang : How to get HTTP request header information?
+20k Golang : Convert(cast) bytes.Buffer or bytes.NewBuffer type to io.Reader