Communication Is An Interesting Thing

There has been a lot of talk about effective communication in my day-to-day lately. At work I have set goals to work on improving how I communicate with coworkers and superiors. On-line I see talk in communities about how to effectively conduct discussions and dialog. In all of this it seems that being able to talk about something, convince someone, or even disseminate information can be an interesting and challenging thing.

What makes this so dang hard??

Waiting For Goroutines to Finish Running Before Exiting

Swirly Lights Image copyright Faizal Sugi

Goroutines are primitives in Google’s Go language that allow a developer to easily write concurrent applications to make use of modern multi-core CPUs. Because these are baked into the language and super easy to use it becomes simple to make quick use of them in your applications. As you start to write more sophisticated server applications you realize you need a way to gracefully exit your application. This means that you may not want your application to exit before all your Goroutines are done executing. In this entry I’ll talk about one way to handle this with a sync.WaitGroup and channels.

Using A Middleware in Your Go Web Applications

Bikes Lined Up Image copyright Ryan McGuire

Middleware in Go HTTP applications is a way to chain HTTP handlers in a sequence to alter the request and response chain prior to your primary handler getting it. This is useful for activities such as logging, input sanitization, handling authorization and security, and more. This concept is supported in the Go standard library with functions like http.StripPrefix and http.TimeoutHandler. Each of the previously mentioned functions take a reference to a handler and return a new handler, wrapping the original with its own logic and processing of the request and response chain. In this post I will show how you can use a middleware called Alice to perform this task.

My First SVN Post-Commit Hook in Go - Part 2

Talking Image copyright Ryan McGuire

This is part two of the two part series on how I created a Subversion post-commit hook using Go, and post a message in a HipChat room. This post follows part one by talking about how to post the message to HipChat. I did this for the teams at my day job. Please note that certain pieces of code have been changed to protect the innocent, and opinions here do not necessarily reflect those of my employer.

In part one of this two part series I talked about how to execute svnlook.exe on the command line using Go, then capture that output. Once captured the idea is to post a message in HipChat (or any other communication platform, should you choose to) to let teams know what code is going into a trunk/master/main/release branch. Please note that this code demonstrates consuming the HipChat API v1, which was current enough at the time I wrote this hook. HipChat has now published version 2 of their API and will deprecate version 1.

My First SVN Post-Commit Hook in Go - Part 1

Man with headphones Image copyright Ryan McGuire

This is part one of a two part series on how I created a Subversion post-commit hook using Go, and post a message in a HipChat room. I did this for the teams at my day job. Please note that certain pieces of code have been changed to protect the innocent, and opinions here do not necessarily reflect those of my employer.

There has been an ongoing effort with the various teams I work with to improve code review. To provide more visibility to code being committed to our trunk branch in Subversion I decided a post-commit hook could help us achieve that visibility. This post-commit hook would send a message to a HipChat room, dedicated to reviewing code changes and information about each commit. This would allow teams to know when changes were made to our trunk branch and have the chance to review the code across teams. This strategy has been an effective one in reducing errors in code and improving overall code quality. This post will deal with utilizing Subversion to retrieve information about a commit. This information is what will be used in part 2 to post a message in HipChat.

JavaScript Multiselect Widget, With No jQuery!

Last night I decided to write a multi-select JavaScript widget. I need such a widget to allow the users of a little app I am working on to select one or more items. I wanted it to look a little more pretty than the default <select> box and I also didn’t want to force users to have to hold CTRL to select more than one item. I did a little searching around the internet and found a number of controls that do exactly what I want, but all of them required an external library, such as jQuery, Angular, and even Mootools. This particular project is not using jQuery on purpose which makes those libraries out of the question. So I start writing my own.


Response To Adam Cameron's Code Review

A few weeks ago I submitted a response to a code puzzle on Adam Cameron’s blog that I wrote using Go. He has (finally) submitted a review! First let me say that it is about time Mr. Cameron! I have waited with bated breath! That review can be read here. In this post I will comment on his commentary.

Handling CTRL+C In Go Command Line Applications

Command line and server-style application often allow you to press a key combination, such as CTRL+C to gracefully exit. In Go this is a pretty easy task to accomplish, and in this entry I will show you how you can add this ability in your own applications.

Deploying My First Go Application to Heroku

For the last week or so I’ve been converting a site I manage from WordPress to a simple Go application. There are three reasons I want to do this.

  1. WordPress has been extreme overkill for what I actually need
  2. Performance. WordPress on a shared host is just not fast enough for what I deem to be a super simple site
  3. I wanted to build something other than a server-style application in Go and I really enjoy writing Go code!

Returning an HTTP Server From a Function in Go

When building web applications in Go the most common example is one that sets up a handler for a specific URL route (endpoint) then fires up the HTTP server to listen for requests. It looks like this.

package main

import (


func main() {
    http.HandleFunc("/", versionController.GetVersion)
    http.ListenAndServe("", nil)

The above example shows the a basic case of listening on all IP address on port 8080, using the default ServeMux to handle routes. This is all well good, until the point where you may need more flexibility. I have reached that point.