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
+34k Golang : Proper way to set function argument default value
+5.5k Golang : If else example and common mistake
+13.8k Golang : Convert spaces to tabs and back to spaces example
+4.3k Javascript : How to show different content with noscript?
+21.2k Golang : How to force compile or remove object files first before rebuild?
+7.2k Ubuntu : connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream
+22k Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."
+5.6k Unix/Linux : How to find out the hard disk size?
+15.4k Golang : invalid character ',' looking for beginning of value
+29.3k Golang : Save map/struct to JSON or XML file
+9.6k Javascript : Read/parse JSON data from HTTP response