-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Milestone
Description
Go version
go version go1.24rc1 darwin/arm64
Output of go env in your module/workspace:
AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/artyom/Library/Caches/go-build'
GODEBUG=''
GOENV='/Users/artyom/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS='-ldflags=-w -trimpath'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/lb/3rk8rqs53czgb4v35w_342xc0000gn/T/go-build3751872123=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/artyom/repos/example/go.mod'
GOMODCACHE='/Users/artyom/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/artyom/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/artyom/Library/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/Users/artyom/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/artyom/Library/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24rc1'
GOWORK=''
PKG_CONFIG='pkg-config'What did you do?
https://go.dev/play/p/A-SjUqygxkd?v=gotip
Tried to use testing.T.Context and testing.B.Context
func TestSomething(t *testing.T) {
if t.Context() == nil {
t.Fatal("nil context")
}
}
func BenchmarkSomething(b *testing.B) {
ctx := b.Context()
for b.Loop() {
if ctx == nil {
b.Fatal("nil context")
}
}
}What did you see happen?
testing.T.Context returns non-nil context (as expected), but testing.B.Context returns nil context
What did you expect to see?
Both t.Context() and b.Context() returning a non-nil context
Reactions are currently unavailable