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
In general the reflect package permits you to do exactly the operations that the language permits you to do. However, the reflect package is given special dispensation to read unexported fields, even though they can not be read in the language, because otherwise it would be impossible to implement the fmt package. That is what you are observing. If we think that consistency of Read and Write in the encoding/binary package is important, then the fix is going to be to change Write to reject unexported fields.
What version of Go are you using (
go version
)?1.9.2
What did you do?
https://play.golang.org/p/aa0RIwHB_2
What did you expect to see?
If
Write
can encode the struct,Read
can decode it.What did you see instead?
Read
panics:Probably #Go2, unless there's a way to make
Read
decode structs with unexported fields.The text was updated successfully, but these errors were encountered: