Skip to content

Instantly share code, notes, and snippets.

@narenaryan
Last active June 5, 2022 12:11
Show Gist options
  • Select an option

  • Save narenaryan/40ec711ea401f32a2231163d98746781 to your computer and use it in GitHub Desktop.

Select an option

Save narenaryan/40ec711ea401f32a2231163d98746781 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"io"
"strings"
)
func main() {
// Create two readers
foo := strings.NewReader("Hello Foo\n")
bar := strings.NewReader("Hello Bar")
// Create a multi reader
mr := io.MultiReader(foo, bar)
// Read data from multi reader
b, err := io.ReadAll(mr)
if err != nil {
panic(err)
}
// Optional: Verify data
fmt.Println(string(b))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment