Closed
Description
The following program fails in both go1.14rc1 and go1.13.7 darwin/amd64.
package main
import (
"fmt"
"github.com/bep/testmodlib"
"github.com/bep/testmodlib/somepackage"
"github.com/bep/testmodlib/somepackage/vendor"
"github.com/bep/testmodlib/somepackage/vendors"
)
func main() {
fmt.Println(testmodlib.Hello())
fmt.Println(somepackage.Hello())
fmt.Println(vendor.Hello())
fmt.Println(vendors.Hello())
}
Fails with:
build github.com/bep/temp: cannot load github.com/bep/testmodlib/somepackage/vendor: module github.com/bep/testmodlib@latest found (v1.0.1), but does not contain package github.com/bep/testmodlib/somepackage/vendor
If I add a replace directive for that module:
replace github.com/bep/testmodlib => /Users/bep/dev/go/bep/testmodlib
It compiles/runs fine:
testmodlib
somepackage
vendor package
vendors package
I understand that the vendor top level folder in a module has a special meaning, but according to https://golang.org/ref/spec#Packages that package name should be fine -- and just deleting it sounds rather harsh.
I assume this is related to #31562 -- I have not read that one in detail, but I don't see how the conclusion can be correct.
github.com/bep/testmodlib/somepackage/vendor
seem to be a valid package with a replace, and I assume that the compiler works as expected here.- Also, a module may contain non-Go folders (test resources etc. to make the test pass).