mirror of
https://github.com/golang/go
synced 2024-11-19 05:34:40 -07:00
43 lines
649 B
Go
43 lines
649 B
Go
|
// +build ignore
|
||
|
|
||
|
// This is a slice of the fmt package.
|
||
|
|
||
|
package main
|
||
|
|
||
|
type pp struct {
|
||
|
field interface{}
|
||
|
}
|
||
|
|
||
|
func newPrinter() *pp {
|
||
|
return new(pp)
|
||
|
}
|
||
|
|
||
|
func Fprintln(a ...interface{}) {
|
||
|
p := newPrinter()
|
||
|
p.doPrint(a, true, true)
|
||
|
}
|
||
|
|
||
|
func Println(a ...interface{}) {
|
||
|
Fprintln(a...)
|
||
|
}
|
||
|
|
||
|
func (p *pp) doPrint(a []interface{}, addspace, addnewline bool) {
|
||
|
print(a[0]) // @concrete S | string
|
||
|
stringer := a[0].(interface {
|
||
|
String() string
|
||
|
})
|
||
|
|
||
|
stringer.String()
|
||
|
print(stringer) // @concrete S
|
||
|
}
|
||
|
|
||
|
type S int
|
||
|
|
||
|
func (S) String() string { return "" }
|
||
|
|
||
|
func main() {
|
||
|
Println("Hello, World!", S(0))
|
||
|
}
|
||
|
|
||
|
// @calls (*main.pp).doPrint -> (main.S).String
|