aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-15 23:09:33 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-15 23:09:33 +0200
commit6b9a59be60de5b66aee14e9160ace80734008eca (patch)
treec302776360b0fd4f774f67f177870fda478b4258 /examples
parented2e3b299e03e4bfd4c37bf5232e9fde05c0600d (diff)
downloadgo-git-6b9a59be60de5b66aee14e9160ace80734008eca.tar.gz
core: *Iter.ForEach method
Diffstat (limited to 'examples')
-rw-r--r--examples/basic/main.go19
1 files changed, 5 insertions, 14 deletions
diff --git a/examples/basic/main.go b/examples/basic/main.go
index e13b5d9..510b39d 100644
--- a/examples/basic/main.go
+++ b/examples/basic/main.go
@@ -2,7 +2,6 @@ package main
import (
"fmt"
- "io"
"os"
"gopkg.in/src-d/go-git.v4"
@@ -16,7 +15,7 @@ func main() {
panic(err)
}
- if err = r.Clone(&git.RepositoryCloneOptions{URL: url, Depth: 1, SingleBranch: false}); err != nil {
+ if err = r.Clone(&git.RepositoryCloneOptions{URL: url}); err != nil {
panic(err)
}
@@ -28,20 +27,12 @@ func main() {
defer iter.Close()
var count = 0
- for {
- //the commits are not shorted in any special order
- commit, err := iter.Next()
- if err != nil {
- if err == io.EOF {
- break
- }
-
- panic(err)
- }
-
+ iter.ForEach(func(commit *git.Commit) error {
count++
fmt.Println(commit)
- }
+
+ return nil
+ })
fmt.Println("total commits:", count)
}