Skip to content

Commit 18d7dbd

Browse files
author
Jay Conrod
committed
cmd/gorelease: use -mod=mod when listing packages
This fixes test failures when gorelease is used with the tip Go 1.16. For golang/go#41456 Change-Id: I9a1452518113f595d9c94fb394f0aecbcc80b95f Reviewed-on: https://go-review.googlesource.com/c/exp/+/255597 Trust: Jay Conrod <[email protected]> Trust: Jean de Klerk <[email protected]> Run-TryBot: Jay Conrod <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Jean de Klerk <[email protected]>
1 parent 20d5ce0 commit 18d7dbd

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

cmd/gorelease/gorelease.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,20 @@ func loadPackages(modPath, modRoot, loadDir string, goModData, goSumData []byte)
909909
// We can't just load example.com/mod/... because that might include packages
910910
// in nested modules. We also can't filter packages from the output of
911911
// packages.Load, since it doesn't tell us which module they came from.
912+
//
913+
// TODO(golang.org/issue/41456): this command fails in -mod=readonly mode
914+
// if sums are missing, which they always are for downloaded modules. In
915+
// Go 1.16, -mod=readonly is the default, and -mod=mod may eventually be
916+
// removed, so we should avoid -mod=mod here. Lazy loading may also require
917+
// changes to temporary module requirements.
918+
//
919+
// Instead of running this command, we should make a list of importable
920+
// packages by walking the directory tree. With such a list,
921+
// in prepareLoadDir, we could generate a temporary package that imports
922+
// all of them, then 'go get -d' that package to ensure no requirements
923+
// or sums are missing.
912924
format := fmt.Sprintf(`{{if .Module}}{{if eq .Module.Path %q}}{{.ImportPath}}{{end}}{{end}}`, modPath)
913-
cmd := exec.Command("go", "list", "-e", "-f", format, "--", modPath+"/...")
925+
cmd := exec.Command("go", "list", "-mod=mod", "-e", "-f", format, "--", modPath+"/...")
914926
cmd.Dir = loadDir
915927
out, err := cmd.Output()
916928
if err != nil {

0 commit comments

Comments
 (0)