Skip to content

Commit

Permalink
channel: warn about fragility of RawJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
creachadair committed Nov 17, 2021
1 parent 36b0a8d commit 13e92d8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions channel/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const bufSize = 4096
// RawJSON is a framing that transmits and receives records on r and wc, in which
// each record is defined by being a complete JSON value. No padding or other
// separation is added.
//
// A RawJSON channel has no out-of-band framing, so the channel cannot usually
// recover after a message that is not syntactically valid JSON. Applications
// that need a channel to survive invalid JSON should avoid this framing.
func RawJSON(r io.Reader, wc io.WriteCloser) Channel {
return jsonc{wc: wc, dec: json.NewDecoder(r), buf: make([]byte, bufSize)}
}
Expand Down

0 comments on commit 13e92d8

Please sign in to comment.