Phillip Trelford's Array

POKE 36879,255

Getting Go

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.

Go Cover

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.

Comments (2) -

  • hodzanassredin

    9/3/2015 12:53:28 AM |

    I had good experience with both go and F# for almost the same task in different companies. Mainly site crawling, some ml stuff and fast web sites(counters ala google analytics)

    What I like in golang:
    1. Speed and low memory consumption. Everything is highly optimized for system programming. Writing high load sites and ml alghoritms is ok for go.  
    2. String representtion.
    3. Extremely good writen core libs.
    4. Dev tools like trace, race detection, gofmt.
    Main dislike is a lack of generics but after some time I think it doesn't need them because it is against simplicity of go..
    And fsharp is a king in types so it is a good tool for building complex programs with a lot of logic. When you need to control high level of complexity.

  • hodzanassredin

    9/3/2015 1:02:33 AM |

    Forgot about async. Golnag doesn't pollute your code with async type, everything is implicit. One more plus is a preemptetive scheduler. Single model of concurrency with ability to use low level primitives is really good. You can easilly read other devs code.

Comments are closed