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 get -t do not install packages #18315

Closed
powerman opened this issue Dec 14, 2016 · 1 comment
Closed

cmd/go: go get -t do not install packages #18315

powerman opened this issue Dec 14, 2016 · 1 comment
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@powerman
Copy link

Please answer these questions before submitting your issue. Thanks!

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

go version go1.7.4 linux/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/tmp/build/a94a8fe5"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build834793487=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

What did you do?

go get -v -t ./proto/apns/

What did you expect to see?

Packages required for running tests not only downloaded, but also installed.

What did you see instead?

proto/apns# cat init_test.go 
package apns

import (
	"testing"

	. "gopkg.in/check.v1"
)

func Test(t *testing.T) { TestingT(t) }
proto/apns# ls -l $GOPATH/pkg/linux_amd64/gopkg.in/check.v1.a
ls: cannot access /tmp/build/a94a8fe5/pkg/linux_amd64/gopkg.in/check.v1.a: No such file or directory
proto/apns# go get -v -t .
proto/apns# ls -l $GOPATH/pkg/linux_amd64/gopkg.in/check.v1.a
ls: cannot access /tmp/build/a94a8fe5/pkg/linux_amd64/gopkg.in/check.v1.a: No such file or directory
proto/apns# go get -v gopkg.in/check.v1
gopkg.in/check.v1
proto/apns# ls -l $GOPATH/pkg/linux_amd64/gopkg.in/check.v1.a
-rw-r--r-- 1 root root 400968 Dec 14 19:28 /tmp/build/a94a8fe5/pkg/linux_amd64/gopkg.in/check.v1.a

Real reason why I need it to be installed is because golang.org/x/tools/cmd/gotype fails if it's not installed (so maybe this should be fixed in gotype instead of go get):

proto/apns# rm $GOPATH/pkg/linux_amd64/gopkg.in/check.v1.a
proto/apns# gotype -a .
init_test.go:6:4: could not import gopkg.in/check.v1 (can't find import: gopkg.in/check.v1)
proto/apns# go get -v gopkg.in/check.v1
gopkg.in/check.v1
proto/apns# gotype -a .
proto/apns#
@bradfitz bradfitz changed the title go get -t do not install packages cmd/go: go get -t do not install packages Dec 14, 2016
@bradfitz bradfitz added this to the Go1.9 milestone Dec 14, 2016
@bradfitz bradfitz added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 14, 2016
@rsc
Copy link
Contributor

rsc commented Jun 22, 2017

I think this is working as documented:

$ go help get
usage: go get [-d] [-f] [-fix] [-insecure] [-t] [-u] [build flags] [packages]

Get downloads the packages named by the import paths, along with their
dependencies. It then installs the named packages, like 'go install'.

...

The -t flag instructs get to also download the packages required to build
the tests for the specified packages.

...
$ 

Overall, get downloads and installs the named targets, but -t only downloads the test dependencies: it does not install them. If you want to install the test dependencies as well, then you can follow go get -v -t gopkg.in/check.v1 with go test -i gopkg.in/check.v1.

The new caching work planned for Go 1.10 will require gotype to coordinate a bit more anyway, and that coordination will make plain downloads of the test dependencies good enough.

@rsc rsc closed this as completed Jun 22, 2017
@golang golang locked and limited conversation to collaborators Jun 22, 2018
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