Three Questions From dotGo

With all the dotGo 2014 videos out now, I took an interest in the three questions Andrew Gerrand would ask each speaker in a back stage style interview. Every time I heard the questions, I would rack my brain to find the best answer I could come up with. So without further ado, he’s the questions and my responses.

What is the first Go program you wrote?

The first true Go program that I wrote eventually turned in to my first package called gapless. Its purpose was to listen to a Redis list, process the message, and send push notifications to Apple (which in turn pushed them to iOS devices). The original implementation was in python, and sending over 100,000 notifications a day would backlog the queue for long periods of time as it was a single threaded process. So after investigating Go for a while, I realized how goroutines could solve my current pains. This worked so well, that I ended up rewriting the API server in Go as well.

What’s your favorite bug?

This bug has nothing to do with Go, but it’s one of my favorites. I was working on an API that took a datetime like 2014-11-12 12:59:59.997 as a parameter. The consuming app was written in VB.NET and backed by a MSSQL 2008 database, and yes this is an important detail. This consumer app would look at the last element it had received, and send a datetime of that element to my API. My API would then return anything newer based on the datatime (and yes, there is a good reason we didn’t use a unique identifier for this). So it turns out MSSQL has a bit of an accuracy issue when dealing with datetimes. The consuming app would send a datatime like 2014-11-12 12:59:59.997 but actually it meant to send 2011-01-01 23:59:59.998, and thus my API would send a duplicate element back! Took a lot of back and forth to solve this little gem.

What is the worst code you have ever written?

This is an example of embarrassing code. The first site I was ever tasked to write needed a way to update the content without editing the source files. Today we would call this a CMS, and use some out-of-the-box solution like Drupal, Django or Wordpress. But being new to this crazy web world, I figured writing something from scratch would be the way to go. After creating a very crude administrative section, I decided to implement the most amazing and horrify feature… a form with a textarea that would take any data, and with no validation checking or escaping, run it on the database as a query. I’m happy to say I take security much more seriously these days.