我是golang的新手,我写了一个程序来测试io包:
func 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) }