How to Run Tests in Go (go test Command)

Run Go tests using the go test command with optional flags for verbose output or specific test selection.

Run go test in your package directory to execute all tests ending in _test.go.

go test

To run tests with verbose output showing each test name as it runs, use the -v flag:

go test -v

To run a specific test function, use the -run flag followed by a regular expression matching the test name:

go test -run TestReader