Skip to content

Commit b693037

Browse files
nvartolomeijirfag
authored andcommitted
Allow configure module download mode
1 parent 7dfb9cf commit b693037

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ Flags:
432432
--print-linter-name Print linter name in issue line (default true)
433433
--issues-exit-code int Exit code when issues were found (default 1)
434434
--build-tags strings Build tags
435+
--mod string module download mode to use: readonly or vendor (passed to go list)
435436
--deadline duration Deadline for total work (default 1m0s)
436437
--tests Analyze tests (*_test.go) (default true)
437438
--print-resources-usage Print avg and max memory usage of golangci-lint and total time

pkg/commands/run.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func initFlagSet(fs *pflag.FlagSet, cfg *config.Config, m *lintersdb.Manager) {
6363
fs.IntVar(&rc.ExitCodeIfIssuesFound, "issues-exit-code",
6464
exitcodes.IssuesFound, wh("Exit code when issues were found"))
6565
fs.StringSliceVar(&rc.BuildTags, "build-tags", nil, wh("Build tags"))
66+
fs.StringVar(&rc.Mod, "mod", "", wh("module download mode to use: readonly or vendor (passed to go list)"))
6667
fs.DurationVar(&rc.Deadline, "deadline", time.Minute, wh("Deadline for total work"))
6768
fs.BoolVar(&rc.AnalyzeTests, "tests", true, wh("Analyze tests (*_test.go)"))
6869
fs.BoolVar(&rc.PrintResourcesUsage, "print-resources-usage", false,

pkg/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ type Run struct {
110110
Args []string
111111

112112
BuildTags []string `mapstructure:"build-tags"`
113+
Mod string `mapstructure:"mod"`
113114

114115
ExitCodeIfIssuesFound int `mapstructure:"issues-exit-code"`
115116
AnalyzeTests bool `mapstructure:"tests"`

pkg/lint/load.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,17 @@ func (cl ContextLoader) loadPackages(ctx context.Context, loadMode packages.Load
201201
cl.prepareBuildContext()
202202

203203
var buildFlags []string
204+
204205
if len(cl.cfg.Run.BuildTags) != 0 {
205206
// go help build
206207
buildFlags = []string{"-tags", strings.Join(cl.cfg.Run.BuildTags, " ")}
207208
}
209+
210+
if cl.cfg.Run.Mod != "" {
211+
// go help module
212+
buildFlags = append(buildFlags, fmt.Sprintf("-mod=%s", cl.cfg.Run.Mod))
213+
}
214+
208215
conf := &packages.Config{
209216
Mode: loadMode,
210217
Tests: cl.cfg.Run.AnalyzeTests,

0 commit comments

Comments
 (0)