Spyke

Syndicated from the fediverse. Read and engage on the original instance.

View original on azorius.net
golang·Golangbytedu

Scripting with Go: a 400-line 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).

https://benhoyt.com/writings/gogit/Open linkView original on azorius.net
15

No replies yet

No comments on the original post yet.