-
Notifications
You must be signed in to change notification settings - Fork 11
add experimental support for go.tools #44
Comments
Just noting the detail here, but another potential line of attack on capturing tool dependencies separately from the main module is to use an internal submodule. For example, consider the module This would likely, however, require a new flag for
We are running commands from within the |
golang/go#25922 gives guidance on the best practice for adding tool dependencies to a module. In short, the tool dependencies get added to the main module via "fake" imports of the main package that is the tool in a build-ignore file, say
tools.go
.There are a number of benefits and issues with this approach; see golang/go#25922 for further discussion on that.
As a trial, let's make
gobin
understand ago.tools
file in the same directory as the main module and take tool versions from that. The format would be very simple:golang.org/x/tools/cmd/goimports
is special be because the version ofgolang.org/x/tools/cmd/goimports
we want does not resolve to a module. This same restriction applies for any tools that resolve to modules that are incomplete, i.e.go.{mod,sum}
are not the result ofgo mod tidy
. The lack of version indicates that for the tool in question we drop down to the main module'sgo.{mod,sum}
to resolve dependencies, i.e. the user also needs to follow the approach outlined in golang/go#25922.Open questions:
go.{mod,sum}
not the result ofgo mod tidy
), use ofgo.tools
is a strictly worse experience than the approach in cmd/go: clarify best practice for tool dependencies golang/go#25922. Should we be doing anything more here?go.tools
, we lose the ability to use ourgo.sum
as a means of verifying any dependencies, tools or otherwise. Instead we end up relying on thego.sum
(if there is one) that is distributed with the tool. Perhaps we should capture thesego.sum
's somewhere too?go.tools.sum
file that is the concatenation of thego.sum
's of the unique set of$module@$version
from the set of toolsgo
tools starts to understandgo.tools
, then this would be unnecessarygobin -tidy
etc.cc @rogpeppe @mvdan
The text was updated successfully, but these errors were encountered: