Skip to content

Instantly share code, notes, and snippets.

@narenaryan
Last active June 5, 2022 12:12
Show Gist options
  • Save narenaryan/5e8bcc937a6c96e9dc44d8180d16d123 to your computer and use it in GitHub Desktop.
Save narenaryan/5e8bcc937a6c96e9dc44d8180d16d123 to your computer and use it in GitHub Desktop.
package main
import (
"bytes"
"fmt"
"io"
)
func main() {
// Two empty buffers
var foo, bar bytes.Buffer
// Create a multi writer
mw := io.MultiWriter(&foo, &bar)
// Write message into multi writer
fmt.Fprintln(mw, "Hello Medium")
// Optional: verfiy data stored in buffers
fmt.Println(foo.String())
fmt.Println(bar.String())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment