Skip to content

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

@Tomasz-Smelcerz

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.

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