github.com/v2fly/tools@v0.100.0/go/pointer/testdata/fmtexcerpt.go (about) 1 // +build ignore 2 3 // This is a slice of the fmt package. 4 5 package main 6 7 type pp struct { 8 field interface{} 9 } 10 11 func newPrinter() *pp { 12 return new(pp) 13 } 14 15 func Fprintln(a ...interface{}) { 16 p := newPrinter() 17 p.doPrint(a, true, true) 18 } 19 20 func Println(a ...interface{}) { 21 Fprintln(a...) 22 } 23 24 func (p *pp) doPrint(a []interface{}, addspace, addnewline bool) { 25 print(a[0]) // @types S | string 26 stringer := a[0].(interface { 27 String() string 28 }) 29 30 stringer.String() 31 print(stringer) // @types S 32 } 33 34 type S int 35 36 func (S) String() string { return "" } 37 38 func main() { 39 Println("Hello, World!", S(0)) 40 } 41 42 // @calls (*main.pp).doPrint -> (main.S).String