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

Document pitfall with custom marshal/unmarshal implementations #329

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ that satisfy the `easyjson.Marshaler` / `easyjson.Unmarshaler` interfaces.
These will be used by `easyjson.Marshal` and `easyjson.Unmarshal` when defined
for a Go type.

Note: easyjson does not currently skip code generation for types which already define their own `MarshalEasyJSON`/`UnmarshalEasyJSON`
functions, meaning that code generation will result in duplicate method errors like:

`(*MyStruct).UnmarshalEasyJSON redeclared in this block`

This can be avoided by excluding types with custom marshalling behavior from easyjson code generation, either using
`//easyjson:skip` (with `-all`) or by simply not including them in the `easyjson` invocation.

Go types can also satisfy the `easyjson.Optional` interface, which allows the
type to define its own `omitempty` logic.

Expand Down