1
2
3
4
5
6
7 package main
8
9 import "fmt"
10
11 type Buffer int
12
13 func (*Buffer) Read() {}
14
15 type Reader interface {
16 Read()
17 }
18
19 func f() *Buffer { return nil }
20
21 func g() Reader {
22
23 return f()
24 }
25
26 func h() (b *Buffer, ok bool) { return }
27
28 func i() (r Reader, ok bool) {
29
30 return h()
31 }
32
33 func fmter() (s string, i int, t string) { return "%#x %q", 100, "hello" }
34
35 func main() {
36 b := g()
37 bb, ok := b.(*Buffer)
38 _, _, _ = b, bb, ok
39
40 b, ok = i()
41 bb, ok = b.(*Buffer)
42 _, _, _ = b, bb, ok
43
44 s := fmt.Sprintf(fmter())
45 if s != "0x64 \"hello\"" {
46 println(s)
47 panic("fail")
48 }
49 }
50
View as plain text