Golang io.MultiReader function example
package io
Golang io.MultiReader function usage example
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
)
func main() {
reader := bytes.NewReader([]byte("abcdefghijkl"))
reader2 := bytes.NewReader([]byte("mnopqrstuvwxyz"))
buff := []io.Reader{reader, reader2}
// FROM http://golang.org/pkg/io/#MultiReader
// MultiReader returns a Reader that's the logical concatenation
// of the provided input readers. They're read sequentially.
combined := io.MultiReader(buff...)
data, _ := ioutil.ReadAll(combined)
fmt.Println(string(data))
}
Output :
abcdefghijklmnopqrstuvwxyz
Reference :
Advertisement
Something interesting
Tutorials
+20.9k Golang : Underscore or snake_case to camel case example
+15.2k Golang : How to check if IP address is in range
+20.6k Golang : Secure(TLS) connection between server and client
+9.2k Golang : Write multiple lines or divide string into multiple lines
+29.7k Golang : Record voice(audio) from microphone to .WAV file
+5.9k Unix/Linux : How to open tar.gz file ?
+22.4k Golang : Read directory content with filepath.Walk()
+14.5k How to automatically restart your crashed Golang server
+18k Golang : Get all upper case or lower case characters from string example
+9.2k Golang : does not implement flag.Value (missing Set method)
+8.8k Golang : Executing and evaluating nested loop in html template
+7.4k Golang : Word limiter example