Exercises

Powerful Command-Line Applications in Go — by Ricardo Gerardi (70 / 127)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Handling Signals | TOC | Wrapping Up 👉

Try these exercises to improve the skills you learned:

  • Add another step to the pipeline: code linting using golangci-lint. For more information consult its home page.[38]
  • Add gocyclo to the pipeline. Capture its output and return an error if gocyclo returns any functions with a complexity score of 10 or greater. For more information about this tool, consult its GitHub page.[39]
  • Add environment variables to handle Git authentication with remote repositories that require it.
  • Add another command-line flag to your tool asking for the Git branch to push. Update the Git step to accept a configurable branch instead of master.
  • Get the Pipeline configuration from a file instead of hard-coding it in the run function.

👈 Handling Signals | 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.

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.