diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/ioutil/common.go | 12 | ||||
-rw-r--r-- | utils/ioutil/pipe.go | 9 | ||||
-rw-r--r-- | utils/ioutil/pipe_js.go | 9 |
3 files changed, 29 insertions, 1 deletions
diff --git a/utils/ioutil/common.go b/utils/ioutil/common.go index e9dcbfe..b52e85a 100644 --- a/utils/ioutil/common.go +++ b/utils/ioutil/common.go @@ -7,7 +7,7 @@ import ( "errors" "io" - "github.com/jbenet/go-context/io" + ctxio "github.com/jbenet/go-context/io" ) type readPeeker interface { @@ -168,3 +168,13 @@ func (r *writerOnError) Write(p []byte) (n int, err error) { return } + +type PipeReader interface { + io.ReadCloser + CloseWithError(err error) error +} + +type PipeWriter interface { + io.WriteCloser + CloseWithError(err error) error +} diff --git a/utils/ioutil/pipe.go b/utils/ioutil/pipe.go new file mode 100644 index 0000000..f30c452 --- /dev/null +++ b/utils/ioutil/pipe.go @@ -0,0 +1,9 @@ +// +build !js + +package ioutil + +import "io" + +func Pipe() (PipeReader, PipeWriter) { + return io.Pipe() +} diff --git a/utils/ioutil/pipe_js.go b/utils/ioutil/pipe_js.go new file mode 100644 index 0000000..cf102e6 --- /dev/null +++ b/utils/ioutil/pipe_js.go @@ -0,0 +1,9 @@ +// +build js + +package ioutil + +import "github.com/acomagu/bufpipe" + +func Pipe() (PipeReader, PipeWriter) { + return bufpipe.New(nil) +} |