func (e *ImportMissingError) Error() string {
if e.Module.Path == "" {
if e.isStd {
- msg := fmt.Sprintf("package %s is not in GOROOT (%s)", e.Path, filepath.Join(cfg.GOROOT, "src", e.Path))
+ msg := fmt.Sprintf("package %s is not in std (%s)", e.Path, filepath.Join(cfg.GOROOT, "src", e.Path))
if e.importerGoVersion != "" {
msg += fmt.Sprintf("\nnote: imported by a module that requires go %s", e.importerGoVersion)
}
# a clear error in module mode.
! go list cmd/unknown
-stderr '^package cmd/unknown is not in GOROOT \('$GOROOT'[/\\]src[/\\]cmd[/\\]unknown\)$'
+stderr '^package cmd/unknown is not in std \('$GOROOT'[/\\]src[/\\]cmd[/\\]unknown\)$'
go list -f '{{range .DepsErrors}}{{.Err}}{{end}}' x.go
-stdout '^package cmd/unknown is not in GOROOT \('$GOROOT'[/\\]src[/\\]cmd[/\\]unknown\)$'
+stdout '^package cmd/unknown is not in std \('$GOROOT'[/\\]src[/\\]cmd[/\\]unknown\)$'
-- x.go --
package x
cp go.mod.orig go.mod
! go list example
-stderr '^package example is not in GOROOT \(.*\)$'
+stderr '^package example is not in std \(.*\)$'
! go get example
stderr '^go: malformed module path "example": missing dot in first path element$'
! go build -mod=readonly nonexist
! stderr 'import lookup disabled'
! stderr 'missing dot'
-stderr '^package nonexist is not in GOROOT \('$GOROOT'[/\\]src[/\\]nonexist\)$'
+stderr '^package nonexist is not in std \('$GOROOT'[/\\]src[/\\]nonexist\)$'
! go build nonexist
! stderr 'import lookup disabled'
! stderr 'missing dot'
-stderr '^package nonexist is not in GOROOT \('$GOROOT'[/\\]src[/\\]nonexist\)$'
+stderr '^package nonexist is not in std \('$GOROOT'[/\\]src[/\\]nonexist\)$'
# Building a nonexistent std package indirectly should also fail usefully.
! go build -mod=readonly ./importnonexist
! stderr 'import lookup disabled'
! stderr 'missing dot'
-stderr '^importnonexist[/\\]x.go:2:8: package nonexist is not in GOROOT \('$GOROOT'[/\\]src[/\\]nonexist\)$'
+stderr '^importnonexist[/\\]x.go:2:8: package nonexist is not in std \('$GOROOT'[/\\]src[/\\]nonexist\)$'
! go build ./importnonexist
! stderr 'import lookup disabled'
! stderr 'missing dot'
-stderr '^importnonexist[/\\]x.go:2:8: package nonexist is not in GOROOT \('$GOROOT'[/\\]src[/\\]nonexist\)$'
+stderr '^importnonexist[/\\]x.go:2:8: package nonexist is not in std \('$GOROOT'[/\\]src[/\\]nonexist\)$'
# Building an *actual* std package should fail if GOROOT is set to something bogus.
! go build ./importjson
! stderr 'import lookup disabled'
! stderr 'missing dot'
-stderr 'importjson[/\\]x.go:2:8: package encoding/json is not in GOROOT \('$WORK'[/\\]not-a-valid-goroot[/\\]src[/\\]encoding[/\\]json\)$'
+stderr 'importjson[/\\]x.go:2:8: package encoding/json is not in std \('$WORK'[/\\]not-a-valid-goroot[/\\]src[/\\]encoding[/\\]json\)$'
-- go.mod --
module example.com
cd ../c
! go build -mod=vendor
-stderr 'main.go:4:5: package p is not in GOROOT'
+stderr 'main.go:4:5: package p is not in std'
-- a/go.mod --
module image
# import is missing. See golang.org/issue/48966.
! go build .
-stderr '^main.go:3:8: package nonexistent is not in GOROOT \(.*\)$'
+stderr '^main.go:3:8: package nonexistent is not in std \(.*\)$'
stderr '^note: imported by a module that requires go 1.99999$'
-- go.mod --
# 'go mod tidy' and 'go mod vendor' should not hide loading errors.
! go mod tidy
-! stderr 'package nonexist is not in GOROOT'
+! stderr 'package nonexist is not in std'
stderr '^issue27063 imports\n\tnonexist.example.com: cannot find module providing package nonexist.example.com'
stderr '^issue27063 imports\n\tissue27063/other imports\n\tother.example.com/nonexist: cannot find module providing package other.example.com/nonexist'
! go mod vendor
-! stderr 'package nonexist is not in GOROOT'
+! stderr 'package nonexist is not in std'
stderr '^issue27063 imports\n\tnonexist.example.com: no required module provides package nonexist.example.com; to add it:\n\tgo get nonexist.example.com$'
stderr '^issue27063 imports\n\tissue27063/other imports\n\tother.example.com/nonexist: no required module provides package other.example.com/nonexist; to add it:\n\tgo get other.example.com/nonexist$'
go list -mod=mod -f {{.Dir}} w
stdout 'src[\\/]w'
! go list -mod=vendor -f {{.Dir}} w
-stderr 'package w is not in GOROOT'
+stderr 'package w is not in std'
go list -mod=mod -f {{.Dir}} diamondright
stdout 'src[\\/]diamondright'
errOk := (err != nil && strings.HasPrefix(err.Error(), "cannot find package"))
wantErr := `"cannot find package" error`
if test.srcDir == "" {
- if err != nil && strings.Contains(err.Error(), "is not in GOROOT") {
+ if err != nil && strings.Contains(err.Error(), "is not in std") {
errOk = true
}
- wantErr = `"cannot find package" or "is not in GOROOT" error`
+ wantErr = `"cannot find package" or "is not in std" error`
}
if !errOk {
t.Errorf("%s got error: %q, want %s", test.label, err, wantErr)