ForEach call the cb function for each object contained on this iter until an error happens or the end of the iter is reached. If ErrStop is sent the iteration is stop but no error is returned. The iterator is closed.
(cb func(Object) error)
| 205 | // an error happens or the end of the iter is reached. If ErrStop is sent |
| 206 | // the iteration is stop but no error is returned. The iterator is closed. |
| 207 | func (iter *ObjectIter) ForEach(cb func(Object) error) error { |
| 208 | return iter.EncodedObjectIter.ForEach(func(obj plumbing.EncodedObject) error { |
| 209 | o, err := iter.toObject(obj) |
| 210 | if err == plumbing.ErrInvalidType { |
| 211 | return nil |
| 212 | } |
| 213 | |
| 214 | if err != nil { |
| 215 | return err |
| 216 | } |
| 217 | |
| 218 | return cb(o) |
| 219 | }) |
| 220 | } |
| 221 | |
| 222 | func (iter *ObjectIter) toObject(obj plumbing.EncodedObject) (Object, error) { |
| 223 | switch obj.Type() { |