Skip to content

Marshal attachment values with durations in seconds - #121

Open
vitalivo wants to merge 1 commit into
gorilla:mainfrom
vitalivo:fix/json-attachment-value-duration
Open

vitalivo wants to merge 1 commit into
gorilla:mainfrom
vitalivo:fix/json-attachment-value-duration

Conversation

@vitalivo

Copy link
Copy Markdown

JSONAttachment.MarshalJSON currently has a pointer receiver, so json.Marshal(attachment) and map values bypass the seconds conversion and encode time.Duration in nanoseconds. Use a value receiver so both pointer and value forms implement json.Marshaler.

The new regression checks standalone values, pointers, and map values using a fractional duration. It fails for the two value forms before the fix. Full Go race tests (83.9% coverage) and vet pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant