How should go/build support GO15VENDOREXPERIMENT?

219 views
Skip to first unread message

Caleb Spare

unread,
Oct 23, 2015, 5:14:28 PM10/23/15
to golang-dev
Hi golang-dev,

I've been considering https://golang.org/issue/12278 which concerns
changes to go/build to support tools which want to be aware of
GO15VENDOREXPERIMENT. I want to get the ball rolling by throwing out a
few thoughts I've had.

It seems to me that if (*Context).Import is to resolve vendored
imports, it has to be given an (optional) parent package. Then it can
search the possible resolutions of the import path relative to the
parent import path. (This is an extension of the way it already
searches multiple GOPATH segments.) The method parameters can't
change, so I guess the parent package has to be part of the Context.

Another approach would be to say that Import will not do vendor
resolution and to instead provide a helper function that can do it.

There are two other details to the vendoring changes:

1. GO15VENDOREXPERIMENT disallows import paths explicitly containing
'vendor'. But go/build can probably be ignorant of that fact, just as
it's currently ignorant of internal packages as far as I can tell.
Alternatively, a new ImportMode analogous to ImportComment could be
introduced.
2. If (*Context).Import becomes GO15VENDOREXPERIMENT-aware, then
ImportComment needs to be adjusted to ignore import comments in
vendored packages.

What other ideas do people have?

Thanks!
Caleb
Reply all
Reply to author
Forward
0 new messages