Skip to content

proposal: testing: relax lower-case suffix requirement for example test annotation #43528

Description

@kortschak

Background

The testing package provides a mechanism to produce distinct examples for a single package, function, type or method.

Multiple example functions for a package/type/function/method may be provided by appending a distinct suffix to the name. The suffix must start with a lower-case letter.

func Example_suffix() { ... }
func ExampleF_suffix() { ... }
func ExampleT_suffix() { ... }
func ExampleT_M_suffix() { ... }

Currently, this is specified to be defined by a suffix that starts with a lower-case letter. This restrictions is presumably to ensure that a method (which must start with an upper-case letter to be justified in having a documentation example by virtue of being exported) is distinguishable from a suffix tag. The godoc command has always allowed numeric and first characters, enabling the use of culturally conventional numbered examples and use of 'words' that start with a number (see #43454 for the motivation for this proposal). It's worth noting that the only requirement for distinguishing between a method _M and a human-directed _suffix would be that the suffix can not be interpretable as a method worth documenting; it must not have an upper-case initial.

Proposal

Relax the documented restriction to be "The suffix must not start with an upper-case letter."

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

    Type

    No type

    Projects

    • Status
      Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions