Command-line arguments revisited!

As we saw in Chapter 2, Writing Programs in Go, you cannot work efficiently with multiple command-line arguments and options using if statements. The solution to this problem is to use the flag package, which will be explained here.

Remembering that the flag package is a standard Go package and that you do not have to search for the functionality of a flag elsewhere is extremely important.

Get Go Systems Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.