mirror of
https://github.com/golang/go
synced 2024-11-19 03:24:40 -07:00
6643abb26c
Suggested reading order: - doc.go - api.go, analysis.go, callgraph.go, labels.go - print.go, util.go - gen.go - solve.go - pointer_test.go, testdata/* - intrinsics.go (none are implemented yet) R=dannyb, gri, crawshaw, 0xjnml CC=golang-dev https://golang.org/cl/10618043
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
|