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
+12.1k Golang : Pagination with go-paginator configuration example
+8.2k How to show different content from website server when AdBlock is detected?
+30k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+11.3k Golang : Byte format example
+14.6k Golang : Send email with attachment(RFC2822) using Gmail API example
+11.1k Golang : Fix go.exe is not compatible with the version of Windows you're running
+16k Golang : Get sub string example
+9.2k nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
+7.1k Golang : Gorrila mux.Vars() function example
+9.7k PHP : Get coordinates latitude/longitude from string
+12.1k Golang : Perform sanity checks on filename example
+15.6k Golang : How to convert(cast) IP address to string?