diff --git a/dev-tools/mage/gotool/go.go b/dev-tools/mage/gotool/go.go index 5cf5c684d8b..b784cf53299 100644 --- a/dev-tools/mage/gotool/go.go +++ b/dev-tools/mage/gotool/go.go @@ -45,12 +45,18 @@ var Test goTest = runGoTest // 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 workspaces 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 }