Closed as not planned
Description
What version of Go are you using (go version
)?
$ go version go version go1.17.4 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/hajimehoshi/Library/Caches/go-build" GOENV="/Users/hajimehoshi/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/hajimehoshi/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/hajimehoshi/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GOVCS="" GOVERSION="go1.17.4" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/hajimehoshi/test/overlay/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/60/khbk2xqn1c5bml1byjn89dwc0000gn/T/go-build626086560=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
Prepare these files:
go.mod
module foo
foo.go
package foo
var bar = 42
foo_test.go
package foo_test
import (
"testing"
"foo"
)
func TestBar(t *testing.T) {
if foo.Bar != 42 {
t.Error("ng")
}
}
export_test.go
package foo
var Bar = bar
replace.json
{
"Replace": {
"foo.go": "overlay/foo.go",
"foo_test.go": "overlay/foo_test.go",
"export_test.go": "overlay/export_test.go"
}
}
overlay/foo.go
package foo
// Do nothing
overlay/foo_test.go
package foo_test
import (
"testing"
)
func TestBar(t *testing.T) {
// Do nothing
}
overlay/export_test.go
package foo
// Do nothing
And run:
go test -overlay=replace.json
What did you expect to see?
The compile and test succeed.
What did you see instead?
go-vet failed with an odd reason
$ go test -overlay=replace.json .
# foo_test
vet: ./foo_test.go:6:2: could not import foo (can't resolve import "")
FAIL foo [build failed]
FAIL