Skip to content

testing: wrong example in package docs for unexported identifier #75540

Description

@Tomasz-Smelcerz

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FixPendingIssues that have a fix which has not yet been reviewed or submitted.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions