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

Encoder: add SetAddExtraNewline option to json.Encoder #119

Merged
merged 4 commits into from
Feb 16, 2022
Merged

Encoder: add SetAddExtraNewline option to json.Encoder #119

merged 4 commits into from
Feb 16, 2022

Conversation

Jerska
Copy link
Contributor

@Jerska Jerska commented Feb 16, 2022

Closes #118

This PR introduces a new Encoder option, toggled with SetAddExtraNewline.
Its default value is true, matching encoding/json's behavior.

Setting it to false allows to use the encoder without having to handle this newline with the output.

There are for instance multiple locations in the tests where newlines are explicitly added to the expected value. Using this option would allow not to have to think about it, making the code a little bit easier to follow.

json/json.go Outdated Show resolved Hide resolved
json/json.go Outdated Show resolved Hide resolved
json/json.go Outdated Show resolved Hide resolved
Copy link
Contributor

@achille-roussel achille-roussel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great, thanks for the contribution!

@achille-roussel achille-roussel merged commit 886f222 into segmentio:master Feb 16, 2022
@Jerska Jerska deleted the encode-add-extra-newline branch February 16, 2022 17:44
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.

Proposal: add an option to prevent encoder from adding a newline on Encode
2 participants