nogo patches doesn't seem to account for `symlink_prefix`
It seems that this feature (added in https://github.com/bazel-contrib/rules_go/pull/4102) does not account for build --symlink_prefix=<something>.
My .bazelrc says:
build --symlink_prefix=.bazel/
Upon build, I get this:
nogo: errors found by nogo during build-time code analysis:
go/core/utils.go:716:8: Use len(x) == 0 rather than x == "": s == "" (empty_string_check)
-------------------Suggested Fix---------------------
--- a/go/core/utils.go
+++ b/go/core/utils.go
@@ -713,7 +713,7 @@
}
func TestRulesGo(s string) string {
- if s == "" {
+ if len(s) == 0 {
return "{}"
}
return s
-----------------------------------------------------
To apply the suggested fix, run the following command:
$ patch -p1 < bazel-out/darwin_arm64-fastbuild/bin/go/core/core.nogo.patch
This is not quite right given the path is invalid: nogo reports bazel-out/darwin_arm64-fastbuild/bin/go/core/core.nogo.patch when the correct path is .bazel/out/darwin_arm64-fastbuild/bin/go/core/core.nogo.patch. Is rules_go not properly accounting for symlinks?
Environment facts:
Build label: 7.4.1- Go version 1.23
rules_goversionv0.53.0gazelleversionv0.35.0
Bazel doesn't expose the symlink prefix to rules and in its exec root always uses bazel-out, which is also the source of these paths in nogo output.
You could file a feature request for Bazel to expose the prefix.