diff --git a/src/cmd/go/testdata/script/build_relative_import_not_supported_in_go_path_mode.txt b/src/cmd/go/testdata/script/build_relative_import_not_supported_in_go_path_mode.txt index 4959ed77b47..4c21f1c9c2e 100644 --- a/src/cmd/go/testdata/script/build_relative_import_not_supported_in_go_path_mode.txt +++ b/src/cmd/go/testdata/script/build_relative_import_not_supported_in_go_path_mode.txt @@ -1,11 +1,27 @@ env GO111MODULE=off -! go build -stderr 'cannot find package "\." in:\n\t.WORK/gopath/src/foo' +# Control case: in GOPATH mode, +# a/a.go can import package "./b" using a relative path. +go build a/a.go +! stderr . --- main.go -- -package main +# package "a" itself cannot import "./b": "a" has a non-local +# import path, so its imports must also have non-local import paths. +! go build a +stderr '^a[/\\]a.go:3:8: local import "./b" in non-local package$' -import _ "./foo" +# package "c" imports itself, which is not allowed. +! go build c +stderr '^c[/\\]c.go:3:8: .: cannot import current directory$' -func main() {} + +-- a/a.go -- +package a + +import _ "./b" +-- a/b/b.go -- +package b +-- c/c.go -- +package c + +import _ "." \ No newline at end of file