From 5a978d7482f39eb51d7fa7ed5e463b8690e52cad Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Sat, 11 Feb 2023 14:15:34 +0200 Subject: [PATCH 1/2] docs: Replace godoc.org with pkg.go.dev - Replace golang.org with go.dev. - Replace godoc.org with pkg.go.dev. --- docs/src/docs/contributing/architecture.mdx | 8 ++++---- docs/src/docs/contributing/workflow.mdx | 4 ++-- docs/src/docs/usage/configuration.mdx | 2 +- docs/src/docs/usage/performance.mdx | 2 +- internal/renameio/renameio.go | 2 +- internal/renameio/renameio_test.go | 2 +- pkg/lint/lintersdb/manager.go | 6 +++--- pkg/result/processors/autogenerated_exclude.go | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/src/docs/contributing/architecture.mdx b/docs/src/docs/contributing/architecture.mdx index eb372bab4b4b..5a48b3d3e340 100644 --- a/docs/src/docs/contributing/architecture.mdx +++ b/docs/src/docs/contributing/architecture.mdx @@ -126,7 +126,7 @@ func (cl *ContextLoader) Load(ctx context.Context, linters []*linter.Config) (*l ``` First, we find a load mode as union of load modes for all enabled linters. -We use [go/packages](https://godoc.org/golang.org/x/tools/go/packages) for packages loading and use it's enum `packages.Need*` for load modes. +We use [go/packages](https://pkg.go.dev/golang.org/x/tools/go/packages) for packages loading and use it's enum `packages.Need*` for load modes. Load mode sets which data does a linter needs for execution. A linter that works only with AST need minimum of information: only filenames and AST. There is no need for @@ -165,7 +165,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { WithLoadForGoAnalysis(). WithPresets(linter.PresetBugs). WithAlternativeNames("vet", "vetshadow"). - WithURL("https://golang.org/cmd/vet/"), + WithURL("https://pkg.go.dev/cmd/vet"), linter.NewConfig(golinters.NewBodyclose()). WithLoadForGoAnalysis(). WithPresets(linter.PresetPerformance, linter.PresetBugs). @@ -208,10 +208,10 @@ Currently, all linters except `unused` can be merged into this meta linter. The `unused` isn't merged because it has high memory usage. Linters execution starts in `runAnalyzers`. It's the most complex part of the `golangci-lint`. -We use custom [go/analysis](https://godoc.org/golang.org/x/tools/go/analysis) runner there. It runs as much as it can in parallel. It lazy-loads as much as it can +We use custom [go/analysis](https://pkg.go.dev/golang.org/x/tools/go/analysis) runner there. It runs as much as it can in parallel. It lazy-loads as much as it can to reduce memory usage. Also, it sets all heavyweight data to `nil` as becomes unneeded to save memory. -We don't use existing [multichecker](https://godoc.org/golang.org/x/tools/go/analysis/multichecker) because +We don't use existing [multichecker](https://pkg.go.dev/golang.org/x/tools/go/analysis/multichecker) because it doesn't use caching and doesn't have some important performance optimizations. All found by linters issues are represented with `result.Issue` struct: diff --git a/docs/src/docs/contributing/workflow.mdx b/docs/src/docs/contributing/workflow.mdx index afe9623dcaae..a6e8531a6d66 100644 --- a/docs/src/docs/contributing/workflow.mdx +++ b/docs/src/docs/contributing/workflow.mdx @@ -9,12 +9,12 @@ conduct](https://github.com/golangci/golangci-lint/blob/master/CODE_OF_CONDUCT.m ## Setup your machine -`golangci-lint` is written in [Go](https://golang.org/). +`golangci-lint` is written in [Go](https://go.dev). Prerequisites: - `make` -- [Go](https://golang.org/doc/install) +- [Go](https://go.dev/doc/install) Fork and clone [golangci-lint](https://github.com/golangci/golangci-lint) repository. diff --git a/docs/src/docs/usage/configuration.mdx b/docs/src/docs/usage/configuration.mdx index dfdbd17c72a2..d3bdfd3e107e 100644 --- a/docs/src/docs/usage/configuration.mdx +++ b/docs/src/docs/usage/configuration.mdx @@ -48,6 +48,6 @@ the `go tool trace` command and visualization tool. ## Cache -GolangCI-Lint stores its cache in the subdirectory `golangci-lint` inside the [default user cache directory](https://golang.org/pkg/os/#UserCacheDir). +GolangCI-Lint stores its cache in the subdirectory `golangci-lint` inside the [default user cache directory](https://pkg.go.dev/os#UserCacheDir). You can override the default cache directory with the environment variable `GOLANGCI_LINT_CACHE`; the path must be absolute. diff --git a/docs/src/docs/usage/performance.mdx b/docs/src/docs/usage/performance.mdx index 06e6b5c73cbb..28b890349b8f 100644 --- a/docs/src/docs/usage/performance.mdx +++ b/docs/src/docs/usage/performance.mdx @@ -4,7 +4,7 @@ title: Performance ## Memory Usage -A trade-off between memory usage and execution time can be controlled by [`GOGC`](https://golang.org/pkg/runtime/#hdr-Environment_Variables) environment variable. +A trade-off between memory usage and execution time can be controlled by [`GOGC`](https://pkg.go.dev/runtime#hdr-Environment_Variables) environment variable. Less `GOGC` values trigger garbage collection more frequently and golangci-lint consumes less memory and more CPU. Below is the trade-off table for running on this repo: | `GOGC` | Peak Memory, GB | Execution Time, s | diff --git a/internal/renameio/renameio.go b/internal/renameio/renameio.go index 2f88f4f7cc5a..bd08f0b2f068 100644 --- a/internal/renameio/renameio.go +++ b/internal/renameio/renameio.go @@ -55,7 +55,7 @@ func WriteToFile(filename string, data io.Reader, perm os.FileMode) (err error) } // Sync the file before renaming it: otherwise, after a crash the reader may // observe a 0-length file instead of the actual contents. - // See https://golang.org/issue/22397#issuecomment-380831736. + // See https://go.dev/issue/22397#issuecomment-380831736. if err := f.Sync(); err != nil { return err } diff --git a/internal/renameio/renameio_test.go b/internal/renameio/renameio_test.go index 0f8dd3489760..17b51e43adbc 100644 --- a/internal/renameio/renameio_test.go +++ b/internal/renameio/renameio_test.go @@ -136,7 +136,7 @@ func TestConcurrentReadsAndWrites(t *testing.T) { case "darwin": // The filesystem on macOS 10.14 occasionally fails with "no such file or - // directory" errors. See https://golang.org/issue/33041. The flake rate is + // directory" errors. See https://go.dev/issue/33041. The flake rate is // fairly low, so ensure that at least 75% of attempts succeed. minReadSuccesses = attempts - (attempts / 4) } diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index 03f898cefe7c..6f406f7d26e3 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -497,7 +497,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { WithSince("v1.0.0"). WithPresets(linter.PresetFormatting). WithAutoFix(). - WithURL("https://golang.org/cmd/gofmt/"), + WithURL("https://pkg.go.dev/cmd/gofmt"), linter.NewConfig(golinters.NewGofumpt(gofumptCfg)). WithSince("v1.28.0"). @@ -514,7 +514,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { WithSince("v1.20.0"). WithPresets(linter.PresetFormatting, linter.PresetImport). WithAutoFix(). - WithURL("https://godoc.org/golang.org/x/tools/cmd/goimports"), + WithURL("https://pkg.go.dev/golang.org/x/tools/cmd/goimports"), linter.NewConfig(golinters.NewGolint(golintCfg)). WithSince("v1.0.0"). @@ -562,7 +562,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { WithLoadForGoAnalysis(). WithPresets(linter.PresetBugs, linter.PresetMetaLinter). WithAlternativeNames("vet", "vetshadow"). - WithURL("https://golang.org/cmd/vet/"), + WithURL("https://pkg.go.dev/cmd/vet"), linter.NewConfig(golinters.NewGrouper(grouperCfg)). WithSince("v1.44.0"). diff --git a/pkg/result/processors/autogenerated_exclude.go b/pkg/result/processors/autogenerated_exclude.go index bc6ba30e67ba..5e41fd6a94d3 100644 --- a/pkg/result/processors/autogenerated_exclude.go +++ b/pkg/result/processors/autogenerated_exclude.go @@ -70,7 +70,7 @@ func (p *AutogeneratedExclude) shouldPassIssue(i *result.Issue) (bool, error) { } // isGenerated reports whether the source file is generated code. -// Using a bit laxer rules than https://golang.org/s/generatedcode to +// Using a bit laxer rules than https://go.dev/s/generatedcode to // match more generated code. See #48 and #72. func isGeneratedFileByComment(doc string) bool { const ( From c69407958858f4b99a8a1527e73e0e7e7957f4f8 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 11 Feb 2023 14:47:12 +0100 Subject: [PATCH 2/2] revert: no modification allowed inside the internal package --- internal/renameio/renameio.go | 2 +- internal/renameio/renameio_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/renameio/renameio.go b/internal/renameio/renameio.go index bd08f0b2f068..2f88f4f7cc5a 100644 --- a/internal/renameio/renameio.go +++ b/internal/renameio/renameio.go @@ -55,7 +55,7 @@ func WriteToFile(filename string, data io.Reader, perm os.FileMode) (err error) } // Sync the file before renaming it: otherwise, after a crash the reader may // observe a 0-length file instead of the actual contents. - // See https://go.dev/issue/22397#issuecomment-380831736. + // See https://golang.org/issue/22397#issuecomment-380831736. if err := f.Sync(); err != nil { return err } diff --git a/internal/renameio/renameio_test.go b/internal/renameio/renameio_test.go index 17b51e43adbc..0f8dd3489760 100644 --- a/internal/renameio/renameio_test.go +++ b/internal/renameio/renameio_test.go @@ -136,7 +136,7 @@ func TestConcurrentReadsAndWrites(t *testing.T) { case "darwin": // The filesystem on macOS 10.14 occasionally fails with "no such file or - // directory" errors. See https://go.dev/issue/33041. The flake rate is + // directory" errors. See https://golang.org/issue/33041. The flake rate is // fairly low, so ensure that at least 75% of attempts succeed. minReadSuccesses = attempts - (attempts / 4) }