fmt: give advice on wrapper functions

Fixes #79332

Change-Id: If50e12834bf1aeaa21bd193acaba28d13f2278fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/777780
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Alan Donovan 2026-05-13 16:15:13 -04:00
parent 1bcea1df64
commit e4283592e5

View file

@ -299,6 +299,16 @@ occurred. If the panic is caused by a nil receiver to an Error,
String, or GoString method, however, the output is the undecorated
string, "<nil>".
Many packages whose APIs involve string formatting expose a trio of
functions similar to [Print], [Printf], and [Println].
For example, the [log.Print], [log.Printf] and [log.Println] functions
forward their arguments to the corresponding functions in this package.
To avoid confusion, other wrapper functions should follow the naming
and behavioral conventions established by this package.
In particular, a single function should not choose between literal
printing (like [Print]) and formatted printing (like [Printf])
based on the number of arguments; instead, provide separate functions.
# Scanning
An analogous set of functions scans formatted text to yield