Skip to content
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

cmd/go: test with -overlay failed with a go-vet error #50044

Open
hajimehoshi opened this issue Dec 8, 2021 · 1 comment
Open

cmd/go: test with -overlay failed with a go-vet error #50044

hajimehoshi opened this issue Dec 8, 2021 · 1 comment

Comments

@hajimehoshi
Copy link
Member

@hajimehoshi hajimehoshi commented Dec 8, 2021

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
@hajimehoshi hajimehoshi changed the title cmd/go: test with -overlay and export failed with go-vet error cmd/go: test with -overlay failed with a go-vet error Dec 8, 2021
@hajimehoshi
Copy link
Member Author

@hajimehoshi hajimehoshi commented Dec 8, 2021

Maybe duplicated with #44957?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants