positional argument
A command-line argument identified by its position rather than by a flag name, such as the host names after the options.
In more detail
Use positional arguments for the things a command acts on, and options for how it acts. A command should print its usage message when a required one is missing.
Examples
hosts := flag.Args()Go: flag.Args() returns what is left after flag.Parse()Related terms
- flag package — Go's standard library package for parsing command-line options into typed values with defaults and a generated usage message.
- os.Args — The slice of strings holding the words a Go program was started with, where os.Args[0] is the program itself.
- command-line option — An argument starting with a dash, such as -r or --help, that changes how a command behaves rather than naming what it works on.
Taught in
- Parsing Arguments with flag — Concurrent Systems Programming with Go