Yeah, it's totally fine that way. It's doing reflect.New(CollectorTypeNeed) instead of reflect.New(CollectorTypeNeed).Elem(), so that the result has type *CollectorGoogleAnalytics and can be cast to ICollector.
On Saturday, October 15, 2016 at 6:26:21 AM UTC+2, Paulo Coutinho wrote: > > Hi, > > I solved it on other group too, a friend help and without remote the > pointer. What you think? > > https://gist.github.com/prsolucoes/2ebc5f199632ba1d72af11b12891d229 > > Thanks. > > On Friday, October 14, 2016 at 11:26:02 PM UTC-3, Roberto Zanotto wrote: >> >> The panic you get is because CollectorGoogleAnalytics does not >> implement ICollector, since GetName is defined on type >> *CollectorGoogleAnalytics and not CollectorGoogleAnalytics. >> This works (I changed line 24): https://play.golang.org/p/SIFh3W3qhW >> >> On Saturday, October 15, 2016 at 4:02:51 AM UTC+2, Paulo Coutinho wrote: >>> >>> Hi, >>> >>> I made an example to my problem: >>> https://play.golang.org/p/zVLH8J7EiP >>> >>> But what i need is have some plugins that use an interface to return >>> some data. But the plugin is auto inserted in a map of type: >>> map[string]reflect.TypeOf >>> >>> or can be (will be better): >>> map[string]ICollector >>> >>> After get the type by string of map i want create a new instance of it. >>> >>> Can anyone help me? >>> >>> >>> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.