0

In golang.org's official FAQ, under pointers there is this quote: "The insight is that although a pointer to a concrete type can satisfy an interface, with one exception a pointer to an interface can never satisfy an interface"

Out of curiosity, what is that exception to the above rule? i.e when can an interface pointer implement an interface?

Javier Zunzunegui
  • 363
  • 1
  • 3
  • 10

1 Answers1

1

Just below it says:

The one exception is that any value, even a pointer to an interface, can be assigned to a variable of empty interface type (interface{}). Even so, it's almost certainly a mistake if the value is a pointer to an interface; the result can be confusing.

LanceH
  • 1,726
  • 13
  • 20
  • 1
    You are right, I just tested it and it runs OK. Thanks func main() { type I interface{} f := func(p interface{}) { fmt.Println("runs") } var i I = 1 f(&i) } – Javier Zunzunegui Jul 29 '15 at 18:25