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: go test prioritises std library packages over local modules #56269

Closed
joerdav opened this issue Oct 17, 2022 · 1 comment
Closed

cmd/go: go test prioritises std library packages over local modules #56269

joerdav opened this issue Oct 17, 2022 · 1 comment

Comments

@joerdav
Copy link

joerdav commented Oct 17, 2022

What version of Go are you using (go version)?

$ go version
go version go1.19 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/joe.davidson/Library/Caches/go-build"
GOENV="/Users/joe.davidson/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/joe.davidson/go/pkg/mod"
GONOPROXY="github.com/aviva-verde"
GONOSUMDB="github.com/aviva-verde"
GOOS="darwin"
GOPATH="/Users/joe.davidson/go"
GOPRIVATE="github.com/aviva-verde"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/nix/store/y22ivsh46ikx5y3ijwadw7s7655c3jn2-go-1.19/opt/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/nix/store/y22ivsh46ikx5y3ijwadw7s7655c3jn2-go-1.19/opt/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/joe.davidson/src/sync/go.mod"
GOWORK=""
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/2m/sl1qb3591xv98xct52dr40nr0000gn/T/go-build2415660171=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Create a module with the same name as a std library package, e.g. sync.

$ go mod init sync
go: creating new go.mod: module sync

$ echo "package somepackage

import \"testing\"

func TestFunc(*testing.T) {
    panic("error")
}" > some_test.go

$ go test ./...

What did you expect to see?

Some error, whether that be a warning that the module has a conflicting name or the test failing.

What did you see instead?

The tests pass, because the test command is actually running sync from the standard library.

$ go test
PASS
ok      sync    1.929s
@mvdan
Copy link
Member

mvdan commented Oct 17, 2022

Duplicate of #26227

@mvdan mvdan marked this as a duplicate of #26227 Oct 17, 2022
@mvdan mvdan closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2022
@golang golang locked and limited conversation to collaborators Oct 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants