...
/Adding Finishing Touches to the Initial Client for the REST API
Adding Finishing Touches to the Initial Client for the REST API
Develop the client-side of the REST API.
We'll cover the following...
Now we can use these functions to implement the first command list to list all to-do items from the API. We use the Cobra generator to add the list command to our application:
Press + to interact
cobra add list
Updating the cmd/list.go file
We edit the file cmd/list.go and update the import section to include the following
packages:
ioto use theio.Writerinterface for flexible output.osto use the os.Stdout for output.text/tabwriterto print formatted tabulated data.github.com/spf13/viperto obtain configuration values.
import ("fmt""io""os""text/tabwriter""github.com/spf13/cobra""github.com/spf13/viper")
Importing the required list
Then we edit the command ...
Ask