summaryrefslogtreecommitdiff
path: root/src/fmt
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2014-09-22 15:35:25 -0700
committerRob Pike <r@golang.org>2014-09-22 15:35:25 -0700
commit892b5074f521ae812b880808e0bd79ee2a02b1a1 (patch)
treee32fb402a4f65a52d1fb6fd01094599ab15cf749 /src/fmt
parent1392276bfb7b6100b2def909ef9d19e477970f6b (diff)
downloadgo-git-892b5074f521ae812b880808e0bd79ee2a02b1a1.tar.gz
fmt: document that self-recursive data structures can be fatal
Fixes #8241. LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://golang.org/cl/144420043
Diffstat (limited to 'src/fmt')
-rw-r--r--src/fmt/doc.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/fmt/doc.go b/src/fmt/doc.go
index 5af8d3e717..b7eaedc11e 100644
--- a/src/fmt/doc.go
+++ b/src/fmt/doc.go
@@ -147,6 +147,10 @@
func (x X) String() string { return Sprintf("<%s>", x) }
convert the value before recurring:
func (x X) String() string { return Sprintf("<%s>", string(x)) }
+ Infinite recursion can also be triggered by self-referential data
+ structures, such as a slice that contains itself as an element, if
+ that type has a String method. Such pathologies are rare, however,
+ and the package does not protect against them.
Explicit argument indexes: