In this article I’m going to explain how to write and run unit tests for Golang code using
go test. If you are completely new to the language, I recommend you take a look at my introduction to Golang article.
Testing in the Golang world revolves around packages, so we need to understand what a package is before we can understand how to test code.
A package is nothing more than a way of grouping related code. In Golang, a folder can only contain a single package. If we try to define two files in a folder belonging to different packages, the compiler will complain.