Skip to content

cmd/go: eliminate empty '()' when passing -mod=readonly explicitly to… #151

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

Merged
merged 1 commit into from
Feb 12, 2020
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion src/cmd/go/internal/modload/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,9 @@ func Import(path string) (m module.Version, dir string, err error) {
if !pathIsStd {
if cfg.BuildModReason == "" {
queryErr = fmt.Errorf("import lookup disabled by -mod=%s", cfg.BuildMod)
} else {
queryErr = fmt.Errorf("import lookup disabled by -mod=%s\n\t(%s)", cfg.BuildMod, cfg.BuildModReason)
}
queryErr = fmt.Errorf("import lookup disabled by -mod=%s\n\t(%s)", cfg.BuildMod, cfg.BuildModReason)
}
return module.Version{}, "", &ImportMissingError{Path: path, QueryErr: queryErr}
}
Expand Down
1 change: 1 addition & 0 deletions src/cmd/go/testdata/script/mod_readonly.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ go mod edit -fmt
cp go.mod go.mod.empty
! go list all
stderr '^can''t load package: x.go:2:8: cannot find module providing package rsc\.io/quote: import lookup disabled by -mod=readonly'
! stderr '\(\)' # If we don't have a reason for -mod=readonly, don't log an empty one.
cmp go.mod go.mod.empty

# -mod=readonly should be set implicitly if the go.mod file is read-only
Expand Down