Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// Stolen from
pr, pw := io.Pipe()
go func() {
// close the writer, so the reader knows there's no more data
defer pw.Close()
// write json data to the PipeReader through the PipeWriter
if err := json.NewEncoder(pw).Encode(&PayLoad{Content: "Hello Pipe!"}); err != nil {
// JSON from the PipeWriter lands in the PipeReader
// ...and we send it off...
if _, err := http.Post("", "application/json", pr); err != nil {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.