github.com/yanyiwu/go@v0.0.0-20150106053140-03d6637dbb7f/test/interface/receiver1.go (about) 1 // errorcheck 2 3 // Copyright 2009 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 // Verify compiler complains about missing implicit methods. 8 // Does not compile. 9 10 package main 11 12 type T int 13 14 func (t T) V() 15 func (t *T) P() 16 17 type V interface { 18 V() 19 } 20 type P interface { 21 P() 22 V() 23 } 24 25 type S struct { 26 T 27 } 28 type SP struct { 29 *T 30 } 31 32 func main() { 33 var t T 34 var v V 35 var p P 36 var s S 37 var sp SP 38 39 v = t 40 p = t // ERROR "does not implement|requires a pointer" 41 _, _ = v, p 42 v = &t 43 p = &t 44 _, _ = v, p 45 46 v = s 47 p = s // ERROR "does not implement|requires a pointer" 48 _, _ = v, p 49 v = &s 50 p = &s 51 _, _ = v, p 52 53 v = sp 54 p = sp // no error! 55 _, _ = v, p 56 v = &sp 57 p = &sp 58 _, _ = v, p 59 }