We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go version go1.23rc1 X:nocoverageredesign linux/amd64
go env
GO111MODULE='off' GOARCH='amd64' GOBIN='' GOCACHE='/home/user/.cache/go-build' GOENV='/home/user/.config/go/env' GOEXE='' GOEXPERIMENT='nocoverageredesign' GOFLAGS='' GOHOSTARCH='amd64' GOHOSTOS='linux' GOINSECURE='' GOMODCACHE='/home/user/go-code2/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='linux' GOPATH='/home/user/go-code2' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/home/user/.cache/bazel/_bazel_taiwon/a4cfce9b81ac8aa474cbfb97d6c4bc91/external/go_sdk' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/home/user/.cache/bazel/_bazel_taiwon/a4cfce9b81ac8aa474cbfb97d6c4bc91/external/go_sdk/pkg/tool/linux_amd64' GOVCS='' GOVERSION='go1.23rc1 X:nocoverageredesign' GODEBUG='' GOTELEMETRY='local' GOTELEMETRYDIR='/home/user/.config/go/telemetry' GCCGO='gccgo' GOAMD64='v1' AR='ar' CC='gcc' CXX='g++' CGO_ENABLED='1' GOMOD='' GOWORK='' CGO_CFLAGS='-O2 -g' CGO_CPPFLAGS='' CGO_CXXFLAGS='-O2 -g' CGO_FFLAGS='-O2 -g' CGO_LDFLAGS='-O2 -g' PKG_CONFIG='pkg-config' GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build4074946335=/tmp/go-build -gno-record-gcc-switches'
Created a context via calling context.WithValue and passed nil to the value and tried printing:
context.WithValue
ctx := context.WithValue(context.Background(), contextKey{}, nil) fmt.Printf("%v\n", ctx)
Playground: https://go.dev/play/p/vtF3t_JWxIC?v=gotip
Printed the following:
%!v(PANIC=String method: runtime error: invalid memory address or nil pointer dereference)
In 1.22, the above program prints:
context.Background.WithValue(type main.contextKey, val <not Stringer>)
The text was updated successfully, but these errors were encountered:
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Sorry, something went wrong.
Change https://go.dev/cl/597415 mentions this issue: context: handle nil values for valueCtx.String()
context: handle nil values for valueCtx.String()
70e453b
No branches or pull requests
Go version
go version go1.23rc1 X:nocoverageredesign linux/amd64
Output of
go env
in your module/workspace:What did you do?
Created a context via calling
context.WithValue
and passed nil to the value and tried printing:Playground:
https://go.dev/play/p/vtF3t_JWxIC?v=gotip
What did you see happen?
Printed the following:
What did you expect to see?
In 1.22, the above program prints:
The text was updated successfully, but these errors were encountered: