1
0
mirror of https://github.com/golang/go synced 2024-10-01 12:38:31 -06:00
Commit Graph

3 Commits

Author SHA1 Message Date
Ford Hurley
0ced849c61 tools/cmd/vet: check only first rune of example suffix
The documentation for the testing package states only that "The suffix
must start with a lower-case letter."

Fixes golang/go#12663

Change-Id: I9b079b105a7c9680325fed442c42adcf3b75055e
Reviewed-on: https://go-review.googlesource.com/14760
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-21 00:24:47 +00:00
Matt T. Proud
871b75fbfc tools/cmd/vet: Incorporate comments from r@.
This commit fixes a few defects from a25a8d567b:

(1.) Making the top-level vars in main consistent w.r.t. documentation
     formatting, and the-like.

(2.) Removing of one-use top-level is-test predicate.

(3.) Including documentation of what the validation does and when.

Change-Id: I19b34d25836bb2af865219d18600e1add78c3fd7
Reviewed-on: https://go-review.googlesource.com/14557
Reviewed-by: Rob Pike <r@golang.org>
2015-09-15 16:08:13 +00:00
Matt T. Proud
a25a8d567b tools/cmd/vet: Create vet checks for examples.
In spite of https://blog.golang.org/examples and
http://golang.org/pkg/testing/#pkg-examples, a number of internal Go
authors have found writing documentation examples to be problematic in
the sense that the syntax is error-prone due to loose coupling with
identifiers found in the source corpus.

This commit introduces a suite of validations for documentation
examples:

    Overall:
    - Correct suffices, if present
    - Niladic function argument and return signatures

    func Example() {}
    func ExampleF() {}
    - F exists
    func ExampleT() {}
    - T exists
    func ExampleT_M() {}
    - T exists
    - M exists within T

Further, if the example is in `package foo_test`, vet attempts to
resolve the respective lookups in `package foo`, if `package foo`
exists (cf., `package stringutil_test`).

Change-Id: Ifa13906363541ebf28325681b749b14b7f8b103d
Reviewed-on: https://go-review.googlesource.com/11982
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-15 07:54:34 +00:00