Open sluongng opened 3 years ago
The current workaround that I decided to go with, is to add com_github_masterminds_semver_v3
inside _go_dependencies()
with a # keep
comment on top of the repo declaration. It's not the cleanest solution and it's screw around with how Gazelle is managing the macro, but it's working.
If somebody can give me a pointer to Gazelle resolve logic of a go_repository
target, I will do a deep dive to see how could I get this fixed so that the generated BUILD file will always have the correct deps
target
Hm, I'm not sure, I haven't seen this behavior before. The relevant code should be language/go/resolve.go:ResolveGo -> resolveExternal
. One workaround would be to use explicit resolve directives, although that shouldn't be necessary in this case..
# gazelle:resolve go github.com/Masterminds/semver/v3 @com_github_masterminds_semver_v3//:go_default_library
What version of gazelle are you using?
v0.23.0
What version of rules_go are you using?
v0.28.0
What version of Bazel are you using?
4.2.1
Does this issue reproduce with the latest releases of all the above?
Yes, all of the above are latest
What operating system and processor architecture are you using?
MacOS Darwin AMD64
What did you do?
I have a setup where all go_dependencies in WORKSPACE are loaded from
third_party/golang_deps.bzl
viago_dependencies()
macro. The content of the macro is like thisNote that in
rules_nfpm_go_dependencies()
there are declarations like thisWhat did you expect to see?
When workspace is built, I expect gazelle to resolve all imports of
"github.com/Masterminds/semver/v3"
ascom_github_masterminds_semver_v3
What did you see instead?
The actual BUILD.bazel file generated
This confuses me as for certain that I do have the go_repository downloaded
After playing with this a bit more, I found out that if I were to take
com_github_masterminds_semver_v3
and put it into my workspace's_go_dependencies()
macro, the issue is fixed.This works as long as
com_github_masterminds_semver_v3
is defined within_go_dependencies()
, disregarding it's order(before/after) relative tocom_github_masterminds_semver
.However if I were to load it in
go_dependencies()
macroThen the issue occurred again.