Skip to content

Commit c6ffc11

Browse files
committed
fix: add -mod flag in GOFLAGS.
1 parent b3491fd commit c6ffc11

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/lint/load.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ func (cl *ContextLoader) makeBuildFlags() ([]string, error) {
116116
return nil, fmt.Errorf("invalid modules download path %s, only (%s) allowed", mod, strings.Join(allowedMods, "|"))
117117
}
118118

119+
// https://github.com/golangci/golangci-lint/issues/1502#issuecomment-752105778
120+
raw := os.Getenv("GOFLAGS")
121+
goflags := strings.Fields(raw)
122+
goflags = append(goflags, fmt.Sprintf("-mod=%s", mod))
123+
_ = os.Setenv("GOFLAGS", strings.Join(goflags, " "))
124+
119125
buildFlags = append(buildFlags, fmt.Sprintf("-mod=%s", cl.cfg.Run.ModulesDownloadMode))
120126
}
121127

0 commit comments

Comments
 (0)