Skip to content

nogo patches doesn't seem to account for symlink_prefix #4296

@omar-scio

Description

@omar-scio

It seems that this feature (added in #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:

  1. Build label: 7.4.1
  2. Go version 1.23
  3. rules_go version v0.53.0
  4. gazelle version v0.35.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions