bazel-contrib / rules_go

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

bug(nogo): fails on @@com_github_aws_aws_sdk_go//internal/context:context #4070

Closed tyler-french closed 1 month ago

tyler-french commented 1 month ago

What version of rules_go are you using?

HEAD

What version of gazelle are you using?

latest

What version of Bazel are you using?

7.2

What did you do?

Build anything with any nogo analyzer (tested with multiple)

INFO: Writing tracer profile to '/tmp/bazel_20240827021935_dgnmh'
INFO: Invocation ID: 295c50af-8d33-4580-a3fe-f617286cd0d1
INFO: Analyzed 171 targets (0 packages loaded, 0 targets configured).
WARNING: Remote Cache: Expected output external/com_github_aws_aws_sdk_go/internal/context/context.nogo.log was not created locally.
ERROR: /home/user/.cache/bazel/_bazel_tfrench/b97476d719d716accead0f2d5b93104f/external/com_github_aws_aws_sdk_go/internal/context/BUILD.bazel:3:11: output 'external/com_github_aws_aws_sdk_go/internal/context/context.nogo.log' was not created
ERROR: /home/user/.cache/bazel/_bazel_tfrench/b97476d719d716accead0f2d5b93104f/external/com_github_aws_aws_sdk_go/internal/context/BUILD.bazel:3:11: Running nogo on @@com_github_aws_aws_sdk_go//internal/context:context failed: not all outputs were created or valid
INFO: Analysis succeeded for only 97 of 171 top-level targets
INFO: Found 171 targets...
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 26.484s, Critical Path: 25.68s
INFO: 2174 processes: 1 disk cache hit, 1 internal, 2172 processwrapper-sandbox.
ERROR: Build did NOT complete successfully
INFO: Build Event Protocol files produced successfully.

Looking at this target, here's the BUILD.bazel file:

load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
    name = "context",
    srcs = ["background_go1.5.go"],
    importpath = "github.com/aws/aws-sdk-go/internal/context",
    visibility = ["//:__subpackages__"],
)

alias(
    name = "go_default_library",
    actual = ":context",
    visibility = ["//:__subpackages__"],
)

and here's the source code:

//go:build !go1.7
// +build !go1.7

package context

import "time"

// An emptyCtx is a copy of the Go 1.7 context.emptyCtx type. This is copied to
// provide a 1.6 and 1.5 safe version of context that is compatible with Go
// 1.7's Context.
//
// An emptyCtx is never canceled, has no values, and has no deadline. It is not
// struct{}, since vars of this type must have distinct addresses.
type emptyCtx int

func (*emptyCtx) Deadline() (deadline time.Time, ok bool) {
    return
}

func (*emptyCtx) Done() <-chan struct{} {
    return nil
}

func (*emptyCtx) Err() error {
    return nil
}

func (*emptyCtx) Value(key interface{}) interface{} {
    return nil
}

func (e *emptyCtx) String() string {
    switch e {
    case BackgroundCtx:
        return "aws.BackgroundContext"
    }
    return "unknown empty Context"
}

// BackgroundCtx is the common base context.
var BackgroundCtx = new(emptyCtx)