Go is a programming language developed at Google, loosely based on C, adding garbage collection and built-in concurrency primitives (goroutines).
I’ve looked at Go briefly in the past, at a Strangeloop workshop in 2012 and later reading An Introduction to Programming in Go, but until now not really done anything with it.
Recently I’ve been hearing some positive things about Go, so I thought I’d give it a go this evening on a simple task: downloading and unzipping a Nuget package.
Some language highlights:
- Extensive libraries of functions with good documentation
- Named and anonymous functions
- Multiple return values from functions
- No semi-colons required
- No class inheritance hierarchies
- Easy cleanup with the defer statement
Go is easy to install (an msi in Windows) and I found Notepad and the command line compiler sufficient to complete the tasks.
Task 1: List Nuget package versions
Nuget has a web API that returns the available versions of a specified package as a JSON array.
This task was pretty easy using Go’s http and json libraries:
Task 2: Download a Nuget package (zip) file
Again the http package made light work of this task:
Task 3: Download and Unzip a Nuget package
Yet again I simply needed to import a package this time the zip package:
For the Nuget download task, Go was easy to pick up and quite pleasant; syntax-wise it felt a little lighter than C#, but in the bigger scheme of things was still a way off the lightness that comes with F# and OCaml's type inference. That said, if I had to choose between C# and Go, then I'd be tempted to give Go another go.