rules_go icon indicating copy to clipboard operation
rules_go copied to clipboard

nogo incorrectly flags strict dependency error

Open TvdW opened this issue 1 year ago • 2 comments

Versions

  • rules_go HEAD, currently 59235b4a
  • gazelle HEAD, currently 2b326f81
  • bazel 7.2.1

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.

TvdW avatar Aug 23 '24 09:08 TvdW

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?

sluongng avatar Aug 27 '24 07:08 sluongng

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?

TvdW avatar Aug 27 '24 07:08 TvdW

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

fmeum avatar Aug 29 '24 11:08 fmeum

Tested, and all tests pass now! 😃

TvdW avatar Aug 29 '24 12:08 TvdW