diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 2c8bcbf76949..5bf58b631c99 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -1453,6 +1453,9 @@ linters: # Defines a pattern to validate `go` minimum version directive. # Default: '' (no match) go-version-pattern: '\d\.\d+(\.0)?' + # Check the validity of the module path. + # Default: false + check-module-path: true gomodguard: allowed: diff --git a/go.mod b/go.mod index 158157f734a7..3a67a19f1c8d 100644 --- a/go.mod +++ b/go.mod @@ -74,7 +74,7 @@ require ( github.com/kunwardeep/paralleltest v1.0.15 github.com/lasiar/canonicalheader v1.1.2 github.com/ldez/exptostd v0.4.5 - github.com/ldez/gomoddirectives v0.7.1 + github.com/ldez/gomoddirectives v0.8.0 github.com/ldez/grignotin v0.10.1 github.com/ldez/tagliatelle v0.7.2 github.com/ldez/usetesting v0.5.0 diff --git a/go.sum b/go.sum index c0f26984411e..4ae8da8cf8e9 100644 --- a/go.sum +++ b/go.sum @@ -386,8 +386,8 @@ github.com/lasiar/canonicalheader v1.1.2 h1:vZ5uqwvDbyJCnMhmFYimgMZnJMjwljN5VGY0 github.com/lasiar/canonicalheader v1.1.2/go.mod h1:qJCeLFS0G/QlLQ506T+Fk/fWMa2VmBUiEI2cuMK4djI= github.com/ldez/exptostd v0.4.5 h1:kv2ZGUVI6VwRfp/+bcQ6Nbx0ghFWcGIKInkG/oFn1aQ= github.com/ldez/exptostd v0.4.5/go.mod h1:QRjHRMXJrCTIm9WxVNH6VW7oN7KrGSht69bIRwvdFsM= -github.com/ldez/gomoddirectives v0.7.1 h1:FaULkvUIG36hj6chpwa+FdCNGZBsD7/fO+p7CCsM6pE= -github.com/ldez/gomoddirectives v0.7.1/go.mod h1:auDNtakWJR1rC+YX7ar+HmveqXATBAyEK1KYpsIRW/8= +github.com/ldez/gomoddirectives v0.8.0 h1:JqIuTtgvFC2RdH1s357vrE23WJF2cpDCPFgA/TWDGpk= +github.com/ldez/gomoddirectives v0.8.0/go.mod h1:jutzamvZR4XYJLr0d5Honycp4Gy6GEg2mS9+2YX3F1Q= github.com/ldez/grignotin v0.10.1 h1:keYi9rYsgbvqAZGI1liek5c+jv9UUjbvdj3Tbn5fn4o= github.com/ldez/grignotin v0.10.1/go.mod h1:UlDbXFCARrXbWGNGP3S5vsysNXAPhnSuBufpTEbwOas= github.com/ldez/tagliatelle v0.7.2 h1:KuOlL70/fu9paxuxbeqlicJnCspCRjH0x8FW+NfgYUk= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index accf61f97455..a6fd05127eb9 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -2220,6 +2220,11 @@ "description": "Defines a pattern to validate `go` minimum version directive.", "type": "string", "default": "" + }, + "check-module-path": { + "description": "Check the validity of the module path.", + "type": "boolean", + "default": false } } }, diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index fefa94ca397b..844affe084c9 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -575,6 +575,7 @@ type GoModDirectivesSettings struct { ToolForbidden bool `mapstructure:"tool-forbidden"` GoDebugForbidden bool `mapstructure:"go-debug-forbidden"` GoVersionPattern string `mapstructure:"go-version-pattern"` + CheckModulePath bool `mapstructure:"check-module-path"` } type GoModGuardSettings struct { diff --git a/pkg/golinters/gomoddirectives/gomoddirectives.go b/pkg/golinters/gomoddirectives/gomoddirectives.go index dd6656fb6cb6..817b5498eeb8 100644 --- a/pkg/golinters/gomoddirectives/gomoddirectives.go +++ b/pkg/golinters/gomoddirectives/gomoddirectives.go @@ -29,6 +29,7 @@ func New(settings *config.GoModDirectivesSettings) *goanalysis.Linter { opts.ToolchainForbidden = settings.ToolchainForbidden opts.ToolForbidden = settings.ToolForbidden opts.GoDebugForbidden = settings.GoDebugForbidden + opts.CheckModulePath = settings.CheckModulePath if settings.ToolchainPattern != "" { exp, err := regexp.Compile(settings.ToolchainPattern)