Using XSLT With Go

I am working on a project that requires pulling and processing different XML feeds from the web and storing the data into MongoDB as JSON. Since new feeds come up everyday, changing the Go program to process and publish new feeds is out of the question. A second constraint is tha...

Form Validation and Processing in Go

In this post I want to outline a sensible pattern that you can use for validating and processing HTML forms in Go web applications. Over the years I've tried out a number of different approaches, but this is the basic pattern that I always keep coming back to. It's clear and unc...

Manage Dependencies With GODEP

Introduction If you are using 3rd party packages, (packages that you don't own or control), you will want a way to create a reproducible build every time you build your projects. If you use 3rd party packages directly and the package authors change things, your projects could bre...

HTTP Response Snippets for Go

Taking inspiration from the Rails layouts and rendering guide, I thought it'd be a nice idea to build a snippet collection illustrating some common HTTP responses for Go web applications. Sending Headers Only Rendering Plain Text Rendering JSON...

My Channel Select Bug

I was testing new functionality on a program that is already running in production when suddenly the code behaved very badly. What I saw shocked me and then it became obvious why it happened. I also have a race condition just waiting to be a problem. I have tried to provide a sim...

UP v2

So, this is the all-new UP version. It is more based on my own blog in some way, which is a some kind of branch of the theme. The biggest changes are: Assets are now managed by bower; Build are now made by grunt; Procfile.dev is provided to use with foreman to wa...

SkyDNS (Or The Long Road to Skynet)

SkyDNS and Skynet This article is in two sections. The first is the announcement of SkyDNS, a new tool to help manage service discovery and announcement.

Functions and Naked Returns In Go

In Go values that are returned from functions are passed by value. Go gives you some nice flexibility when it comes to returning values from a function. Here is a simple example of returning two values from a function: package main import (    "fmt" ) func mai...

Refactoring with go fmt

I’ve recently been getting into go. I’ve built a few applications and libraries. For this post, let’s explore the ‘gofmt’ or ‘go fmt’ tool further.

Understanding Mutexes

For anyone new to building web applications with Go, it's important to realise that all incoming HTTP requests are served in their own Goroutine. This means that any code in or called by your application handlers will be running concurrently, and there is a risk of race cond...