Standard library / flag

flag.NArg()

Counts remaining positional arguments. Run with arguments: ["a", "b"]. Expected stdout: '2\n'.

Formal Syntax & Structure

go syntaxgo
func NArg() int

Return Value

int

Counts remaining positional arguments.

Working Example

Example Snippetgo
package main
import (  "flag"  "fmt")
func main() { v := flag.Int("x", 0, "value"); _ = v; flag.Parse(); fmt.Println(flag.NArg()) }
Go Reference