A weekend with Go

Over the weekend, I was tinkering with data encryption between iOS apps and backend APIs, which led me to find Rob Napier's popular RNCryptor library.

Along with the great Objective-C API, RNCryptor also comes in several other languages that can be used on the server-side for decryption.

Porting RNCryptor to Go

For the sake of portability, I was looking to make a single binary that would handle all of the decryption and recording of data sent from its counterpart iOS apps, regardless of the particular web-stack the server existed in. So I thought I’d give Go a try.

Come to find out, RNCryptor didn’t have an implementation in Go yet (though it was on their todo-list).

So I set out to write one. Having never written any Go code before, there was a lot of googling and doc-reading invovled. Thankfully, Go’s standard crypto package provided everything I needed, it was just a matter of finding the right APIs for the job. The final implementation ended up being ~150 lines of code.

After reaching out to Rob, he was super helpful, and helped migrate the repo to the RNCryptor Organization along with the other languages!

You can check out the end-result at github.com/RNCryptor/RNCryptor-go.

First Impressions with Go

I really enjoyed my first few hours with Go. The standard packages are really rich, and well documented. The built-in support for testing was also a big plus for me.

The language definitely felt minimal. There’s no classes. No default parameters, function overloading, or custom operators. You get structs and interfaces, that’s it. This is very different from something like Swift, where you can bend the language to your will pretty easily. But after accepting the constraints Go has, it was a fun change of pace. The language seems to give you just enough to get the job done, and no more. Which I kinda like.

The workflows for writing Go seems a little wild-west-ish. There is no central package manager, which can make discovering 3rd party packages a little hard. You also have to keep all your Go code in a single “workspace” (like keeping it all under ~/go), which is mildly annoying for me, since I like to keep my code organized by projects, not by language.

Overall though, I really enjoyed getting to hack on something new, and the fact that I was able to create my first Go package in a few hours says a lot about the Go ecosystem I think.