A space to discuss and keep up software development and manage your software career
An inclusive community for gaming enthusiasts
News and discussion of science and technology such as AI, VR, cryptocurrency, quantum computing, and more.
From composing and gigging to gear, hot music takes, and everything in between.
Memes and software development shitposting
Discussing AI software development, and showing off what we're building.
Movie and TV enthusiasm, criticism and everything in-between.
Web design, graphic design and everything in-between
A community for makers, hobbyists, and professionals to discuss Arduino, Raspberry Pi, 3D printing, and much more.
For engineers building software at scale. We discuss architecture, cloud-native, and SRE—the hard-won lessons you can't just Google
Discussing the core forem open source software project — features, bugs, performance, self-hosting.
Your central hub for all things security. From ethical hacking and CTFs to GRC and career development, for beginners and pros alike
A general discussion space for the Forem community. If it doesn't have a home elsewhere, it belongs here
A collaborative community for all things Crypto—from Bitcoin to protocol development and DeFi to NFTs and market analysis.
Quick pointer, because it's common in learning Go.
decoder := json.NewDecoder(ioutil.NopCloser(bytes.NewBuffer(p))) err = decoder.Decode(&Payload)
Is better done via Unmarshal:
err = json.Unmarshal(p, &Payload)
Decoders should be used when the incoming data is an io.Reader, to handle processing streams of data without buffering everything first. Once the data is buffered into a byte slice (by ValidatePayload), then Unmarshal is much more efficient.
io.Reader
ValidatePayload
Unmarshal
Good call! I used decoder in the first pass of the code and didn't think to swap over to unmarshal. I'll add a note to the post. 👍
decoder
unmarshal
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Quick pointer, because it's common in learning Go.
Is better done via Unmarshal:
Decoders should be used when the incoming data is an
io.Reader
, to handle processing streams of data without buffering everything first. Once the data is buffered into a byte slice (byValidatePayload
), thenUnmarshal
is much more efficient.Good call! I used
decoder
in the first pass of the code and didn't think to swap over tounmarshal
. I'll add a note to the post. 👍