Gobble Developments

I’ve just pushed some new changes to the master branch of the Gobble git repository. Mostly I’ve been refactoring the code to be tidier and take advantage of features of the Go language, but I’ve also made some more interesting changes.

As a result of experimenting with closures, Gobble’s list of static files is now user-definable. Previously, only two files could be served from the root of a Gobble blog: robots.txt and favicon.ico. It seems that a single favicon is no longer sufficient, so the config file can now include a dictionary of static file definitions.

For example, this blog includes the following in its config file:

"staticFiles": {
    "/favicon.ico": "favicon.ico",
    "/robots.txt": "robots.txt"

The key is the URL of the file relative to the root URL of the blog; the value is its path on the local filesystem, relative to a new staticFilePath setting.

Gobble has a new syntax highlighting library: Rainbow is out and highlight.js is in. The new library features automatic language detection, which makes marking up code easier. Now it’s possible to just use Markdown-style indenting to indicate a code block instead of including pre and code tags with a data-language attribute.

The correct “Leave a comment” text is shown for all situations: singular, plural, no comments, and comments disabled. Until now Gobble only handled the “no comments” and “plural comments” situation. I couldn’t figure out why I hadn’t fixed that problem before now - other than the awful, awful template docs and the useless errors that the templates spit out if there’s a bug, that is - until I installed the changes on this server and took the whole blog down. It seems the fix relies on features on Go 1.2, so I had to use godeb to get the latest version of the language installed.

Posts and comments are now stored in RAM in both HTML and plain text formats. The plain text versions are searched instead of the HTML versions.


Dropbox Synced Blog

Updating a Gobble blog is now much faster due to the addition of the fsnotify library. The library watches a blog’s “posts” directory and, when anything changes, causes Gobble to refresh its post and comment cache. New posts, edits and deletions now occur instantly. The old 10 minute wait for the timer to expire has gone.

In related news, the content of Simian Zombie now gets synced to the server by Dropbox. The old workflow looked like this:

  • Write a post;
  • Commit to Git;
  • Push to BitBucket;
  • Connect to server;
  • Pull from BitBucket;
  • Restart Gobble to force a refresh.

The new workflow looks like this, thanks to fsnotify and Dropbox:

  • Write a post.

Much nicer. I can even edit posts on my phone without having to use SSH and Vim.

I had a few false starts. The initial idea was to use BitTorrent Sync, not Dropbox, as I thought it would be easier to set up. Unfortunately, the documentation for CLI-only installs is half-baked and, after an hour or so of tinkering, I switched to Dropbox instead. Dropbox had its own share of issues, the most annoying of which was a segfault at startup in the current version. Switching to the latest beta fixed that.


Gobble Updates

Gobble (and therefore Simian Zombie) has received a few updates:

  • The RSS feed now works and implements the Atom standard.
  • The current search term is displayed as a placeholder in the “search” box.
  • Comments can be disabled on a per-post basis.

The post workflow could be made simpler by adding an admin section, but Gobble is holding up well so far. It compiled first time with the new Go 1.1 compiler, which was nice.



A year or so ago I wrote my own blogging engine in C#, and then a while later pointed out some of the worst flaws in the system. The major one for me was the choice of platform:

…using C# means I have to maintain a Windows virtual machine, an installation of VMWare Fusion and a copy of Visual Studio. That’s far too much overhead for something that could be written in a few hundred lines of Go and deployed on any cheap Linux server.

I’ve rectified that with a new blogging engine called Gobble, written in Go. Although it blew away my initial estimate and ended up consisting of 6000 lines of code, CSS and HTML templates (etc), it fulfils my goal of being a blogging engine that:

  • Consists of a single binary;
  • Uses the file system for post storage instead of a database;
  • Supports comments;
  • Uses Akismet and reCAPTCHA for spam prevention;
  • Uses Markdown for post/comment formatting;
  • Can be deployed easily to a cheap Linux server/VPS;
  • Has a search feature;
  • Supports tags.

It has a lot of features that I like in WordPress that didn’t make it into BitBlogger, including search, self-hosted comments, syntax highlighting and more. It even retains the WordPress post ID-based URLs (as a secondary way to link to a post) to ensure that it’s a drop-in replacement as far as external links are concerned. It omits WordPress features that I don’t care about, such as categories, plugins, a fancy admin section and others.

Gobble uses a similar in-memory data storage system to BitBlogger, but this time there’s no enforced shutdown that kills the cache. I’d considered using MongoDB, CouchDB or RethinkDB for data storage, but in the end I realised that the entire textual content for this blog fits in 2MB. A database wouldn’t add anything but unnecessary complexity for managing that tiny amount of data. Posts are stored on disk on the same server as the Gobble executable. I can still use Mercurial and BitBucket to store the posts; I just need to SSH to the VPS in order to pull and update. In future I might add simple admin section that allows me to edit posts in a web browser and view new comments/spam.

I’ve got a complete copy of this blog running in Gobble on a VPS from Digital Ocean. It works well, but some of the formatting of the posts is a bit screwy (it got lost during translation from HTML to Markdown). Once I fix the formatting I’m intending to switch away from my WordPress installation to Gobble.

My only concern with migrating platforms is the fact that moving the simianzombie.com domain to the VPS means I’ll have to run my own mail server, which sounds thoroughly tedious.

More Thoughts on Go

In some ways I find Go a little awkward to write. Working with pointers is identical to working with values directly (unlike in C in which you have to manually dereference pointers) so it’s frequently hard to tell if you’ve got a pointer or a value. Sometimes it’s nice not to care; at other times it’s handy to know if you’re editing a copy of a struct or the original struct (via a pointer), and the language hides that information. Switching back to a more procedural rather than OO paradigm involves some extra thought in deciding how best to structure the app. I’m still of the opinion that Go’s naming conventions are ridiculously anachronistic, and some of the design decisions in the libraries are bloody stupid (sorting and comparison functions are defined on the container rather than the items being sorted and compared, for example).

At the same time, it has some very nice features. Compiling down to a single binary makes Go programs trivial to deploy. Defining structs with associated methods instead of objects makes a lot of sense, and hopefully it should prevent Java-esque program architectures. The concept of implicit interfaces is very reminiscent of Objective-C’s informal protocols and works well. I’ve found that I can write programs in Go extremely quickly, and I’ll get faster as I become more familiar with how to best structure programs and the available libraries.


DL/ID Parser Library For Go

I’ve published an initial version of my US DL/ID barcode data parser library here:

This is a library for Go that can parse the data extracted from the PDF417 barcode on the back of a US driving licence into a Go struct. It doesn’t handle many of the encoded fields yet but it’s a start. I’ve grumbled about the multiple problems with the spec and its various implementations before.