Tooling
Go is like a toolbox. It has everything we need to build great software, so we don’t need anything more than its standard tools to create our programs.
Let’s explore the principal tools that facilitate building, testing, running, error-checking, and code formatting.
go build
The go build command is used to compile Go code into an executable binary that you can run.
Let’s see an example.
Assume you have a Go source file named main.go containing the following code:
package main
import "fmt"
func main() {
fmt.Println("Hello, Go!")
} You can compile it using the go build command:
go build main.go
This will generate an executable binary named main (or main.exe on Windows). You can then run the binary to see the output:
./main
go test
The go test command is used to run tests on your Go code. It automatically finds test files and runs the associated test functions.
Here’s an...