Skip to content

Commit 96ea41e

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

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/lint/load.go

+5
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ 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+
goflags := strings.Fields(os.Getenv("GOFLAGS"))
121+
goflags = append(goflags, fmt.Sprintf("-mod=%s", mod))
122+
_ = os.Setenv("GOFLAGS", strings.Join(goflags, " "))
123+
119124
buildFlags = append(buildFlags, fmt.Sprintf("-mod=%s", cl.cfg.Run.ModulesDownloadMode))
120125
}
121126

0 commit comments

Comments
 (0)