-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Remove tools.go #2781
Remove tools.go #2781
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree, tools.go
works and means we don't need to specify or change @v0.4.0
dozens of times.
To avoid having to specify the same version multiple times a With |
I think this needs to be handled in go, it would be nice to define dev-dependencies which aren't transitively given to consumers. For now is there a way we could define a second module for tools with it's own |
Btw I get the problem you are describing could happen, but have you seen this in the wild ?
|
I've tried to repro your problem and I'm a bit confused:
|
I'm not opposed to this change, but I don't want to see versions strewn all throughout the codebase. A makefile would be preferred or another solution that lets you define the versions outside of this module (can we |
Theoretically you could have a Tool A and B use A simple solution is to have a install:
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.0
go install go.uber.org/mock/mockgen@v0.4.0 and in the code //go:generate mockgen -package mocknetwork -destination mock_resource_manager.go github.com/libp2p/go-libp2p/core/network ResourceManager"
// instead of
//go:generate sh -c "go run go.uber.org/mock/mockgen@v0.4.0 -package mocknetwork -destination mock_resource_manager.go github.com/libp2p/go-libp2p/core/network ResourceManager" And then run EDIT: it looks like the GH workflows for https://github.com/libp2p/go-libp2p/blob/master/.github/workflows/go-check.yml#L16-L20 uses https://github.com/ipdxco/unified-github-workflows/blob/v1.0/.github/workflows/go-check.yml which then calls |
I want to avoid installing anything globally on the user's path. This is brittle, and, for me at least, doesn't work. |
It doesn't need to be global: export GOBIN := $(abspath .)/bin
export PATH := $(GOBIN):$(PATH)
.PHONY: install
install:
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.0
go install go.uber.org/mock/mockgen@v0.4.0
.PHONY: generate
generate: install
go generate ./... Now |
What if a user has older binaries in their ./bin, would running |
~/workspace$ GOBIN=$(pwd)/bin go install go.uber.org/mock/mockgen@v0.4.0
go: downloading go.uber.org/mock v0.4.0
~/workspace$ ./bin/mockgen -version
v0.4.0
~/workspace$ GOBIN=$(pwd)/bin go install go.uber.org/mock/mockgen@v0.3.0
go: downloading go.uber.org/mock v0.3.0
~/workspace$ ./bin/mockgen -version
v0.3.0 The example |
ah, I see you added the |
Interoperability testing fails for head, not because of this change but probably because of this PR: #2780 It seems like updated |
I will defer to Marco on this, but I'd prefer not maintaining a make file for two go install commands. Can we just provide installation instructions in a doc file? |
I've moved the Makefile to a new tools dir because I'm not a fan of having a Makefile in the repo root that isn't part of building the project.
The problem is that we'd have to update the doc and CI and our local machines any time that changes. It's much easier to always do |
@fasmat, I haven't looked into it yet, but I would have expected us to see some removals in go.mod. A brief glance at the diff doesn't show that. Any ideas? |
Because the tools that have been used for |
I am against this change for several reasons: First, this seems to be complicating the Second, specifying these in the
This is a general "updating dependencies can break things" issue. |
Agreed, this is a nice quality of life improvement.
It's a good callout that this is missing any form of checksumming. I'm pretty sure this could be fixed, but at the cost of something more complex. I should have thought about this from the start and brought it up. I'm a bit disappointed that this change in practice doesn't actually reduce any of our dependencies. It just moved one to be indirect. I do like that this change standardized the The actual benefits here don't seem to outweigh the cost of maintaining this and adopting a non-standard |
Since
go install
andgo get
support the installation of specific dependencies / tools via version identifier it should be used instead of atools.go
file to add those dependencies.The reason is that a tool installed that was listed as dependency via
tools.go
is a custom build with (possibly) overwritten dependencies from the official release of that version. Here's an example:Lets say
mockgen@v0.4.0
depends ongolang.org/x/tools@v0.18.0
andgo-libp2p
depends on this version of the dependency too. If the dependency ingo-libp2p
is updated tov0.20.0
mockgen
will now be used in a custom version that is based onv0.4.0
but with an updatedgolang.org/x/tools
dependency. This can lead to builds suddenly breaking in unexpected ways.