aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
authorDaniel Martí <mvdan@mvdan.cc>2026-02-27 23:34:16 +0000
committerGopher Robot <gobot@golang.org>2026-02-27 20:26:18 -0800
commitfea0300499d7164a37b418ad47e2d8b3d4b16c01 (patch)
tree28442c726f2506831271395dc63ab87a4d708dcc /test/codegen
parent244b156e67635f83a13b113c61f7729a79e06056 (diff)
downloadgo-fea0300499d7164a37b418ad47e2d8b3d4b16c01.tar.xz
cmd/compile: test that time.Duration.String is inlineable
This matters for encodings supporting time.Duration, which cannot add an AppendText method due to the encoding package godoc: Adding encoding/decoding methods to existing types may constitute a breaking change, [...] The policy for packages maintained by the Go project is to only allow the addition of marshaling functions if no existing, reasonable marshaling exists. And indeed, time.Duration does have an existing marshaling today: as an integer, which encoding/json still uses to this day. Thankfully, with the String method being inlineable, we can rely on the following not allocating in the heap: var td time.Duration = ... b = append(b, td.String()...) Lock this in so that we can rely on this pattern going forward. For #77851. Change-Id: I57ce0bc099f293b0e36aa4c74b5410f8bda347a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/750100 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/codegen')
0 files changed, 0 insertions, 0 deletions