Golang flag.NArg() function example

package flag

NArg is the number of arguments remaining after flags have been processed.

Golang flag.NArg() function usage example

 ...
 func main() {
 flag.Parse()
 if flag.NArg() != 1 { // <-- here
 fmt.Println("no filename specified")
 os.Exit(1)
 }
 filename = flag.Args()[0]
 ...

Reference :

http://golang.org/pkg/flag/#NArg

  See also : Golang flag.NFlag() function example

Advertisement