From e4283592e5cb00d84544df2442b0d3f4eccf8c72 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Wed, 13 May 2026 16:15:13 -0400 Subject: [PATCH] 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 LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com --- src/fmt/doc.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/fmt/doc.go b/src/fmt/doc.go index 46f30b44e9a722..49365eedf72640 100644 --- a/src/fmt/doc.go +++ b/src/fmt/doc.go @@ -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, "". +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