context.JSON() adds a new line character \n to end of JSON response
Clone this repo and run
$ GIN_MODE=release go run gin-newline.go
Newline character ("\n") must not get added to the end of {"message":"hello world"}
new line character gets added
Before 1.5, context.JSON was using json.Marshal Refer Here. In 1.5 this was changed to use encoder.Encode(). Refer Change
Encoder adds a line at the end. Refer to this code
An issue about this is raised in the golang repository also.
Linking the PR which caused this issue in the name of performance improvement trading correctness and that too without performance numbers.
I am also facing an issue because of this redundant newline character addition.
I have a java service that sits in front a go service that is using gin framework.
Hence, the consumers of my java service are getting a content length mismatch issue between content-length header and actual content body.

Most helpful comment
I am also facing an issue because of this redundant newline character addition.
I have a java service that sits in front a go service that is using gin framework.
Hence, the consumers of my java service are getting a content length mismatch issue between content-length header and actual content body.