Summary
In this chapter, you learned what build tags are and how to use them for different purposes. Build tags can be used for generating builds of different levels, separating our specific tests, or adding debug features. You also learned how to generate builds with the build tags that you added to the top of your files and how to utilize the Boolean logic of tags to quickly determine whether files will or won’t be included.
You also learned how to test your Cobra CLI commands with Golang’s default testing
package. Some necessary tools were also included, such as learning how to mock an HTTP client. Together with the build tags, you can now not only build targeted applications with tags but also run tests with the same tags to target specific tests. In the next chapter, Chapter 12, Cross-Compilation Across Different Platforms, we will learn how to use these tags and compile for the different major operating systems: darwin
, linux
, and windows
.