Exercises
Powerful Command-Line Applications in Go — by Ricardo Gerardi (15 / 127)
Published in
1 min readMar 23, 2022
👈 Compiling Your Tool for Dif ferent Platforms | TOC | Wrapping Up 👉
You can improve your understanding of the concepts discussed here by doing these exercises:
- Add another command-line flag, -b, to count the number of bytes in addition to words and lines.
- Then, update the count function to accept another parameter, countBytes. When this input parameter is set to true, the function should count bytes. (Hint: check all the methods available for the type bufio.Scanner in the Go documentation.[12])
- Write tests to ensure the new feature works as intended.
👈 Compiling Your Tool for Dif ferent Platforms | TOC | Wrapping Up 👉
Powerful Command-Line Applications in Go by Ricardo Gerardi can be purchased in other book formats directly from the Pragmatic Programmers. If you notice a code error or formatting mistake, please let us know here so that we can fix it.