Standard library / flag
flag.Getter
Extends Value with Get, returning the underlying typed value. Check interface support before asserting. Expected stdout: 'true 3\n'.
Formal Syntax & Structure
go syntaxgo
type Getter interface { Value Get() any}Working Example
Example Snippetgo
package main
import ( "flag" "fmt")
func main() { f := flag.NewFlagSet("demo", flag.ContinueOnError) f.Int("n", 3, "count") g, ok := f.Lookup("n").Value.(flag.Getter) fmt.Println(ok, g.Get())}