diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-11-15 16:23:34 -0500 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-11-15 16:23:34 -0500 |
commit | 3744c70711bce0ab92cc47d7fa9a58f7882cc1e5 (patch) | |
tree | 1ce4e42cb3d441400acf276dfc948754a4f16bdb | |
parent | 29c005aded55168631029f9b129ff812ff96f802 (diff) |
add CatBlobWriter
-rw-r--r-- | io.go | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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 +} |