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
+9.5k Golang : Accessing content anonymously with Tor
+18.1k Golang : Convert IPv4 address to decimal number(base 10) or integer
+10.3k Golang : Convert file unix timestamp to UTC time example
+19.2k Golang : Check whether a network interface is up on your machine
+12.2k Golang : calculate elapsed run time
+14.6k Golang : How to get URL port?
+14.9k Golang : Submit web forms without browser by http.PostForm example
+29.5k Golang : Login(Authenticate) with Facebook example
+14.2k Golang : Convert IP version 6 address to integer or decimal number
+8.3k Golang : Implementing class(object-oriented programming style)
+11.2k Golang : Fix - does not implement sort.Interface (missing Len method)
+11.6k Golang : Surveillance with web camera and OpenCV