@@ -356,7 +356,12 @@ func tryUpdateGoModAndGoSum(modMode ModMode, depMode DependencyInstallerMode) {
356
356
}
357
357
}
358
358
359
- func moveToTemporaryGopath (srcdir string , importpath string ) (string , []string , string , string , string ) {
359
+ type moveGopathInfo struct {
360
+ scratch , realSrc , root , newdir string
361
+ files []string
362
+ }
363
+
364
+ func moveToTemporaryGopath (srcdir string , importpath string ) moveGopathInfo {
360
365
// a temporary directory where everything is moved while the correct
361
366
// directory structure is created.
362
367
scratch , err := ioutil .TempDir (srcdir , "scratch" )
@@ -408,7 +413,7 @@ func moveToTemporaryGopath(srcdir string, importpath string) (string, []string,
408
413
log .Fatalf ("Failed to rename %s to %s: %s\n " , scratch , newdir , err .Error ())
409
414
}
410
415
411
- return scratch , files , realSrc , root , newdir
416
+ return moveGopathInfo { scratch , realSrc , root , newdir , files }
412
417
}
413
418
414
419
func createPathTransformerFile (newdir string ) * os.File {
@@ -640,16 +645,16 @@ func main() {
640
645
inLGTM := os .Getenv ("LGTM_SRC" ) != "" || os .Getenv ("LGTM_INDEX_NEED_GOPATH" ) != ""
641
646
642
647
if inLGTM && needGopath {
643
- scratch , files , realSrc , root , newdir := moveToTemporaryGopath (srcdir , importpath )
648
+ paths := moveToTemporaryGopath (srcdir , importpath )
644
649
645
650
// schedule restoring the contents of newdir to their original location after this function completes:
646
- defer restoreRepoLayout (newdir , files , filepath .Base (scratch ), srcdir )
651
+ defer restoreRepoLayout (paths . newdir , paths . files , filepath .Base (paths . scratch ), srcdir )
647
652
648
- pt := createPathTransformerFile (newdir )
653
+ pt := createPathTransformerFile (paths . newdir )
649
654
defer os .Remove (pt .Name ())
650
655
651
- writePathTransformerFile (pt , realSrc , root , newdir )
652
- setGopath (root )
656
+ writePathTransformerFile (pt , paths . realSrc , paths . root , paths . newdir )
657
+ setGopath (paths . root )
653
658
}
654
659
655
660
// check whether an explicit dependency installation command was provided
0 commit comments