Skip to content
This repository has been archived by the owner on Feb 26, 2019. It is now read-only.

Go 1.6 GO15VENDOREXPERIMENT #437

Open
didip opened this issue Mar 16, 2016 · 6 comments
Open

Go 1.6 GO15VENDOREXPERIMENT #437

didip opened this issue Mar 16, 2016 · 6 comments

Comments

@didip
Copy link

didip commented Mar 16, 2016

When using Go 1.6, GO15VENDOREXPERIMENT is not automatically set to 1.

Expected:
godep saves dependencies under vendor/

Result:
godep is still saving dependencies under Godeps/_workspace.

@freeformz
Copy link

What version of godep (godep version output)?

Current version of godep will save to vendor/ if go1.6 or go1.5 w/GO15VENDOREXPERIMENT, unless there is an existing Godeps/_workspace folder (and if so you get a warning about it).

@hiroxy
Copy link

hiroxy commented Mar 17, 2016

I use godep v58.
My understanding is that go1.5 vedoring experiment was enabled by setting GO15VENDOREXPERIMENT environment variable is set to 1 explicitly. But in go1.6 it is 1 by default without setting the environment variable and is disabled by setting GO15VENDOREXPERIMENT=0 explicitly.
Therefore, in go1.6 godep should save dependencies to vendor unless GO15VENDOREXPERIMENT=0 is set explicitly. But at this moment, godep saves dependencies under Godeps/_workspace because godep refers to only the environment variable.
I think if godep uses the result of go env GO15VENDOREXPERIMENT instead of the environment variable, this issue is solved.

@freeformz
Copy link

Godep looks directly at the environment AND go version. If a ./Godeps/_workspace exists though it keeps using it and disables the vendor experiment (and warns you about that). Here is the code it uses to determine this:

godep/main.go

Lines 69 to 88 in a62a914

// VendorExperiment is the Go 1.5 vendor directory experiment flag, see
// https://github.com/golang/go/commit/183cc0cd41f06f83cb7a2490a499e3f9101befff
// Honor the env var unless the project already has an old school godep workspace
func determineVendor(v string) bool {
go15ve := os.Getenv("GO15VENDOREXPERIMENT")
ev := (v == "go1.5" && go15ve == "1") ||
(v == "go1.6" && go15ve != "0") ||
(v == "devel" && go15ve != "0")
ws := filepath.Join("Godeps", "_workspace")
s, err := os.Stat(ws)
if err == nil && s.IsDir() {
if ev {
log.Printf("WARNING: Go version (%s) & $GO15VENDOREXPERIMENT=%s wants to enable the vendor experiment, but disabling because a Godep workspace (%s) exists\n", v, go15ve, ws)
}
return false
}
return ev
}

Please see this if you are looking to move an existing Godeps workspace to vendor: https://github.com/tools/godep#migrating-to-vendor

@hiroxy
Copy link

hiroxy commented Mar 17, 2016

I see. I misinterpreted current code and verified v58 works correctly with go1.6. So sorry.

@didip
Copy link
Author

didip commented Mar 17, 2016

Ah, my build machine is still on older godep. Thanks!

After upgrading, I ran into this bug: #377, but go get golang.org/x/sys/unix fixes it.

Feel free to close this ticket.

@freeformz
Copy link

@didip I don't really consider #377 a bug per se, at least not as it's stated. It will be "solved" by better build tag support though at some point.

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