<iframe src="//www.googletagmanager.com/ns.html?id=GTM-KXSCJR" height="0" width="0" style="display:none;visibility:hidden">

Simple tools to solve simple problems

Jason Mooberry on Jul 17, 2014

At Prevoty we write all of our core services in Go.  We have found it to be a robust, rapid development language with a budding community around performant solutions.  Since it’s version 1 release, a little over two years ago, there has been a strong showing of library and framework developers building pieces of functionality that can be imported into any project for quick wins with ease.

There have been several contributions to the orm space and a few to the deployment space written in Go.  We’d like to add two libraries we’ve developed to satisfy our needs in both of these spaces.  The first is pdo, a struct/table mapper for simple crud actions.  The second is pd, a deployment library, similar in spirit to fabric.



Our dashboard of Trusted Services is written in Go.  Initially, we wanted to have flexibility to evolve and develop it quickly and PHP was a good choice.  After seeing how many of our clients wanted to embed our dashboard in their data centers and private clouds, we wanted a more portable solution.  Go was the obvious choice.  A single binary and a folder of static assets, with no dependencies at all.  We ported the site over and added some nicer authentication/performance features inside of a week.  During the process we saw the tedious nature of querying the database in Go.  Keeping track of variables locally quickly led to unclear code.  Since our needs were only CRUD based, I migrated our existing code to use a schema of structs decorated with column/table information.

Several good orm options exist in Go, but we wanted something simple that would fetch/retrieve information and didn’t require learning a bunch of new conventions.  I wrote pdo to satisfy this need.  

This code demonstrates how to fetch a user by email.  The User struct is defined below:

pdo expects an Id field and a _meta field both decorated as above.  Fetching multiple records is simple.

pdo works with MySQL and Sqlite and is available for use under the Apache 2 license.



pd was created on a dare.  Our CTO, Kunal Anand, mentioned that the core fabric functionality boiled down to run, sudo and rsync.  I realized that shelling out these commands could be accomplished concurrently with just a few lines of Go.  I wrote pd in a few hours and we iterated on it until it was usable for our aws deployments.  A simple build/deploy:

pd has several helper methods that enable quick spinning up of aws servers, deploying, creating ami’s and spinning down servers.  It uses the goamz library under the hood, but pd can be used with any set of ips/dns names for local/vm/hardware/cloud actions.  It is freely available under the Apache 2 license.

We hope as the community of engineers grows around Go that our contributions will satisfy some of the needs that arise.  Thanks!


Jason Mooberry
Director of Engineering

Back to blog

Jason Mooberry

Topics: Open Source