Created
May 25, 2016 20:23
-
-
Save calvn/2d483971f64dd0db1e6c6bd314356a19 to your computer and use it in GitHub Desktop.
git2go BranchIterator ForEach() bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"path/filepath" | |
"gopkg.in/libgit2/git2go.v24" | |
) | |
func main() { | |
p := filepath.Join(os.TempDir(), "sample-data") | |
err := os.Mkdir(p, 0777) | |
if err != nil { | |
panic(err) | |
} | |
repo, err := git.Clone("https://github.com/libgit2/TestGitRepository", p, &git.CloneOptions{}) | |
if err != nil { | |
panic(err) | |
} | |
itr, err := repo.NewBranchIterator(git.BranchLocal) | |
if err != nil { | |
panic(err) | |
} | |
defer itr.Free() | |
var f = func(_ *git.Branch, _ git.BranchType) error { | |
return nil | |
} | |
err = itr.ForEach(f) // This doesn't return nil, but instead an empty string | |
if err != nil { | |
fmt.Printf("Error: %s Length: %d", err.Error(), len(err.Error())) | |
} | |
defer func() { | |
os.RemoveAll(p) | |
}() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment