Course Recap

We covered a lot of ground in this course, so let's do a quick recap and appreciate how far we've come

Overview

In the overview section we just started to warm up. We discussed the attributes of command-line programs in general and why they are so useful.

Then, we took a deep look into the Go programming language and explored its unique properties.

We followed up with ten popular and high-caliber Go projects to demonstrate how influential Go has become in a relatively short time frame.

Finally, we introduced the multi-git application that was our coding guinea pig throughout the course.

Restructuring multi-git

In this section, we prepared multi-git for the big things to come later. We came up with a reasonable directory structure that follows the Go community’s best practices with pkg and cmd top-level directories, and, then we refactored the core logic into a pkg/repo_manager package and the command-line interface into the cmd/mg package.

Testing 1,2,3

In the testing section, we focused on adding tests to multi-git. Testing is always important, but especially when refactoring. First, we introduced the testing support of Go itself, which is powerful and extensive, but not necessarily user-friendly. We addressed that with Ginkgo and Gomega, and the BDD testing framework built on top of Go’s testing support.

Then, we created some end-to-end tests for multi-git as well.

Adding smart command-line parsing

In the smart command-line parsing section we met Cobra for the first time. We looked at using Cobra as a library and then explored how to use it to generate a full-fledged application skeleton. We refactored multi-git to use Cobra for command-line parsing instead of its own ad-hoc command-line argument parsing.

Adding advanced configuration

In the advanced configuration section, we encountered Viper, which can work on its own, but works even better when combined with Cobra. We looked at environment variables, configuration files and remote configuration stores. We played with Viper’s support for various configuration sources and then refactored multi-git to take advantage of all the goodness.

Adding bells and whistles

Multi-git was a decent command-line program at this state, but we went the extra mile and embedded git tag and build time into the executable, added a cool GitHub Actions pipeline, made multi-git update itself when run and even showed how to package it into a Docker image. Finally, we added a nice Makefile that helped us build and manage multi-git.

Conclusion

Wow, that was a lot. The course focused on command-line programs, but many of the concepts can be applied to any Go program, including testing, refactoring methods, configuration, and Dockerizing a Go program.

I hope you enjoyed yourself and learned some useful stuff. As I mentioned in the “Why Go?” lesson Go is unique and a great tool to have.

Where to go from here? Go is super versatile and beyond command-line programs it is the language of the cloud. A lot of the modern cloud software, like Docker, Kubernetes, various queues, and data stores are built using Go.

I’m personally a big proponent of Kubernetes, and I wrote several books on the subject. If you are the type of person that prefers learning from books make sure to check them out:

  • Mastering Kubernetes 3rd edition
  • Hands on Microservices with Kubernetes

I wish you all the best. Always keep learning and building cool stuff.

Quiz

Just kidding!

Get hands-on with 1200+ tech skills courses.