Run go test -cover to generate data and go tool cover -html to view the report.
Run go test with the -cover flag to generate coverage data, then use go tool cover to visualize it.
go test -cover ./...
go tool cover -html=coverage.out
The first command runs tests and saves results to coverage.out. The second command opens an interactive HTML report in your default browser.
go tool cover measures how much of your code is actually executed when your tests run. It highlights untested lines in red and tested lines in green, helping you find gaps in your test suite. Think of it as a map showing exactly which parts of your code have been visited by your tests.