From e8d1f0139084b8a56990cf9c08b7534afb7c4af5 Mon Sep 17 00:00:00 2001 From: John Reese Date: Thu, 10 Mar 2022 22:38:00 -0500 Subject: [PATCH 1/2] Add module-path setting to gofumpt --- .golangci.example.yml | 4 ++++ pkg/config/linters_settings.go | 2 ++ pkg/golinters/gofumpt.go | 1 + 3 files changed, 7 insertions(+) diff --git a/.golangci.example.yml b/.golangci.example.yml index 9aa6b7cc1364..1fd0d2d28ee4 100644 --- a/.golangci.example.yml +++ b/.golangci.example.yml @@ -511,6 +511,10 @@ linters-settings: # Default: 1.15 lang-version: "1.17" + # Module path which contains the source code being formatted. + # Default: empty string + module-path: "github.com/golangci/golangci-lint" + # Choose whether to use the extra rules. # Default: false extra-rules: true diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index bd5d11897f82..2ae8550e71b4 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -49,6 +49,7 @@ var defaultLintersSettings = LintersSettings{ }, Gofumpt: GofumptSettings{ LangVersion: "", + ModulePath: "", ExtraRules: false, }, Gosec: GoSecSettings{ @@ -311,6 +312,7 @@ type GoFmtSettings struct { type GofumptSettings struct { LangVersion string `mapstructure:"lang-version"` + ModulePath string `mapstructure:"module-path"` ExtraRules bool `mapstructure:"extra-rules"` } diff --git a/pkg/golinters/gofumpt.go b/pkg/golinters/gofumpt.go index 455572d6ebc2..f0523459f4cc 100644 --- a/pkg/golinters/gofumpt.go +++ b/pkg/golinters/gofumpt.go @@ -37,6 +37,7 @@ func NewGofumpt() *goanalysis.Linter { options := format.Options{ LangVersion: getLangVersion(settings), + ModulePath: settings.ModulePath, ExtraRules: settings.ExtraRules, } From 6212a75e50c4c7f139326b754278a50dcbb3c1b8 Mon Sep 17 00:00:00 2001 From: John Reese Date: Fri, 11 Mar 2022 09:01:19 -0500 Subject: [PATCH 2/2] Update .golangci.example.yml Co-authored-by: Ludovic Fernandez --- .golangci.example.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.example.yml b/.golangci.example.yml index 1fd0d2d28ee4..949f9ef04719 100644 --- a/.golangci.example.yml +++ b/.golangci.example.yml @@ -513,7 +513,7 @@ linters-settings: # Module path which contains the source code being formatted. # Default: empty string - module-path: "github.com/golangci/golangci-lint" + module-path: github.com/org/project # Choose whether to use the extra rules. # Default: false