Skip to content

feat: allow opting out of text marshaling - #89

Open
efegokdemir wants to merge 1 commit into
Basekick-Labs:v6from
efegokdemir:fix/11-text-marshaler-option
Open

efegokdemir wants to merge 1 commit into
Basekick-Labs:v6from
efegokdemir:fix/11-text-marshaler-option

Conversation

@efegokdemir

Copy link
Copy Markdown

Summary

Types such as database null wrappers can implement encoding.TextMarshaler without representing all of their fields in the text form. Automatically selecting that interface can therefore lose data during round trips. This adds explicit opt-out controls while preserving the current default behavior.

Changes

  • Add Encoder.UseTextMarshaler(false) to encode the underlying value instead of its text representation.
  • Add Decoder.UseTextUnmarshaler(false) to decode the underlying value instead of invoking the text unmarshaler.
  • Keep both interfaces enabled by default for compatibility.
  • Add a regression test covering a struct whose text representation omits a field.

Testing

  • go test ./... — passed
  • go test -race ./... — passed
  • go vet ./... — passed
  • git diff --check — passed

Closes #11

Signed-off-by: Efe Gökdemir <efe@rexcode.co.uk>
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

Successfully merging this pull request may close these issues.

TextMarshaler breaks round-tripping for wrapper types (upstream #367)

1 participant