You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By following the "Configuring nogo" step at "Go with Bzlmod" documentation, I was able to setup its target and started with a minimalist configuration that only has vet enabled:
# golang.org/x/tools is not a direct dependency of the go code anymore# but bazel buildtools and nogo depend on it.go_deps.module(
path="golang.org/x/tools",
sum="h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ=",
version="v0.18.0",
)
use_repo(
go_deps,
...
"org_golang_x_tools",
...
)
That way it only runs copylock, and the way to access org_golang_x_tools was by having a manual go_deps.module entry and add allow it to be accessed with the apparent name @org_golang_x_tools with the use_repo extension, similarly to any direct dependency of the project itself.
I tried to mimic the same behavior and got this error:
$ bazel mod tidy
ERROR: Traceback (most recent call last):
File "C:/users/alber/_bazel_alber/dyih625r/external/gazelle~/internal/bzlmod/go_deps.bzl", line 309, column 21, in _go_deps_impl
fail("Duplicate Go module path \"{}\" in module \"{}\".".format(module_tag.path, module.name))
Error in fail: Duplicate Go module path "golang.org/x/tools"in module "cli".
ERROR: error evaluating module extension go_deps in @@gazelle~//:extensions.bzl. Type 'bazel help mod'for syntax and help.
Fetching module extension go_deps in @@gazelle~//:extensions.bzl; starting
Am I missing something? So far the only workaround that worked for me was to rely on its canonical name that TOOLS_NOGO uses, as:
It now worked, in one of my attemps I had done a bazel run @rules_go//go -- get -u golang.org/x/tools which also added it to go.mod and added to go_deps.from_file(go_mod = "//:go.mod") it became duplicated.
I didn't fill the template as I'm seeking guidance rather than reporting an issue, but please let me know any other info I should provide.
I am seting up this template that I have to use
bzlmod
only: https://github.com/albertocavalcante/cli, and right now I am attempting to configurenogo
.By following the "Configuring
nogo
" step at "Go with Bzlmod" documentation, I was able to setup its target and started with a minimalist configuration that only hasvet
enabled:MODULE.bazel
BUILD.bazel
It worked! :)
Then, according to the
nogo
documentation, in order to run all the analyzers fromgolang.org/x/tools
I can useTOOLS_NOGO
and that's what I did:BUILD.bazel
Then it incurred into the same issue described at #3592. Ok, I simply removed
vet = True
and all the analyzers atTOOLS_NOGO
executed successfuly.Now comes my problem, how to I choose only a few analyzers from
golang.org/x/tools
?I was taking a look at https://github.com/bazelbuild/bazel-gazelle and noticed it has this setup:
MODULE.bazel
BUILD.bazel
That way it only runs
copylock
, and the way to accessorg_golang_x_tools
was by having a manualgo_deps.module
entry and add allow it to be accessed with the apparent name@org_golang_x_tools
with theuse_repo
extension, similarly to any direct dependency of the project itself.I tried to mimic the same behavior and got this error:
Am I missing something? So far the only workaround that worked for me was to rely on its canonical name that
TOOLS_NOGO
uses, as:But I know this is not sustainable, specially when considered bazelbuild/bazel#22865.
Thanks!
The text was updated successfully, but these errors were encountered: