From 8b1a0f486045dbb56301e5fa7c5bb2296714a9e2 Mon Sep 17 00:00:00 2001 From: Dave Rolsky Date: Mon, 3 Feb 2025 11:45:41 -0600 Subject: [PATCH] Add reference to golangci-lint & nogo in `intro.md` and add nogo in `lint.md` --- CHANGELOG-MongoDB.md | 1 + src/intro.md | 6 ++++++ src/lint.md | 6 +++++- style.md | 7 ++++++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG-MongoDB.md b/CHANGELOG-MongoDB.md index 4d118a6..b9511d6 100644 --- a/CHANGELOG-MongoDB.md +++ b/CHANGELOG-MongoDB.md @@ -6,4 +6,5 @@ intro to use `gofumpt` instead. - Added a recommendation to use `gopls` in general, and specifically to configure your editor to use it to update imports. +- Added recommendations to use `golangci-lint` or `nogo` for linting orchestration. diff --git a/src/intro.md b/src/intro.md index 0611843..f431247 100644 --- a/src/intro.md +++ b/src/intro.md @@ -38,6 +38,12 @@ recommend setting up your editor to: - Run `gofumpt` on save - Run `revive` and `go vet` to check for errors +Note that you may wish to use [golangci-lint] or Bazel's [nogo] to run `gofumpt`, `revive`, and `go +vet` instead of running each one separately. + + [golangci-lint]: https://golangci-lint.run/ + [nogo]: https://github.com/bazel-contrib/rules_go/blob/master/go/nogo.rst + You can find information in editor support for Go tools here: diff --git a/src/lint.md b/src/lint.md index 62306d0..6e5ec7e 100644 --- a/src/lint.md +++ b/src/lint.md @@ -21,7 +21,10 @@ quality without being unnecessarily prescriptive: ## Lint Runners -We recommend [golangci-lint] as the go-to lint runner for Go code, largely due +For projects which use Bazel, you should use [nogo] instead of [golangci-lint], as [golangci-lint] +does not work well with Bazel's sandboxing. + +Otherwise, we recommend [golangci-lint] as the go-to lint runner for Go code, largely due to its performance in larger codebases and ability to configure and use many canonical linters at once. This repo has an example [.golangci.yml] config file with recommended linters and settings. @@ -30,6 +33,7 @@ golangci-lint has [various linters] available for use. The above linters are recommended as a base set, and we encourage teams to add any additional linters that make sense for their projects. + [nogo]: https://github.com/bazel-contrib/rules_go/blob/master/go/nogo.rst [golangci-lint]: https://github.com/golangci/golangci-lint [.golangci.yml]: https://github.com/uber-go/guide/blob/master/.golangci.yml [various linters]: https://golangci-lint.run/usage/linters/ diff --git a/style.md b/style.md index 2b20a39..e3af175 100644 --- a/style.md +++ b/style.md @@ -107,6 +107,8 @@ recommend setting up your editor to: - Run `gofumpt` on save - Run `revive` and `go vet` to check for errors +Note that you may wish to use [golangci-lint](https://golangci-lint.run/) or Bazel's [nogo](https://github.com/bazel-contrib/rules_go/blob/master/go/nogo.rst) to run `gofumpt`, `revive`, and `go vet` instead of running each one separately. + You can find information in editor support for Go tools here: https://go.dev/wiki/IDEsAndTextEditorPlugins @@ -4109,7 +4111,10 @@ quality without being unnecessarily prescriptive: ### Lint Runners -We recommend [golangci-lint](https://github.com/golangci/golangci-lint) as the go-to lint runner for Go code, largely due +For projects which use Bazel, you should use [nogo](https://github.com/bazel-contrib/rules_go/blob/master/go/nogo.rst) instead of [golangci-lint](https://github.com/golangci/golangci-lint), as [golangci-lint](https://github.com/golangci/golangci-lint) +does not work well with Bazel's sandboxing. + +Otherwise, we recommend [golangci-lint](https://github.com/golangci/golangci-lint) as the go-to lint runner for Go code, largely due to its performance in larger codebases and ability to configure and use many canonical linters at once. This repo has an example [.golangci.yml](https://github.com/uber-go/guide/blob/master/.golangci.yml) config file with recommended linters and settings.