Skip to content

Latest commit

 

History

History
47 lines (38 loc) · 1.09 KB

README.md

File metadata and controls

47 lines (38 loc) · 1.09 KB

pipe Go Report Card GoDoc

small package for reading pipe data

Installation

go get -u github.com/yaronsumel/pipe

Sync Usage

Read is Sync Action to get all pipe data fits in the predifened size

	data,err := pipe.Read(pipe.Stdin,1024)
	if err!=nil{
		//do something with the error
	}

Async Usage

AyncRead will keep reading from the pipe and write it back to StdDataChannel. Don't forget to handle the errors.

	StdinChannel := make(pipe.StdDataChannel)
	go pipe.AsyncRead(pipe.Stdin, 1024, StdinChannel)
	for {
		select {
		case stdin := <-StdinChannel:
			if stdin.Err != nil {
				panic(stdin.Err)
			}
			fmt.Println(stdin.Data)
		}
	}

Working Example

get the command

go get -u github.com/yaronsumel/pipe/pipe-example

run it.pipe it.that's it.

pipe-example --write | pipe-example