summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-11-15 16:23:34 -0500
committerLuke Shumaker <lukeshu@lukeshu.com>2017-11-15 16:23:34 -0500
commit3744c70711bce0ab92cc47d7fa9a58f7882cc1e5 (patch)
tree1ce4e42cb3d441400acf276dfc948754a4f16bdb
parent29c005aded55168631029f9b129ff812ff96f802 (diff)
add CatBlobWriter
-rw-r--r--io.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/io.go b/io.go
index f977b73..d8a68bb 100644
--- a/io.go
+++ b/io.go
@@ -132,3 +132,21 @@ retry:
line = _line[:n+len(line)]
return
}
+
+type CatBlobWriter struct {
+ w io.Writer
+}
+
+func (cbw *CatBlobWriter) WriteLine(a ...interface{}) error {
+ _, err := fmt.Fprintln(cbw.w, a...)
+ return err
+}
+
+func (cbw *CatBlobWriter) WriteBlob(sha1 string, data []byte) error {
+ err := cbw.WriteLine(sha1, "blob", len(data))
+ if err != nil {
+ return err
+ }
+ _, err = cbw.w.Write(data)
+ return err
+}