aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2021-05-02 23:36:12 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2021-05-02 23:36:12 +0200
commit67af9d7223b0cc643025d958c592291f7475ac75 (patch)
treea8d14d0e88fd57ae84c2614d7c2fb9c6527438a5 /utils
parentc69d5331743e49d3672897cf1c552e5e123d4509 (diff)
downloadgo-git-67af9d7223b0cc643025d958c592291f7475ac75.tar.gz
utils: ioutil, Pipe implementatio
Diffstat (limited to 'utils')
-rw-r--r--utils/ioutil/common.go12
-rw-r--r--utils/ioutil/pipe.go9
-rw-r--r--utils/ioutil/pipe_js.go9
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)
+}