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
+14.4k Golang : How to filter a map's elements for faster lookup
+12.6k Golang : Exit, terminating or aborting a program
+7.4k Android Studio : How to detect camera, activate and capture example
+7.5k Golang : Rot13 and Rot5 algorithms example
+11.2k CodeIgniter : How to check if a session exist in PHP?
+8k Golang : Handle Palindrome string with case sensitivity and unicode
+4.3k Javascript : How to show different content with noscript?
+9.6k Golang : Sort and reverse sort a slice of floats
+4.3k Golang : Converting individual Jawi alphabet to Rumi(Romanized) alphabet example
+12.2k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter
+19.2k Golang : Populate dropdown with html/template example
+6.5k Grep : How to grep for strings inside binary data