Skip to content

package-comment-form

Gostyleno fixdefault: offgo/revive

Reports a package comment whose first line does not start with Package and the name of the package. A comment of the right form with a blank line before the package clause is reported as detached. A file of package main is not checked.

Documentation tools read the first sentence of the package comment as the package’s summary, and a fixed form makes the summaries of all packages read the same. A blank line between the comment and the package clause makes the comment a plain comment, not the package’s documentation.

To fix, start with Package name and remove the blank line.

Reported
// Does things.
package a
go:
lint:
rules:
package-comment-form: warn # off (default), warn, error

Enabled by the presets: go/revive.

Suppress one line with sudsy-disable-next-line package-comment-form 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