Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: explain that unexported fields are not encoded/decoded #317

Open
Deleplace opened this issue Oct 11, 2021 · 0 comments
Open

Comments

@Deleplace
Copy link

Expected Behavior

The documentation should say more explicitly how it handles exported and unexported struct fields.

Current Behavior

The documentation doesn't say much about this (unless I missed the relevant section).

Possible Solution

The documentation would say upfront something like "Due to how visibility rules work in Go, the package msgpack will not access any of your struct's unexported fields (starting with a lowercase) even if they have a proper msgpack struct field tag. To make your field serializable/deserializable, make the fields public (or implement MarshalMsgpack and UnmarshalMsgpack). By default a public field results in a msgpack field name starting with an uppercase, but this can be avoided with a struct field tag. All of this is similar to how the standard library package json works."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant