Scripting with Go: a 400-line Git client (benhoyt.com)
from tedu to golang@programming.dev on 30 Jul 2023 03:03
https://azorius.net/p/6MdZ116c4199Hn96s4-Scripting-with-Go-a-400line-Git-client

A few years ago I wrote pygit, a small Python program that’s just enough of a Git client to create a repository, add some commits, and push itself to GitHub.

I wanted to compare what it would look like in Go, to see if it was reasonable to write small scripts in Go – quick ’n’ dirty code where performance isn’t a big deal, and stack traces are all you need for error handling.

The result is gogit, a 400-line Go program that can initialise a repository, commit, and push to GitHub. It’s written in ordinary Go … except for error handling, which is just too verbose in idiomatic Go to work well for scripting (more on that below).

#golang@programming.dev

threaded - newest