diff --git a/README.md b/README.md index e7f4be6bbc51..eb0af9d218aa 100644 --- a/README.md +++ b/README.md @@ -924,6 +924,15 @@ Also, you can exclude all issues in a file by: package pkg ``` +You may add a comment explaining or justifying why `//nolint` is being used on the same line as the flag itself: + +```go +//nolint:gocyclo // This legacy function is complex but the team too busy to simplify it +func someLegacyFunction() *string { + // ... +} +``` + You can see more examples of using `//nolint` in [our tests](https://github.com/golangci/golangci-lint/tree/master/pkg/result/processors/testdata) for it. Use `//nolint` instead of `// nolint` because machine-readable comments should have no space by Go convention. diff --git a/README.tmpl.md b/README.tmpl.md index 0649b1fadbf0..91b7c24cc17f 100644 --- a/README.tmpl.md +++ b/README.tmpl.md @@ -471,6 +471,15 @@ Also, you can exclude all issues in a file by: package pkg ``` +You may add a comment explaining or justifying why `//nolint` is being used on the same line as the flag itself: + +```go +//nolint:gocyclo // This legacy function is complex but the team too busy to simplify it +func someLegacyFunction() *string { + // ... +} +``` + You can see more examples of using `//nolint` in [our tests](https://github.com/golangci/golangci-lint/tree/master/pkg/result/processors/testdata) for it. Use `//nolint` instead of `// nolint` because machine-readable comments should have no space by Go convention.