Improving the List Output Format
Explore how to improve your Go command-line application's output by implementing the Stringer interface on a custom list type. Learn to format output consistently, update tests accordingly, and create a more informative user experience.
We’ve made good progress on our to-do list tool so far, but the list output is still not very informative.
Powerful interfaces
At this moment, executing the command ./todo -list gives us this output:
Another ToDo item
Improve usage
Improve output
There are various ways of improving the output formatting. For instance, if we don’t own the API code, our only alternative is to format the output in the command-line tool implementation. But we own the API, so we can leverage the powerful interfaces feature of Go to implement the list output formatting in ...