diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-22 03:29:05 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-22 03:29:05 +0200 |
commit | 2ed3474ab8e52c98a87e390d5128d45d693a115d (patch) | |
tree | 6f136c2508c22f6b5146ef08c49821a45a5f2357 /core | |
parent | 5b13c1a2e55cb442484d9c7b45389f422b110eec (diff) | |
download | go-git-2ed3474ab8e52c98a87e390d5128d45d693a115d.tar.gz |
ForEach review and Commit.Tree err return
Diffstat (limited to 'core')
-rw-r--r-- | core/object.go | 7 | ||||
-rw-r--r-- | core/reference.go | 3 |
2 files changed, 7 insertions, 3 deletions
diff --git a/core/object.go b/core/object.go index d777f4a..9c9a74e 100644 --- a/core/object.go +++ b/core/object.go @@ -141,8 +141,10 @@ func (iter *ObjectLookupIter) Next() (Object, error) { // ForEach call the cb function for each object contained on this iter until // an error happends or the end of the iter is reached. If ErrStop is sent -// the iteration is stop but no error is returned +// the iteration is stop but no error is returned. The iterator is closed. func (iter *ObjectLookupIter) ForEach(cb func(Object) error) error { + defer iter.Close() + for _, hash := range iter.series { obj, err := iter.storage.Get(hash) if err != nil { @@ -197,8 +199,9 @@ func (iter *ObjectSliceIter) Next() (Object, error) { // ForEach call the cb function for each object contained on this iter until // an error happends or the end of the iter is reached. If ErrStop is sent -// the iteration is stop but no error is returned +// the iteration is stop but no error is returned. The iterator is closed. func (iter *ObjectSliceIter) ForEach(cb func(Object) error) error { + defer iter.Close() for _, o := range iter.series { if err := cb(o); err != nil { if err == ErrStop { diff --git a/core/reference.go b/core/reference.go index c33402c..16b60ac 100644 --- a/core/reference.go +++ b/core/reference.go @@ -182,8 +182,9 @@ func (iter *ReferenceSliceIter) Next() (*Reference, error) { // ForEach call the cb function for each reference contained on this iter until // an error happends or the end of the iter is reached. If ErrStop is sent -// the iteration is stop but no error is returned +// the iteration is stop but no error is returned. The iterator is closed. func (iter *ReferenceSliceIter) ForEach(cb func(*Reference) error) error { + defer iter.Close() for _, r := range iter.series { if err := cb(r); err != nil { if err == ErrStop { |