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

x/tools/go/packages: unclear how to distinguish test packages #38744

Open
willfaught opened this issue Apr 29, 2020 · 2 comments
Open

x/tools/go/packages: unclear how to distinguish test packages #38744

willfaught opened this issue Apr 29, 2020 · 2 comments

Comments

@willfaught
Copy link
Contributor

@willfaught willfaught commented Apr 29, 2020

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

$ go version
go version go1.14.2 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="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/Will/Library/Caches/go-build"
GOENV="/Users/Will/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/Will/Developer/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14.2_1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.2_1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/Will/Developer/turbine/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 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bx/qk0phsxd265fqj512dnnpg080000gn/T/go-build418939867=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

$ go doc golang.org/x/tools/go/packages

If you set Config.Tests=true, it isn't clear how to distinguish which package is the test package and which is the normal package. For example, here are the package names and paths for the four Packages returned for the "net/http" query:

  1. http, net/http
  2. main, net/http.test
  3. http, net/http
  4. http_test, net/http_test

Note that 1 and 3 are identical. Since Package IDs are meant to be opaque, according to the doc, I'm at a loss for how to distinguish between these two cases. I could look for GoFiles ending in "_test.go" in each Package, but that seems hacky and requires adding NeedFiles to Config.Mode.

@gopherbot gopherbot added this to the Unreleased milestone Apr 29, 2020
@myitcv
Copy link
Member

@myitcv myitcv commented Apr 29, 2020

cc @matloob

See also #38445 and friends.

@matloob
Copy link
Contributor

@matloob matloob commented May 1, 2020

Yeah, I think #38445 is the most likely solution to this, if we solve it.

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
5 participants