Don't flag underscores in Examples.
Fixes #5.
diff --git a/README b/README
index 378dbb4..3a9d3e4 100644
--- a/README
+++ b/README
@@ -1,8 +1,5 @@
golint is a linter for Go source code.
-To install, run
- go get github.com/golang/lint/golint
-
Invoke golint with one or more filenames.
The output of this tool is a list of suggestions in Vim quickfix format,
which is accepted by lots of different editors.
diff --git a/lint.go b/lint.go
index 51db210..da59b46 100644
--- a/lint.go
+++ b/lint.go
@@ -200,8 +200,6 @@
// lintNames examines all names in the file.
// It complains if any use underscores or incorrect known initialisms.
func (f *file) lintNames() {
- // TODO(dsymonds): If in a test, don't ping ExampleFoo_Bar.
-
// Package names need slightly different handling than other names.
if strings.Contains(f.f.Name.Name, "_") && !strings.HasSuffix(f.f.Name.Name, "_test") {
f.errorf(f.f, 1, "don't use an underscore in package name")
@@ -230,6 +228,9 @@
}
}
case *ast.FuncDecl:
+ if f.isTest() && strings.HasPrefix(v.Name.Name, "Example") {
+ return true
+ }
check(v.Name, "func")
case *ast.GenDecl:
if v.Tok == token.IMPORT {
diff --git a/testdata/5_test.go b/testdata/5_test.go
index 1f925f9..af84ba1 100644
--- a/testdata/5_test.go
+++ b/testdata/5_test.go
@@ -9,3 +9,6 @@
func TestSomething(t *testing.T) {
}
+
+func ExampleBuffer_reader() {
+}