]> Cypherpunks repositories - gostls13.git/commit
fmt: add Append, Appendln, Appendf
authorRob Pike <r@golang.org>
Sun, 15 May 2022 00:11:56 +0000 (10:11 +1000)
committerRob Pike <r@golang.org>
Tue, 17 May 2022 18:55:46 +0000 (18:55 +0000)
commit668041ef66ddafffccf1863e6180b83ea1ad30c9
treeda7cb4efd720e7b5621b500f2019c830773a177b
parent076039a5e16acf104210d62778d48363589e241d
fmt: add Append, Appendln, Appendf

These are straightforward variants of the existing Sprintf etc.,
but append the resulting bytes to a provided buffer rather than
returning a string.

Internally, there is potentially some allocation because the package
uses a pool of buffers to build its output. We make no attempt to
override that, so the result is first printed into the pool and
then copied to the output. Since it is a managed pool, asymptotically
there should be no extra allocation.

Fixes #47579

RELNOTE=yes

Change-Id: Icef797f9b6f0c84d03e7035d95c06cdb819e2649
Reviewed-on: https://go-review.googlesource.com/c/go/+/406177
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
api/next/47579.txt [new file with mode: 0644]
src/fmt/fmt_test.go
src/fmt/print.go