December 2021
Intermediate to advanced
510 pages
11h 20m
English
You have a working to-do API, so now you can build a command-line interface on top of it. We’ll start with an initial implementation that includes the following two features:
When executed without any arguments, the command will list the available to-do items.
When executed with one or more arguments, the command will concatenate the arguments as a new item and add it to the list.
Start by creating the file main.go in the cmd/todo directory as described in Organizing Your Code.
| | $ cd $HOME/pragprog.com/rggo/interacting/todo/cmd/todo |
Add the following code to the main.go file to define the package and imports you’ll use:
| | package main |
| | |
| | import ( |
| | |
Read now
Unlock full access