The go build tool
The go build tool takes Go source code and compiles it so that it can be executed. When creating software, you write code in a human-readable programming language. Then, the code needs to be translated into a machine-readable format so that it can be executed. This is done by a compiler that compiles the machine instructions from the source code. To do this with Go code, you can use go build.
Exercise 20.01 – using the go build tool
In this exercise, you will learn about the go build tool. This will take your Go source code and compile it into a binary. To use it, run the go build tool on the command line while using the –o flag to specify the output file or executable name:
go build -o name_of_the_binary_to_create source_file.go If the –o flag is omitted, the output file will be named by the package or folder that contains the source file.
Let’s get started:
- Create a new directory called
Exercise20.01. Within that...