Start simple: use a *bytes.Buffer, and help the GC with using a sync.Pool for those buffers.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/aea5ff9b-db0f-4bb5-abfb-82a2f54f7ae1%40googlegroups.com.
Just put the missing [,] chars wher it's required with buf.WriteByte.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/00bb4351-e400-46a6-aec1-05124a966410%40googlegroups.com.
Yes, I also need to put '[' at first and ']' at last position. But I was checking if there is any better way to do it. I was even having question how can someone make it better without unmarshalling JSON and remarshalling merged object.
On Mon, Jan 20, 2020 at 4:12 AM Tamás Gulácsi <tgula...@gmail.com> wrote:
Just put the missing [,] chars wher it's required with buf.WriteByte.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/71b5beb8-31e3-4894-9575-ee3c04514e2a%40googlegroups.com.
You could use json iterator’s Stream type if you prefer to feel better by having it wrapped in a library. It does the same thing of course. As the name suggests it can be used to incrementally write the json to a writer if that’s what you’d like.
https://godoc.org/github.com/json-iterator/go#Stream
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/202ffb33-2f22-443b-9115-35d1fd93187d%40googlegroups.com.