Summary
In this chapter, we learned about the special features in Go that are not so obvious.
We covered the use of build constraints and how they can be used to control the behavior of your application build. Build constraints can be used to perform conditional compilation using the GOOS
and GOARCH
variables. They can also be used to ignore a file during compilation. Another common use of build
tags is to add tags to files that contain integration tests.
We have seen use cases for the reflect
package and the functions that can be used to access the type and value of objects at runtime. Reflection is a good way to solve scenarios where we can only determine the data type of a variable at runtime.
We also demonstrated how wildcards can be used to perform lists and tests on multiple packages in your project. We also learned the use of the unsafe
package to access runtime memory in Go. The unsafe
package is commonly used when using C libraries.
Over the course of the book...