File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -226,8 +226,7 @@ func tryUpdateGoModAndGoSum(buildInfo project.BuildInfo) {
226226 beforeGoSumFileInfo , beforeGoSumErr := os .Stat (goSumPath )
227227
228228 // run `go mod tidy -e`
229- cmd := exec .Command ("go" , "mod" , "tidy" , "-e" )
230- cmd .Dir = buildInfo .BaseDir
229+ cmd := toolchain .TidyModule (buildInfo .BaseDir )
231230 res := util .RunCmd (cmd )
232231
233232 if ! res {
@@ -443,9 +442,7 @@ func initGoModForLegacyProject(buildInfo project.BuildInfo) {
443442 return
444443 }
445444
446- modTidy := exec .Command ("go" , "mod" , "tidy" )
447- modTidy .Dir = buildInfo .BaseDir
448-
445+ modTidy := toolchain .TidyModule (buildInfo .BaseDir )
449446 out , err := modTidy .CombinedOutput ()
450447 log .Println (string (out ))
451448
Original file line number Diff line number Diff line change @@ -71,3 +71,10 @@ func parseGoVersion(data string) string {
7171func SupportsWorkspaces () bool {
7272 return semver .Compare (GetEnvGoSemVer (), "v1.18.0" ) >= 0
7373}
74+
75+ // Run `go mod tidy -e` in the directory given by `path`.
76+ func TidyModule (path string ) * exec.Cmd {
77+ cmd := exec .Command ("go" , "mod" , "tidy" , "-e" )
78+ cmd .Dir = path
79+ return cmd
80+ }
You can’t perform that action at this time.
0 commit comments