Standard library / flag
flag.NFlag()
Counts distinct flags set, not the number of occurrences. Run with arguments: ["-x=1", "-x=2"]. Expected stdout: '1\n'.
Formal Syntax & Structure
go syntaxgo
func NFlag() intReturn Value
int
Counts distinct flags set, not the number of occurrences.
Working Example
Example Snippetgo
package main
import ( "flag" "fmt")
func main() { v := flag.Int("x", 0, "value"); _ = v; flag.Parse(); fmt.Println(flag.NFlag()) }