LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2010 The Go Authors. All rights reserved. | 1 // Copyright 2010 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // This file contains tests for the printf checker. | 5 // This file contains tests for the printf checker. |
6 | 6 |
7 package testdata | 7 package testdata |
8 | 8 |
9 import ( | 9 import ( |
10 "fmt" | 10 "fmt" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 var notPercentDV notPercentDStruct | 262 var notPercentDV notPercentDStruct |
263 | 263 |
264 // A data type we can print with "%s". | 264 // A data type we can print with "%s". |
265 type percentSStruct struct { | 265 type percentSStruct struct { |
266 a string | 266 a string |
267 b []byte | 267 b []byte |
268 c stringerarray | 268 c stringerarray |
269 } | 269 } |
270 | 270 |
271 var percentSV percentSStruct | 271 var percentSV percentSStruct |
| 272 |
| 273 type recursiveStringer int |
| 274 |
| 275 func (s recursiveStringer) String() string { |
| 276 fmt.Sprintf("%v", &s) // ERROR "arg &s for printf causes recursive call
to String method" |
| 277 fmt.Sprintf("%d", s) |
| 278 fmt.Sprintf("%v", s) // ERROR "arg s for printf causes recursive call
to String method" |
| 279 return fmt.Sprintln(s) // ERROR "arg s for print causes recursive call t
o String method" |
| 280 } |
| 281 |
| 282 type recursivePtrStringer int |
| 283 |
| 284 func (p *recursivePtrStringer) String() string { |
| 285 fmt.Sprintf("%v", *p) // ERROR "arg \*p for printf causes recursive cal
l to String method" |
| 286 return fmt.Sprintln(p) // ERROR "arg p for print causes recursive call t
o String method" |
| 287 } |
LEFT | RIGHT |