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
+26.6k Golang : Encrypt and decrypt data with AES crypto
+4.7k MariaDB/MySQL : Form select statement or search query with Chinese characters
+6.8k Golang : Join lines with certain suffix symbol example
+5.7k Golang : Frobnicate or tweaking a string example
+6.3k WARNING: UNPROTECTED PRIVATE KEY FILE! error message
+9.6k Golang : Quadratic example
+24.6k Golang : How to validate URL the right way
+12.3k Golang : Print UTF-8 fonts on image example
+26.4k Golang : Convert(cast) string to uint8 type and back to string
+9k Golang : automatically figure out array length(size) with three dots
+17.6k Golang : Upload/Receive file progress indicator
+12.9k Golang : Convert IPv4 address to packed 32-bit binary format