FAQ
http://play.golang.org/p/BkMFSKBbQc

I'm trying to return an error from a function wrapped by reflect.MakeFunc, but it panics with "reflect: function created by MakeFunc using closure returned wrong type: have *errors.errorString for error"

Is there a way around this, or should I file a bug?

Jonathan

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Ian Lance Taylor at Sep 23, 2013 at 1:51 am

    On Sun, Sep 22, 2013 at 6:41 PM, Jonathan Rudenberg wrote:
    http://play.golang.org/p/BkMFSKBbQc

    I'm trying to return an error from a function wrapped by reflect.MakeFunc, but it panics with "reflect: function created by MakeFunc using closure returned wrong type: have *errors.errorString for error"

    Is there a way around this, or should I file a bug?
    Because reflect.ValueOf takes an interface argument, it effectively
    always uses the dynamic type. You have to work a bit to get an
    interface type into a reflect.Value, like this:

    http://play.golang.org/p/QRY4wQIfuH

    Ian

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jonathan Rudenberg at Sep 23, 2013 at 2:04 am
    Perfect, thanks.
    On Sep 22, 2013, at 9:51 PM, Ian Lance Taylor wrote:

    On Sun, Sep 22, 2013 at 6:41 PM, Jonathan Rudenberg
    wrote:
    http://play.golang.org/p/BkMFSKBbQc

    I'm trying to return an error from a function wrapped by reflect.MakeFunc, but it panics with "reflect: function created by MakeFunc using closure returned wrong type: have *errors.errorString for error"

    Is there a way around this, or should I file a bug?
    Because reflect.ValueOf takes an interface argument, it effectively
    always uses the dynamic type. You have to work a bit to get an
    interface type into a reflect.Value, like this:

    http://play.golang.org/p/QRY4wQIfuH

    Ian
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 23, '13 at 1:41a
activeSep 23, '13 at 2:04a
posts3
users2
websitegolang.org

People

Translate

site design / logo © 2018 Grokbase