Standard library / io
io.MultiReader()
Reads each input sequentially until all reach EOF or a non-EOF error interrupts reading. Expected stdout: 'abcd <nil>\n'.
Formal Syntax & Structure
go syntaxgo
func MultiReader(readers ...Reader) ReaderParameters & Attributes
| Name | Type | Description |
|---|---|---|
| readers | ...Reader | Input readers in reading order. |
Return Value
Reader
Reads each input sequentially until all reach EOF or a non-EOF error interrupts reading.
Working Example
Example Snippetgo
package main
import ( "fmt" "io" "strings")
func main() { b, e := io.ReadAll(io.MultiReader(strings.NewReader("ab"), strings.NewReader("cd"))) fmt.Println(string(b), e)}