The following text from the description of the package is at least misleading:
// If the test file is in the same package, it may refer to unexported
// identifiers within the package, as in this example:
//
// package abs
//
// import "testing"
//
// func TestAbs(t *testing.T) {
// got := Abs(-1)
// if got != 1 {
// t.Errorf("Abs(-1) = %d; want 1", got)
// }
// }
it may refer to unexported identifiers within the package, as in this example:
And then, in the example, we have an exported Abs
identifier?
The Abs
is then used in the next example, that refers to exported identifiers, and that usage is correct.
But the mentioned first example confuses the reader.
Comment From: gabyhelp
Related Code Changes
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: gopherbot
Change https://go.dev/cl/705456 mentions this issue: testing: fix example for unexported identifier