Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1483)

Unified Diff: cmd/vet/testdata/print.go

Issue 12936046: code review 12936046: go.tools/cmd/vet: check for recursive stringers (Closed)
Patch Set: diff -r 7cdd043fad2b https://code.google.com/p/go.tools Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cmd/vet/print.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cmd/vet/testdata/print.go
===================================================================
--- a/cmd/vet/testdata/print.go
+++ b/cmd/vet/testdata/print.go
@@ -269,3 +269,19 @@
}
var percentSV percentSStruct
+
+type recursiveStringer int
+
+func (s recursiveStringer) String() string {
+ fmt.Sprintf("%v", &s) // ERROR "arg &s for printf causes recursive call to String method"
+ fmt.Sprintf("%d", s)
+ fmt.Sprintf("%v", s) // ERROR "arg s for printf causes recursive call to String method"
+ return fmt.Sprintln(s) // ERROR "arg s for print causes recursive call to String method"
+}
+
+type recursivePtrStringer int
+
+func (p *recursivePtrStringer) String() string {
+ fmt.Sprintf("%v", *p) // ERROR "arg \*p for printf causes recursive call to String method"
+ return fmt.Sprintln(p) // ERROR "arg p for print causes recursive call to String method"
+}
« no previous file with comments | « cmd/vet/print.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b