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: provide way to get list of modules without test only modules #28210

Closed
heppu opened this issue Oct 15, 2018 · 3 comments
Closed

cmd/go: provide way to get list of modules without test only modules #28210

heppu opened this issue Oct 15, 2018 · 3 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@heppu
Copy link

heppu commented Oct 15, 2018

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

go version go1.11.1 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN="/home/heppu/go/bin"
GOCACHE="/home/heppu/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/heppu/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build661079665=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Tried to list all third party modules with version excluding once that are used only for testing.

What did you expect to see?

Some field that would allow me to exclude modules that are used only for testing like this:

go list -mod=vendor -m -f '{{ if not .TestOnly}}{{.Path}} {{.Version}}{{end}}' ...

What did you see instead?

List of all modules my project uses also including test dependencies for third party modules.

Background

Company I'm working for would like to move from glide to go modules because it allows us to update one dependency at a time and and also define rules like:

replace (
	legacy.server.com/some/dep => legacy.server.com/some/dep.git
)

Only problem now is that in CI pipe we need to do some checks for these dependencies that end up in final build and with go modules there is currently no easy way to get this information. I did build small tool with using go/build to get list of these dependencies and then cross reference that with go.mod but to me it feels like this should be part of tooling it self.

@FiloSottile FiloSottile changed the title Provide way to get list of modules without test only modules cmd/go: provide way to get list of modules without test only modules Oct 15, 2018
@FiloSottile FiloSottile added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. modules labels Oct 15, 2018
@FiloSottile FiloSottile added this to the Go1.12 milestone Oct 15, 2018
@FiloSottile
Copy link
Contributor

/cc @bcmills

@myitcv
Copy link
Member

myitcv commented Oct 15, 2018

Probably a dup of #26955?

@myitcv
Copy link
Member

myitcv commented Nov 5, 2018

I'm going to close this as a dup of #26955 but also note that in the meantime you can:

$ go list -deps -f "{{if not .Standard}}{{.Module.Path}}{{end}}" ./... | sort | uniq

You can of course use -mod=vendor with the above, and use any package specification in place of ./....

@myitcv myitcv closed this as completed Nov 5, 2018
@golang golang locked and limited conversation to collaborators Nov 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules 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