-
Notifications
You must be signed in to change notification settings - Fork 8k
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
use encode replace json marshal increase json encoder speed #1546
Conversation
itcloudy
commented
Sep 14, 2018
•
edited by thinkerou
Loading
edited by thinkerou
@itcloudy please fix unit test error, and can you give one link or doc about compare encode with marshal? thanks! |
Marshal => String |
@itcloudy build fail |
Codecov Report
@@ Coverage Diff @@
## master #1546 +/- ##
==========================================
- Coverage 98.74% 98.74% -0.01%
==========================================
Files 38 38
Lines 2145 2143 -2
==========================================
- Hits 2118 2116 -2
Misses 15 15
Partials 12 12
Continue to review full report at Codecov.
|
Hello, I'm sticking to Gin master revision since last week (to benefit from a dependency issue fix in master using gin + zerolog) and I agree more speed is good, but ... am I the only one shocked to have to cope with the additionnal "\n" that the use of Encode introduce or did I miss a way to remove it ? I mean it's the first time I see a framework forcing additional "\n" at the end of any JSON body data in responses (not that I've used many though ;) ) if we follow the documentation examples. I could use c.indentedJSON of c.asciiJSON but I don't want extra features, just plain JSON as I had before with c.JSON |
This felt like an early Xmas present. Between the disappearance of the gin/json package and a surprise newline character in my JSON payloads I really don't know which is more exciting. But seriously breaking changes on this project need to be much better controlled especially in minor revisions. |
How does using encoder increase speed? If I follow the code of encode, it calls marshal() which is the same as what Marshal calls. Am I missing something here? |
Marshal creates a copy https://cs.opensource.google/go/go/+/refs/tags/go1.22.0:src/encoding/json/encode.go;l=167 |