我是golang的新手,我写了一个程序来测试io包:
原文链接:https://www.f2er.com/go/186803.htmlfunc main() { readers := []io.Reader{ strings.NewReader("from string reader"),bytes.NewBufferString("from bytes reader"),} reader := io.MultiReader(readers...) data := make([]byte,1024) var err error //var n int for err != io.EOF { n,err := reader.Read(data) fmt.Printf("%s\n",data[:n]) } os.Exit(0) }