aboutsummaryrefslogtreecommitdiff
path: root/src/context
diff options
context:
space:
mode:
Diffstat (limited to 'src/context')
-rw-r--r--src/context/context.go2
-rw-r--r--src/context/x_test.go4
2 files changed, 6 insertions, 0 deletions
diff --git a/src/context/context.go b/src/context/context.go
index 30adfe987d..763d4f777f 100644
--- a/src/context/context.go
+++ b/src/context/context.go
@@ -739,6 +739,8 @@ func stringify(v any) string {
return s.String()
case string:
return s
+ case nil:
+ return "<nil>"
}
return reflectlite.TypeOf(v).String()
}
diff --git a/src/context/x_test.go b/src/context/x_test.go
index 2c66ed42b2..ab3c2757cf 100644
--- a/src/context/x_test.go
+++ b/src/context/x_test.go
@@ -243,6 +243,10 @@ func TestValues(t *testing.T) {
c4 := WithValue(c3, k1, nil)
check(c4, "c4", "", "c2k2", "c3k3")
+ if got, want := fmt.Sprint(c4), `context.Background.WithValue(context_test.key1, c1k1).WithValue(context_test.key2(1), c2k2).WithValue(context_test.key2(3), c3k3).WithValue(context_test.key1, <nil>)`; got != want {
+ t.Errorf("c.String() = %q want %q", got, want)
+ }
+
o0 := otherContext{Background()}
check(o0, "o0", "", "", "")