-
Notifications
You must be signed in to change notification settings - Fork 86
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
go.mod: add dependencies for go tooling #5811
Conversation
7ef52e2
to
ec65e88
Compare
// This tools/deps package keep track of Go tooling dependency that we use | ||
// but do not depend directly in code. |
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.
what sorts of tool deps need to be included here? i.e. how did you build this list of deps below? (Is there a straightforward way of automating this?)
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.
There are 3 groups added here:
-
Go deps we depend on directly in our BUILD files but not our Go files. I.e.
gitlab.com/arm-research/smarter/smarter-device-manager
-
Transitive Go deps that our
http_archive
repo use. For example, in WORKSPACE mode, we used to load some Go deps with
load("@com_github_sluongng_nogo_analyzer//staticcheck:deps.bzl", "staticcheck")
staticcheck()
This is no longer possible because of the new way Gazelle operate in Bzlmod
ERROR: /Users/sluongng/work/buildbuddy/buildbuddy/BUILD:79:5: //:vet_actual depends on @@org_golang_x_tools//go/analysis/passes/unusedresult:unusedresult in repository @@org_golang_x_tools which failed to fetch. no such package '@@org_golang_x_tools//go/analysis/passes/unusedresult': Unable to load package for @@bazel_gazelle_go_repository_cache//:go.env: The repository '@@bazel_gazelle_go_repository_cache' could not be resolved: Repository '@@bazel_gazelle_go_repository_cache' is not defined
- Our transitive proto/grpc deps that we used to add to
server/libmain/libmain.go
to help withgo mod tidy -e
not adding them fromproto/**
generated code.
These were pretty much manually picked from the errors I encountered #5792.
So maintaining this list would have to be a manual effort for now.
The UX in Bzlmod is documented here https://github.com/bazelbuild/rules_go/blob/master/docs/go/core/bzlmod.md#depending-on-tools.
fa4d335
to
3966e92
Compare
This is a change backported from #5792. Under bzlmod, there will be no `deps.bzl` file. The `go_repository` repos are automatically generated with gazelle's `go_deps` extension parsing `go.mod` and `go.sum` files. This let us consolidate go dependency management to a single source of truth that is consistent with our editor experience. The downside of this approach is that we should not be adding `go_repository` declarations manually, but instead, adding them to `go.mod` file by calling `go mod tidy -e`. Create a dummy Go source file that imports all the Go tools dependencies and guard it with a Go build directive that will not be used.
3966e92
to
23f8af3
Compare
Co-authored-by: Brandon Duffany <brandon@buildbuddy.io>
This is a change backported from #5792.
Under bzlmod, there will be no
deps.bzl
file.The
go_repository
repos are automatically generated with gazelle'sgo_deps
extension parsinggo.mod
andgo.sum
files.This let us consolidate go dependency management to a single source of
truth that is consistent with our editor experience.
The downside of this approach is that we should not be adding
go_repository
declarations manually, but instead, adding them togo.mod
file by callinggo mod tidy -e
.Create a dummy Go source file that imports all the Go tools dependencies
and guard it with a Go build directive that will not be used.