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) Reader

Parameters & Attributes

NameTypeDescription
readers...ReaderInput 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)}
Go Reference