GPLv2: Show HN: go-git2 – libgit2 as pure Go, 10-100x faster than go
In this story
go-git2 is a Go git library (read-only for now) using libgit2 transpiled to Go with wasm2go. As a result, it builds with CGO_ENABLED=0 and cross-compiles without a C toolchain. It supports 64-bit Linux, macOS, and Windows today.<p>While go-git has been great for my uses, its performance on larger repos and quirky differences from the git CLI output have been tricky to work with. I'm a huge fan of wasm2go and go-sqlite3 and wanted to apply the same approach and see what could be done. Incredibly happy with the results thus far, with 10-100x improvements on my real-world use cases. On the django repo, finding commits touching a file goes from 40s with go-git to 350ms, against 255ms for git itself. And the only unsafe is in wasm2go's bounds-checked memory accesses!<p>The API follows go-git v5, so read-only code is mostly a drop-in (still a few constructs to port). Write support is down the road.<p>The main module is MIT and the libgit2 module keeps the upstream license (GPLv2 w/ linking exception).<p>Give it a go!
go-git2 is a Go git library (read-only for now) using libgit2 transpiled to Go with wasm2go. As a result, it builds with CGO_ENABLED=0 and cross-compiles without a C toolchain. It supports 64-bit Linux, macOS, and Windows today.<p>While go-git has been great for my uses, its performance on larger repos and quirky differences from the git CLI output have been tricky to work with. I'm a huge fan of wasm2go and go-sqlite3 and wanted to apply the same approach and see what could be done. Incredibly happy with the results thus far, with 10-100x improvements on my real-world use cases. On the django repo, finding commits touching a file goes from 40s with go-git to 350ms, against 255ms for git itself. And the only unsafe is in wasm2go's bounds-checked memory accesses!<p>The API follows go-git v5, so read-only code is mostly a drop-in (still a few constructs to port). Write support is down the road.<p>The main module is MIT and the libgit2 module keeps the upstream license (GPLv2 w/ linking exception).<p>Give it a go!