February 2020
Intermediate to advanced
404 pages
8h 42m
English
The cli package is the next step for a Go developer after working with the flag package. It provides an intuitive API for creating command-line applications with ease. It allows a Go program to collect arguments and flags. It's quite handy for designing complex applications.
First, create a directory for our example programs. For our basic CLI example, create the following directory:
mkdir -p $GOPATH/src/github.com/git-user/chapter8/cli/example1
To install the package, we use the dep tool. Initialize the tool first and then add the cli package as the dependency:
dep init dep ensure --add github.com/urfave/cli
Now, we can write a program that does exactly the same job as the preceding flag example. ...
Read now
Unlock full access