defer Panic

Logging Panics in Go Lang on Android

To say that we are pretty pumped about today’s release of golang 1.4 that includes official android support is an understatement.

We believe android is really going to propel go’s popularity. I mean - it’s not that it doesn’t already have killer apps - docker anyone? However, now the ecosystem has just opened up an entirely new world of software engineer that is more than willing to use it.

Huge shoutout to David Crawshaw and the rest of the go team for making this happen!

We were really interested in seeing how easy it would be to integrate deferpanic support in so we could defer our panics, log our errors and watch memory and goroutines over time.

Turns out - it’s incredibly easy.

Ready to get started building android apps with golang?

The repo you will be interested in is:

The instructions are already pretty clear but I’ll go ahead and crosspost here:

Definitely use the dockerfile provided:

go get -d
docker build -t mobile $GOPATH/src/

Now create a regular go project just like normal && cp over the template:

mkdir -p ~/go/src/
cp -R ~/go/src/ \


docker run -v $GOPATH/src:/src mobile /bin/bash -c 'cd /src/ && ./make.bash'


Then once you launch it you can see from logcat that we are executing.

and you can see the error that was captured and posted to your deferpanic dashboard.


As you can see - we’ve only added the two deferpanic imports and our token. After that any errors that are instatiated will be shot up to your deferpanic dashboard.

import (


var (
    program  gl.Program
    position gl.Attrib
    offset   gl.Uniform
    color    gl.Uniform
    buf      gl.Buffer

    green    float32
    touchLoc geom.Point

func main() {
    deferclient.Token = "v00L0K6CdKjE4QwX5DL1iiODxovAHUfo"

    err := errors.New("warning from android!")

    if err != nil {

        Draw:  draw,
        Touch: touch,

You can get the full code here:

but as we mentioned - we only added a few lines. The example on the gomobile repo is missing internet access permissions so you’ll need to add those or yank the AndroidManifest.xml from our example repo.

Vote on HN
Looking to monitor your go applications?