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.6k Golang : Quadratic example
+7.7k Gogland : Where to put source code files in package directory for rookie
+4.8k Facebook : How to place save to Facebook button on your website
+18.7k Golang : Iterating Elements Over A List
+13.9k Golang : Get current time
+5.9k AWS S3 : Prevent Hotlinking policy
+6.5k PHP : Shuffle to display different content or advertisement
+4.7k MariaDB/MySQL : Form select statement or search query with Chinese characters
+5.9k Golang : Generate multiplication table from an integer example
+8.7k Golang : Find duplicate files with filepath.Walk
+31.5k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+39.6k Golang : Remove dashes(or any character) from string