Last active
June 5, 2022 12:11
-
-
Save narenaryan/40ec711ea401f32a2231163d98746781 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 ( | |
| "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