Update: So I’ve learned that there’s actually some work to be done here around sandboxing before it’s actually ready for public use. Until then I’ve removed the server, but the code is still available if you want to play around with it in a trusted setting.

One of the great things about go is the whole environment you get with it, gofmt, godoc, go get. It’s all good stuff. There’s also a playground for you to try things out on. The docs also have runnable examples in them based off a similar idea: http://golang.org/pkg/encoding/json/#example_Unmarshal

It’s a great idea, it means you can actually try the code out while you’re reading the docs. But it only works on code from the stdlib. But that makes sense doesn’t it? You don’t want to allow anyone to import some arbitrary package.

But it occured to me that when someone develops a package, the author might want to include runnable examples for their own code.

The source for something similar to the playgrond is incuded in the go release (misc/goplay) I’ve modified it very slightly to allow /compile to be called from any location. I’ve called it goplaas (It’s not really as a service, but that’s the standard suffix these days isn’ it? And it got your attention!)

The idea is you install it on your own server, and it will have access to anything installed on your GOPATH. This means you can control what packages can be imported, and also the version.

All you need to do is put some javascript and a textarea into a webpage, point it to your server and you’re done.

Here’s an example using the loggo package from launchpad.net. Try it

1 I've removed it - sorry

I’ll try to keep my server running with goplaas for the next few weeks. If it suddenly stops working, it’s likely that I’ve pulled the server down. You can experiment yourself by running

1 2 go install github.com/mattyw/goplaas ./goplaas -http :9999 #Listen on 9999

goplaas includes a -compile flag for sending compilation instructions to another server, full instructions are in github.

A good next step would be to package this all up into a docker container to allow anyone to install it with relative ease