Clarify that a reasonable response to a missing doc comment on an exported name is to unexport it.
diff --git a/lint.go b/lint.go
index 613a430..f862a76 100644
--- a/lint.go
+++ b/lint.go
@@ -367,7 +367,7 @@
return
}
if doc == nil {
- f.errorf(t, 1, "exported type %v should have comment", t.Name)
+ f.errorf(t, 1, "exported type %v should have comment or be unexported", t.Name)
return
}
@@ -422,7 +422,7 @@
name = recv + "." + name
}
if fn.Doc == nil {
- f.errorf(fn, 1, "exported %s %s should have comment", kind, name)
+ f.errorf(fn, 1, "exported %s %s should have comment or be unexported", kind, name)
return
}
s := fn.Doc.Text()
@@ -459,7 +459,7 @@
if vs.Doc == nil {
if gd.Doc == nil && !genDeclMissingComments[gd] {
- f.errorf(vs, 1, "exported %s %s should have comment", kind, name)
+ f.errorf(vs, 1, "exported %s %s should have comment or be unexported", kind, name)
genDeclMissingComments[gd] = true
}
return
diff --git a/testdata/4.go b/testdata/4.go
index 829a581..7ea22fd 100644
--- a/testdata/4.go
+++ b/testdata/4.go
@@ -3,9 +3,9 @@
// Package pkg does something.
package pkg
-type T int // MATCH /exported type T.*should.*comment/
+type T int // MATCH /exported type T.*should.*comment.*or.*unexport/
-func (T) F() {} // MATCH /exported method T\.F.*should.*comment/
+func (T) F() {} // MATCH /exported method T\.F.*should.*comment.*or.*unexport/
// this is a nice type.
// MATCH /comment.*exported type U.*should.*form.*"U ..."/
@@ -20,10 +20,10 @@
// V.H has a pointer receiver
-func (*V) H() {} // MATCH /exported method V\.H.*should.*comment/
+func (*V) H() {} // MATCH /exported method V\.H.*should.*comment.*or.*unexport/
-var W = "foo" // MATCH /exported var W.*should.*comment/
+var W = "foo" // MATCH /exported var W.*should.*comment.*or.*unexport/
-const X = "bar" // MATCH /exported const X.*should.*comment/
+const X = "bar" // MATCH /exported const X.*should.*comment.*or.*unexport/
var Y, Z int // MATCH /exported var Y.*own declaration/