blob: 9b72dd4736455002346df386d464ff04388ffe3e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
// printnil checks that fmt correctly handles a nil pointer receiver
// for a value method at all optimization levels.
package main
import "fmt"
type MyType struct {
val int
}
func (t MyType) String() string {
return "foobar"
}
func main() {
if got := fmt.Sprintf("%s", (*MyType)(nil)); got != "<nil>" {
panic(got)
}
}
|