Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Go Workspaces when executing 'go list' in packaging process #37579

Merged
merged 3 commits into from
Jan 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions dev-tools/mage/gotool/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,19 @@

// GetModuleName returns the name of the module.
func GetModuleName() (string, error) {
lines, err := getLines(callGo(nil, "list", "-m"))
lines, err := getLines(callGo(
// Disabling the Go workspace prevents 'go list' from listing all
// modules within the workspace.
map[string]string{"GOWORK": "off"},
"list",
"-m"))
if err != nil {
return "", err
}

if len(lines) != 1 {
return "", fmt.Errorf("unexpected number of lines")
return "", fmt.Errorf("expected 'go list -m' to return 1 line, got %d",
len(lines))
}
return lines[0], nil
}
Expand Down Expand Up @@ -217,7 +224,7 @@
}, cmd, args)
}

func runGo(cmd string, args *Args) error {

Check failure on line 227 in dev-tools/mage/gotool/go.go

View workflow job for this annotation

GitHub Actions / lint (darwin)

func `runGo` is unused (unused)
return execGoWith(sh.RunWith, cmd, args)
}

Expand Down
Loading