This repository contains code for learning Go with tests, following the Learn Go with Tests book.
Each package represents a lesson and contains corresponding tests.
go run src/main.go
go test ./...
The ./...
syntax in the go test
command is a wildcard pattern that tells the Go tool to recursively find and run tests in the current directory and all its subdirectories. This is useful for running all tests in a multi-package project with a single command.
-
Run All Tests in the Current Directory and Subdirectories:
go test ./...
-
Run Tests in a Specific Package:
go test ./path/to/package
-
Run Tests with Verbose Output:
go test -v ./...
-
Run Tests with Coverage:
go test -cover ./...
-
Run Tests and Generate a Coverage Report:
go test -coverprofile=coverage.out ./... go tool cover -html=coverage.out
-
Run a Specific Test Function:
go test -run TestFunctionName ./path/to/package