golang pipe

===============golang pipe==============
package main

import (
    "fmt"
    "io"
)

func main() {
    reader, writer := io.Pipe()
    inputData := []byte("1234567890ABCD")
    go writer.Write(inputData)
    outputData := make([]byte, 11)
    n, _ := reader.Read(outputData)
    fmt.Println(string(outputData))
    fmt.Println("read number", n)
    fmt.Println(string(outputData))

}

/*
1234567890A
read number 11
1234567890A
*/

 

posted on 2015-04-06 15:33  rojas  阅读(384)  评论(0编辑  收藏  举报