How to Use go tool cover for Test Coverage

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.