Type assertion + interface + pointer

2,223 views
Skip to first unread message

Ian Davis

unread,
May 12, 2012, 6:48:41 PM5/12/12
to golan...@googlegroups.com
I define an interface and a struct that implements that interface. I'm
storing pointers to these structs in a list but I can't access the
interface methods when I retrieve the pointers from the list.

As you can see in this example, I get the error
"e.Value.(*Updater).Update undefined (type *Updater has no field or
method Update)"

http://play.golang.org/p/DCEIOA7s-z

Any suggestions?

Cheers,

Ian

Ian Davis

unread,
May 12, 2012, 6:50:21 PM5/12/12
to golan...@googlegroups.com
And of course, 2 minutes later I solved it :)

See http://play.golang.org/p/biK4dUpPhq

Malcolm Greaves

unread,
Nov 29, 2012, 3:25:53 PM11/29/12
to golan...@googlegroups.com
Thanks for this post -- it helped me solve the same problem in my code!
Reply all
Reply to author
Forward
0 new messages