os.Args

The slice of strings holding the words a Go program was started with, where os.Args[0] is the program itself.

In more detail

os.Args[1:] gives the real arguments. Check len(os.Args) before indexing, or a missing argument panics. For anything beyond one or two arguments, use the flag package, whose flag.Args() returns what is left after options.

Example

args := os.Args[1:]

Related terms

Taught in

References