We love using Go for writing specialized network servers, and we've just open sourced one.
In our Web Whiteboard service we've been using QR codes for some time now, to make it easier to people to share the whiteboard links in real life and avoid tedious random link typing.
In implementing this, we've opted to not add QR code generation to the main (nodejs) app. With a fairly simple and well defined semantics, this was an ideal candidate to split out into a microservice. It also allowed us to pick the best tool for the job, which in this case is Go.
We've been working with Go for some time now, and while it'd never be our first pick for a typical db-backed web application (we love Django for that), we love it for implementing specialized network servers.
This allowed us to build the fully fledged production-ready service in ~100 lines of clean, commented Go code, with an additional ~60 lines for the test suite. The code is fully open source and available from GitHub.
To install it, you'll need a functional Go environment, and run:
go get https://github.com/dobarkod/qrserve
You'll get the
qrserve command (in your
$GOPATH/bin directory), which
you can run to start the service:
To generate the QR code, make a request to the service:
curl 'http://127.0.0.1:8000/?data=Hello&size=100' -o qrcode.png
More information about the usage is available in the project's README.
The service only depends on the Go runtime and one Go package (go-qrcode, does the actual image generation) for building. Once built, the binary has no dependencies and can be deployed with ease anywhere, without worrying about containers, dependencies, runtimes or any other baggage that usually comes with many mainstream web app platforms.
Go generate some QR codes!