diff options
| author | Axel Wagner <[email protected]> | 2013-05-16 14:02:22 +0200 |
|---|---|---|
| committer | Axel Wagner <[email protected]> | 2013-05-16 14:02:22 +0200 |
| commit | 1da989e28b04807fb9781c3198769630ccb9a0fd (patch) | |
| tree | fe4f46646b0a448a2d4fa7e087e1d56a3f839355 | |
| parent | 140f362428d07ba130c4797b346e1bc2b8777b78 (diff) | |
Add Write(w io.Writer) to packbuilder
This wraps (*packbuilder).ForEach(), making it possible to write the
pack easiliy to a tcp-connection, a HTTP-Body or the like.
| -rw-r--r-- | packbuilder.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/packbuilder.go b/packbuilder.go index 40b2c81..6228e12 100644 --- a/packbuilder.go +++ b/packbuilder.go @@ -74,6 +74,17 @@ func (pb *Packbuilder) WriteToFile(name string) error { return nil } +func (pb *Packbuilder) Write(w io.Writer) error { + ch := pb.Foreach() + for _, slice := range ch { + _, err := w.Write(slice) + if err != nil { + return err + } + } + return nil +} + func (pb *Packbuilder) Written() uint32 { return uint32(C.git_packbuilder_written(pb.ptr)) } |
