Last active
June 5, 2022 12:12
-
-
Save narenaryan/5e8bcc937a6c96e9dc44d8180d16d123 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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