You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
StructOf currently does not generate wrapper methods for embedded fields.
This limitation may be lifted in a future version.
So the expectation is that if I generate a struct using StructOf that embeds *bytes.Buffer, it does not implement io.Writer.
https://play.golang.org/p/R9mDLLNMje demonstrates that this is not true: the
generated struct claims to implement io.Writer, can be casted to it, and a Write call on that io.Writer gets delegated to the right *bytes.Buffer.
What did you expect to see?
Implements io.Writer: false
Can cast to io.Writer: false
What did you see instead?
Implements io.Writer: true
Can cast to io.Writer: true
Wrote: hello
See also #20633 for inconsistent behavior when the method is unexported.
The text was updated successfully, but these errors were encountered:
The current situation is that it sometimes works and sometimes doesn't. Try adding another field to your StructOf call, such that the interface is not the first field. Horrible things will happen.
The general issue is #15924. Let's move any discussion there. Closing this issue.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
The documentation for
reflect.StructOf
states,So the expectation is that if I generate a struct using
StructOf
that embeds*bytes.Buffer
, it does not implementio.Writer
.https://play.golang.org/p/R9mDLLNMje demonstrates that this is not true: the
generated struct claims to implement
io.Writer
, can be casted to it, and aWrite
call on thatio.Writer
gets delegated to the right*bytes.Buffer
.What did you expect to see?
What did you see instead?
See also #20633 for inconsistent behavior when the method is unexported.
The text was updated successfully, but these errors were encountered: