GO語言"io"包中"MultiReader"函數的用法及代碼示例。
用法:
func MultiReader(readers ...Reader) Reader
MultiReader 返回一個 Reader,它是提供的輸入閱讀器的邏輯串聯。它們是按順序讀取的。一旦所有輸入都返回 EOF,Read 將返回 EOF。如果任何讀取器返回非零、非 EOF 錯誤,Read 將返回該錯誤。
例子:
package main
import (
"io"
"log"
"os"
"strings"
)
func main() {
r1 := strings.NewReader("first reader ")
r2 := strings.NewReader("second reader ")
r3 := strings.NewReader("third reader\n")
r := io.MultiReader(r1, r2, r3)
if _, err := io.Copy(os.Stdout, r); err != nil {
log.Fatal(err)
}
}
輸出:
first reader second reader third reader
相關用法
- GO MultiWriter用法及代碼示例
- GO Mul32用法及代碼示例
- GO Mul64用法及代碼示例
- GO MethodSet用法及代碼示例
- GO MakeFunc用法及代碼示例
- GO Mkdir用法及代碼示例
- GO Map用法及代碼示例
- GO MkdirTemp用法及代碼示例
- GO MakeTable用法及代碼示例
- GO Modf用法及代碼示例
- GO Mod用法及代碼示例
- GO MarshalIndent用法及代碼示例
- GO Marshal用法及代碼示例
- GO MatchString用法及代碼示例
- GO Month用法及代碼示例
- GO Match用法及代碼示例
- GO MkdirAll用法及代碼示例
- GO PutUvarint用法及代碼示例
- GO Scanner.Scan用法及代碼示例
- GO LeadingZeros32用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 MultiReader。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。