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
+11.6k Golang : Convert(cast) float to int
+9.3k Golang : Generate random Chinese, Japanese, Korean and other runes
+11.7k Golang : Gorilla web tool kit secure cookie example
+5.1k Swift : Convert (cast) Float to Int or Int32 value
+18.1k Golang : Check if a directory exist or not
+5.1k Golang : Check if a word is countable or not
+12.2k Golang : calculate elapsed run time
+13.6k Android Studio : Password input and reveal password example
+5.4k Javascript : How to loop over and parse JSON data?
+13.7k Golang : Activate web camera and broadcast out base64 encoded images
+19.5k Golang : Example for DSA(Digital Signature Algorithm) package functions
+6.3k Golang : Selection sort example