bazel-contrib / rules_go

Go rules for Bazel
Apache License 2.0
1.38k stars 656 forks source link

nogo incorrectly flags strict dependency error #4062

Closed TvdW closed 1 month ago

TvdW commented 1 month ago

Versions

Issue

Was working on a gazelle patch for something unrelated, pulled in the latest sources, and noticed that bazel test //... on my repo now has build errors.

nogo: missing strict dependencies:
    internal/util/myutil/myutil_test.go: import of "my.module/util/myutil"

I asked git bisect, it said 29d4e5dbcfa702c479311f0bb4a929a236666a46 is the first bad commit: #3995

It looks like nogo is no longer happy with importing a module's own importpath. Since this is a supported pattern in Go, I believe this to be a regression.

sluongng commented 1 month ago

Hey Tom, just to double check on this, what's the package name of myutil_test.go?

Is it package myutil or package myutil_test or something else?

TvdW commented 1 month ago

It's indeed package myutil_test

Good point, and I hadn't noticed that earlier. That said, the tests do have embed = [":myutil"]. Does that make this a Gazelle issue, or should rules_go pick up the embed?

fmeum commented 1 month ago

@TvdW Could you test the fix at https://github.com/bazelbuild/rules_go/pull/4075?

TvdW commented 1 month ago

Tested, and all tests pass now! 😃