From 3ee9df799fc76e06b216248735e530dd4e1dc504 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Sun, 1 Mar 2015 08:56:25 -0800 Subject: [PATCH] fmt: document existing behavior of nil receivers If a method called by fmt triggers a panic, the output usually says so. However, there is heretofore undocumented special treatment for a panic caused by formatting a nil value with an Error or String method: the output is simply "". Document that behavior. Change-Id: Id0f79dd0b3487f9d1c74a0856727bba5cc342be4 Reviewed-on: https://go-review.googlesource.com/6410 Reviewed-by: David Crawshaw --- src/fmt/doc.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fmt/doc.go b/src/fmt/doc.go index 9dc2a0d75d..9ba11f4a2b 100644 --- a/src/fmt/doc.go +++ b/src/fmt/doc.go @@ -225,7 +225,9 @@ %!s(PANIC=bad) The %!s just shows the print verb in use when the failure - occurred. + occurred. If the panic is caused by a nil receiver to an Error + or String method, however, the output is the undecorated + string, "". Scanning -- 2.48.1