Re: [go-nuts] types lookup for error interface type

2019-12-14 Thread Dan Kortschak
I think you are right. Thanks.

On Sat, 2019-12-14 at 19:20 +, Paul Jolly wrote:
> > This seem massively over complicated, so I'm wondering if there is
> > an
> > easier way.
> 
> I think you're after types.Universe.Lookup("error")?
> 
> 
> Paul
> 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/627d18f43be4c07f2b8fed78e73c47fa46f3abbd.camel%40kortschak.io.


Re: [go-nuts] types lookup for error interface type

2019-12-14 Thread Paul Jolly
> This seem massively over complicated, so I'm wondering if there is an
> easier way.

I think you're after types.Universe.Lookup("error")?


Paul

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CACoUkn7rrsi9Ai9vhR2GVRRx_dX1w_xjoqGh3davbGbmw5wVkw%40mail.gmail.com.


Re: [go-nuts] types lookup for error interface type

2019-12-14 Thread Dan Kortschak
I think I must have asked this really badly.

I don't want a reflect.Type of an error, I want a types.Type
representation of error for performing static analysis.

The playground that I imagine is necessary is something like this.

https://play.golang.org/p/e-FU0_4J9jK

This seem massively over complicated, so I'm wondering if there is an
easier way. 

On Sat, 2019-12-14 at 19:37 +1030, Dan Kortschak wrote:
> In the go/types package there is an easy way to obtain a types.Type
> for
> basic builtin types. This doesn't exist for the error type.
> 
> Is there an easier way to get a types.Type representing error than by
> using NewInterfaceType, NewFunc and NewSignature functions (I am
> assuming that the nil *types.Package is what should be used for the
> call to NewFunc).
> 
> thanks
> Dan
> 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/5734a9fb1f8261b94545bc6f451be552a74029e6.camel%40kortschak.io.


Re: [go-nuts] types lookup for error interface type

2019-12-14 Thread 'Axel Wagner' via golang-nuts
https://play.golang.org/p/pdjKMn__ufA

On Sat, Dec 14, 2019 at 10:07 AM Dan Kortschak  wrote:

> In the go/types package there is an easy way to obtain a types.Type for
> basic builtin types. This doesn't exist for the error type.
>
> Is there an easier way to get a types.Type representing error than by
> using NewInterfaceType, NewFunc and NewSignature functions (I am
> assuming that the nil *types.Package is what should be used for the
> call to NewFunc).
>
> thanks
> Dan
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/4fb681518e2e36e0d0564394546dd7879dd8f96a.camel%40kortschak.io
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEkBMfEd%3DsrU-xn3WK%3DOH_PTqBjNhgJQ%3DZ3m4b06tFbnDFwW_Q%40mail.gmail.com.


Re: [go-nuts] types lookup for error interface type

2019-12-14 Thread 'Axel Wagner' via golang-nuts
whoops, I misread :) types.Type,, not reflect :)

On Sat, Dec 14, 2019 at 6:54 PM Axel Wagner 
wrote:

> https://play.golang.org/p/pdjKMn__ufA
>
> On Sat, Dec 14, 2019 at 10:07 AM Dan Kortschak  wrote:
>
>> In the go/types package there is an easy way to obtain a types.Type for
>> basic builtin types. This doesn't exist for the error type.
>>
>> Is there an easier way to get a types.Type representing error than by
>> using NewInterfaceType, NewFunc and NewSignature functions (I am
>> assuming that the nil *types.Package is what should be used for the
>> call to NewFunc).
>>
>> thanks
>> Dan
>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/golang-nuts/4fb681518e2e36e0d0564394546dd7879dd8f96a.camel%40kortschak.io
>> .
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEkBMfGmL2u_9P%2B7%2BHou%2BAP_SgPr3TKEOG4ab%3DyfpFzmi9F3tQ%40mail.gmail.com.


Re: [go-nuts] types lookup for error interface type

2019-12-14 Thread Marcin Romaszewicz
Error is an interface, so its type depends on the implementation satisfying
that interface. You can't just create an "error", since they don't exist,
all that exists are implementation satisfying the error interface. That's
what you're doing with NewSignature.

Could you just create an implementation of the error interface and
instantiate one of those?





On Sat, Dec 14, 2019 at 1:07 AM Dan Kortschak  wrote:

> In the go/types package there is an easy way to obtain a types.Type for
> basic builtin types. This doesn't exist for the error type.
>
> Is there an easier way to get a types.Type representing error than by
> using NewInterfaceType, NewFunc and NewSignature functions (I am
> assuming that the nil *types.Package is what should be used for the
> call to NewFunc).
>
> thanks
> Dan
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/4fb681518e2e36e0d0564394546dd7879dd8f96a.camel%40kortschak.io
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CA%2Bv29Lt2OX7CAqDnLy5-ABtjMPNPNFE22nRM9FikcFmJxRr7Uw%40mail.gmail.com.


[go-nuts] types lookup for error interface type

2019-12-14 Thread Dan Kortschak
In the go/types package there is an easy way to obtain a types.Type for
basic builtin types. This doesn't exist for the error type.

Is there an easier way to get a types.Type representing error than by
using NewInterfaceType, NewFunc and NewSignature functions (I am
assuming that the nil *types.Package is what should be used for the
call to NewFunc).

thanks
Dan

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4fb681518e2e36e0d0564394546dd7879dd8f96a.camel%40kortschak.io.