Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For standalone godoclint, configure rule selection and per-rule options in .godoc-lint.yaml (the README also accepts .godoclint.yaml). Use a source directive for a narrow exception, a top-level directive to disable checks across one file, or an exclude path pattern when a generated or legacy file should not be edited. If godoc-lint runs through golangci-lint, use golangci-lint’s configuration instead: the two configuration schemas differ.

Choose standalone godoc-lint or golangci-lint first

Identify which runner checks your Go code before changing configuration. Standalone godoc-lint reads its own YAML settings. When integrated with golangci-lint, its settings and exclusions belong to golangci-lint’s configuration; standalone keys should not be copied over as if the formats were interchangeable.

Run standalone godoc-lint

From the repository root, run godoclint ./... to check all Go packages. To narrow the target, use a package path such as godoclint ./internal/foo/bar or a subtree such as godoclint ./internal/....

By default, the tool looks for .godoc-lint.yaml in its working directory; the project README also accepts .godoclint.yaml. To choose another file, pass -config, for example godoclint -config the-config-file.yaml ./....

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configuration can be placed in subdirectories. For each processed package, godoc-lint uses a config in that package’s directory if present; otherwise it walks up parent directories toward the root where the linter was invoked. This allows a package or subtree to use a local configuration.

Configure the golangci-lint integration

The godoc-lint project says integration is available in golangci-lint v2.5.0 and later. Its README gives this enablement example:

version: "2"
linters:
  enable:
    - godoclint

This enables the linter; it is not a standalone godoc-lint configuration. Consult the current golangci-lint settings for integrated rule configuration and exclusions. The project README specifically points users toward golangci-lint’s linters.exclusions.rules for excluding test files when appropriate.

Select standalone rules

In standalone configuration, default sets the starting rule set: basic, all, or none. Without an overriding config, the documented default is basic. The basic set enables pkg-doc, single-pkg-doc, start-with-name, and deprecated. Choose all to activate every rule, or none to build a deliberate allowlist with enable. Add or remove rules with the enable and disable lists.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The other documented rules cover these checks:

  • require-doc requires comments for exported symbols and, when configured, unexported symbols.
  • require-pkg-doc requires package documentation.
  • max-len limits rendered godoc line length. Its standalone default is 77 characters, excluding the // , /*, and */ delimiter tokens.
  • no-unused-link detects unused documentation links.
  • require-stdlib-doclink suggests documentation links for standard-library identifiers mentioned as plain text.

Rule-specific settings belong under options. This illustrative standalone configuration combines documented keys; it is not represented as a configuration validated by running the linter:

version: "1.0"
default: basic
enable:
  - require-doc
  - max-len
disable:
  - deprecated
options:
  max-len/length: 88
  max-len/ignore-patterns:
    - "^TODO:"
  require-doc/include-tests: false

In the upstream default configuration, max-len/length is 77 and max-len/ignore-patterns is an empty list. Documented include-tests options default to false. Other documented defaults include start-with-name/include-unexported: false, require-doc/ignore-unexported: true, and require-doc/ignore-exported: false.

Ignore a warning at the narrowest useful scope

One declaration and selected rules

Put the directive in the declaration’s documentation comment group. The syntax requires no space between the comment slashes and the directive:

// This is a constant.
//
godoclint:disable start-with-name
const Foo = 0

Use //godoclint:disable start-with-name in place of the directive line shown above; the required syntax begins with // immediately followed by godoclint:disable. List multiple rule names separated by spaces to suppress several checks for that declaration. If the directive has no rule names, it disables all rules for the declaration’s godoc. Multiple directives are also supported.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Every declaration in one file

To turn off all rules for a file, place //godoclint:disable in a top-level, non-godoc comment group. The project README’s example places it after the package line. This is broader than an exception attached to one declaration.

Generated or legacy paths

When a file should not be edited to add a source directive, use standalone exclude patterns. Standalone include and exclude values are regular expressions matched against paths relative to the configuration file. Use forward slashes in path patterns on every platform, including Windows:

exclude:
  - ^internal/generated/
  - _autogenerated.go$

The upstream default config has include: null and exclude: null, so it applies no explicit path filter. For golangci-lint, configure per-file exclusions in golangci-lint’s own settings instead.

Decide how test files are checked

Most listed standalone rule options skip _test.go files by default. To check tests for a particular rule, set that rule’s .../include-tests: true option. This is configured per rule, so enabling a rule alone does not necessarily make it inspect test files. Alternatively, golangci-lint users may use its path-based exclusions to omit test files.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Standalone pkg-doc automatically exempts command packages named main and their test packages named main_test by default.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use standalone CLI overrides when appropriate

Standalone command-line options can override rule selection and path filters for a run:

  • -default accepts basic, all, or none.
  • Repeat -enable or -disable to select rules.
  • Repeat -include or -exclude to supply regular-expression path filters.

As with YAML path patterns, CLI path patterns should use forward slashes even on Windows.

Match the exception to the problem

  • One declaration triggers one unwanted rule: add a named //godoclint:disable directive to its documentation comment.
  • A whole file must be exempt: use the top-level non-godoc directive.
  • A generated or legacy file should remain untouched: use a standalone exclude regex, or the corresponding golangci-lint exclusion if that is the runner.
  • Only some rules should inspect tests: set each relevant standalone rule’s include-tests option; do not assume rule enablement includes tests.
  • The desired check is missing or overly strict: adjust standalone default, enable, disable, or the relevant options value rather than broadly disabling the file.

The project README and default YAML are on the moving upstream main branch, so configuration can change. The README’s standalone install examples showed v0.11.3 when accessed for this article; check the version installed in your environment if a key or behavior differs. The stated golangci-lint integration milestone is v2.5.0.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.