You shouldn't need to do any more parsing - when you type checked the original program, the bytes package would have been loaded. (if it wasn't then you know for sure that the type isn't *bytes.Buffer).
You could do something like this: https://play.golang.org/p/7pn6G9PCPp (I used types.WriteExpr for the example as it was the first thing I came across that had a public signature involving *bytes.Buffer). cheers, rog. On 28 September 2016 at 15:04, Nate Finch <[email protected]> wrote: > Oh yes, that's smart, just use go/types to parse the bytes package. Great, > thanks! > > On Wednesday, September 28, 2016 at 9:27:20 AM UTC-4, Sebastien Binet wrote: >> >> >> >> On Wed, Sep 28, 2016 at 2:57 PM, <[email protected]> wrote: >>> >>> You need to actually get the type of a *bytes.Buffer with reflect.TypeOf >>> and compare types. >>> >>> https://play.golang.org/p/iqv16ibt9w >> >> >> OP is using go/types, not reflect. >> >> using something like so might work: >> >> https://play.golang.org/p/sJ8u6cZjZ1 >> >> (for some reason, it won't work in the playground...) >> >> hth, >> -s > > -- > 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 [email protected]. > For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
