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
This is consistent with the language itself. If you split your code into two separate packages, the importing package will also not be able to set the error field. The compiler will give an error like cannot refer to unexported field or method error. The reflect package always acts as though it is in a separate package (because it is) so this is working as intended.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I've embedded
error
into a struct, and tried to set this via reflection:https://play.golang.org/p/8dEZLTljtI3
What did you expect to see?
I can set the embedded field.
What did you see instead?
panic: reflect: reflect.Value.Set using value obtained using unexported field
It looks as if
error
is considered an unexported field based on the type name.The text was updated successfully, but these errors were encountered: