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

Closed
hajimehoshi opened this issue Dec 8, 2021 · 2 comments
Closed

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

hajimehoshi opened this issue Dec 8, 2021 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@hajimehoshi
Copy link
Member

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

Maybe duplicated with #44957?

@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 8, 2021
@matloob matloob assigned matloob and unassigned matloob Jan 21, 2022
@seankhliao
Copy link
Member

Duplicate of #44957

@seankhliao seankhliao marked this as a duplicate of #44957 Aug 20, 2022
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Aug 20, 2022
@golang golang locked and limited conversation to collaborators Aug 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants