From 1f39465975d56bbb02f5cdfb1e3e77f41c613f1d Mon Sep 17 00:00:00 2001 From: "Santiago M. Mola" Date: Tue, 7 Feb 2017 10:02:20 +0100 Subject: doc: improve object iterators godoc. --- plumbing/object/file.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'plumbing/object/file.go') diff --git a/plumbing/object/file.go b/plumbing/object/file.go index 618cea7..4caed6b 100644 --- a/plumbing/object/file.go +++ b/plumbing/object/file.go @@ -56,15 +56,20 @@ func (f *File) Lines() ([]string, error) { return splits, nil } +// FileIter provides an iterator for the files in a tree. type FileIter struct { s storer.EncodedObjectStorer w TreeWalker } +// NewFileIter takes a storer.EncodedObjectStorer and a Tree and returns a +// *FileIter that iterates over all files contained in the tree, recursively. func NewFileIter(s storer.EncodedObjectStorer, t *Tree) *FileIter { return &FileIter{s: s, w: *NewTreeWalker(t, true)} } +// Next moves the iterator to the next file and returns a pointer to it. If +// there are no more files, it returns io.EOF. func (iter *FileIter) Next() (*File, error) { for { name, entry, err := iter.w.Next() -- cgit