Using Git from Go

Bonjour,

In the context of the Friendly Forge Format reference implementation in Go, I researched how to work with Git repositories in Go. The requirement is to do so in a way that is compatible with Gitea, i.e. that the Git CLI is called in a way that works with the most commonly known Operating system.

The Git package was moved in the Gitea repository about three years ago. It relies, in part, on the native go-git package which partly implements Git. In the words of the authors:

git is a humongous project with years of development by thousands of contributors, making it challenging for go-git to implement all the features.

The Gitea implementation calls the Git CLI via the exec package: it first creates a context, starts the process in the background and waits for its completion.

Cheers

1 Like