Skip to content

missing-package-comment

Gostyleno fixdefault: offgo/revive

Reports a package that has no comment right above the package clause in any file of its directory. The report is made once per directory, at the package keyword of the first file by name (a test file too). A test file or a file with a detached comment counts for the comment where it has one, and never causes the report. The files of the directory are read even when only some are linted; the rule is silent when one of them does not parse.

The package comment is the first thing go doc and the package index show, and it tells a reader what the package is for. A package without one is listed with no description.

To fix, add a comment of the form // Package name does ... right above the package clause of one file.

Reported
package a
func F() {}
go:
lint:
rules:
missing-package-comment: warn # off (default), warn, error

Enabled by the presets: go/revive.

Suppress one line with sudsy-disable-next-line missing-package-comment in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
revive package-comments partial 52 findings are missed where a generated or build-excluded sibling that revive does not load holds the first file name or the only comment