Skip to content

Commit 219c168

Browse files
committed
Wrap return values of moveToTemporaryGopath in a struct
1 parent 1bb006f commit 219c168

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

go/extractor/cli/go-autobuilder/go-autobuilder.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,12 @@ func tryUpdateGoModAndGoSum(modMode ModMode, depMode DependencyInstallerMode) {
356356
}
357357
}
358358

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 {
360365
// a temporary directory where everything is moved while the correct
361366
// directory structure is created.
362367
scratch, err := ioutil.TempDir(srcdir, "scratch")
@@ -408,7 +413,7 @@ func moveToTemporaryGopath(srcdir string, importpath string) (string, []string,
408413
log.Fatalf("Failed to rename %s to %s: %s\n", scratch, newdir, err.Error())
409414
}
410415

411-
return scratch, files, realSrc, root, newdir
416+
return moveGopathInfo{scratch, realSrc, root, newdir, files}
412417
}
413418

414419
func createPathTransformerFile(newdir string) *os.File {
@@ -640,16 +645,16 @@ func main() {
640645
inLGTM := os.Getenv("LGTM_SRC") != "" || os.Getenv("LGTM_INDEX_NEED_GOPATH") != ""
641646

642647
if inLGTM && needGopath {
643-
scratch, files, realSrc, root, newdir := moveToTemporaryGopath(srcdir, importpath)
648+
paths := moveToTemporaryGopath(srcdir, importpath)
644649

645650
// 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)
647652

648-
pt := createPathTransformerFile(newdir)
653+
pt := createPathTransformerFile(paths.newdir)
649654
defer os.Remove(pt.Name())
650655

651-
writePathTransformerFile(pt, realSrc, root, newdir)
652-
setGopath(root)
656+
writePathTransformerFile(pt, paths.realSrc, paths.root, paths.newdir)
657+
setGopath(paths.root)
653658
}
654659

655660
// check whether an explicit dependency installation command was provided

0 commit comments

Comments
 (0)