Write a function with the testing.T parameter in a file named *_test.go and run it with go test.
package mypackage
import "testing"
func TestAdd(t *testing.T) {
got := Add(2, 3)
want := 5
if got != want {
t.Errorf("Add(2, 3) = %d; want %d", got, want)
}
}
Run the test:
go test