Monday, December 10, 2012


Go's time.Time already have Format, which is very human readable. However if you try to "embed" time format in longer strings, Format might expand things that you want to stay fixed. Take for example "/report06/2006", the first "06: will be expanded to the current year.

Python's strftime is less human readable but requires explicit escaping to it's easier to write string with embedded time directives. Now you can have strftime in Go as well.

To get it, run the usual go get

Tuesday, December 4, 2012


I wanted to play a bit with cgo. As a project I tried to have Go bindings to snowball.

One of the problems was that snowball does not come as a library but an archive of sources. cgo can handle C source files, but all in the same directory. I had to "flatten" the source tree, rewriting #include directives (sed FTW!).

One the above was done, the rest was pretty much straightforward. I confess that at the beginning I wanted to write a lot of C helper functions, but managed to resist the temptation :)

You can get it with go get Note the building takes time - that's C compilation for you :)

Friday, October 26, 2012

nrsc - Take 2

After getting some good comments on nrsc and reading more. I re-wrote the implementation to append a zip file to the executable and serve resources from there (idea from Carlos Castillo).

The order you do the packing has change, you first "go build" and then run the nrsc script.

Here the nrsc script that packs the zip into the executable. The nrsc API didn't change that much.

Tuesday, October 23, 2012

nrsc - Resource Compiler

IMO one of the nicest things in Go is the "single executable deployment". However this breaks down when you have some templates, css files, ...

For this I created nrsc, it's a resource compiler that will compile your resources to a local nrsc package which you can include in your project. Building your project after running nrsc will embed all the resource in the executable.

To install nrsc just run go get

Here's an example on how to use nrsc in your code:

Friday, September 21, 2012

Jenkins/Hudson Integration

The most dominate CI system is Jenkins (was Hudson).

Jenkins has a nice integration with xunit XML output for tests. I wrote a little utility that converts go test -v output to xunit compatible XML called go2xunit. (install with the usual go get

The view on Jenkins (tests are failing intentionally) is like the below.

When you click on the tests you get

There's a demo directory with an example bash script. The project configuration looks something like the below. Note the "Execute Shell" command and "Publish JUnit tests report" sections.

Happy Testing.

Thursday, September 6, 2012

seamless - now with multiple backends

Updated seamless to support multiple backends (thank you Fabrizio for helping out).

The new API is:
  • /set?backends=host:port,host:port
  • /add?backend=host:port
  • /remove?backend=host:port
  • /get
The front end will round-robin between the backends.

You can install either via go get or by downloading the binaries.
/* MIKI: Analytics */