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

proposal: cmd/go: force vendor directory only #19234

Open
azr opened this Issue Feb 22, 2017 · 7 comments

Comments

Projects
None yet
7 participants
@azr

azr commented Feb 22, 2017

Hello there,

TLDR: it would be nice to be able to go build --using-vendors-only or something similar.

More thought:
I like a revision of a go project to be buildable.
Often when I update the vendors of a project, the ci tools tell me there is a missing dep or something is wrong with this or that dep, because that other pkg is outdated, because the system are different or other various reasons.
But it always works locally and then I find myself having a lot commits that contain fix godeps

So I'd like to have a pre commit hook that checks if the project builds in my ci.

that hook would do something like this: GOOS=linux go build --using-vendors-only

Tried GOOS=linux go build -pkgdir ./vendor but nope

@mvdan

This comment has been minimized.

Member

mvdan commented Feb 22, 2017

What about setting GOPATH to an empty directory?

@azr

This comment has been minimized.

azr commented Feb 22, 2017

@mvdan empty default to $HOME and "/tmp" failed:

GOPATH=/tmp GOOS=linux go build ./cmd/runner
output:

 cannot find package "github.com/stvp/rollbar" in any of:
	/usr/local/opt/go/libexec/src/github.com/stvp/rollbar (from $GOROOT)
	/tmp/src/github.com/stvp/rollbar (from $GOPATH)

It doesn't look for the vendor dir, may be it should ?

And I can't use go build "project name/repo" because GOPATH is wrong.

Edit: same output for GOPATH=/tmp GOOS=linux go build -pkgdir ./vendor ./cmd/runner

@mvdan

This comment has been minimized.

Member

mvdan commented Feb 22, 2017

Ah right, it can't find any of the packages then. I guess you could set up a new GOPATH and link src/your/pkg to the right place, which should work as a script or shell alias. But that's not as simple.

Alternatively, I've seen discussions around "building Go packages outside of GOPATH". That might be a solution for this if you unset GOPATH, but it would probably be in the long term. I think that's #17271.

@vcabbage

This comment has been minimized.

Member

vcabbage commented Feb 22, 2017

I agree that it would be useful to do this.

For the time being you could try https://github.com/cloudflare/hellogopher. The Makefile creates a .GOPATH directory within your project and uses that for tests, building, etc.

@azr

This comment has been minimized.

azr commented Feb 23, 2017

@vcabbage works like a charm, thanks

@quentinmit quentinmit changed the title from go build using vendor directory only to cmd/go: force vendor directory only Feb 27, 2017

@quentinmit quentinmit added this to the Go1.9Maybe milestone Feb 27, 2017

@rtuin

This comment has been minimized.

rtuin commented Apr 10, 2017

I think this is a great idea. Being able to build (dependencies) in an isolated environment reduces frustration and increases software stability. 👍

@rsc

This comment has been minimized.

Contributor

rsc commented Jun 12, 2017

On hold for package management. We'll get there but vendor may or may not be the answer.

@rsc rsc changed the title from cmd/go: force vendor directory only to proposal: cmd/go: force vendor directory only Jun 12, 2017

@rsc rsc added the Proposal-Hold label Jun 12, 2017

@rsc rsc modified the milestones: Proposal, Go1.9Maybe Jun 12, 2017

@gopherbot gopherbot added the Proposal label Jun 12, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment