Accessing Non-Flag Arguments

Learn about arguments and how to access non-flag arguments in Go.

We'll cover the following

Arguments in Go are read in a few ways. We can read the raw arguments using os.Args, which will also include all the flags. This is great when no flags are used.

When using flags, flag.Args() can be used to retrieve only the non-flag arguments. If we want to send a list of authors to a development server and retrieve QOTDs for each author, the command might look like this:

Get hands-on with 1400+ tech skills courses.