Gaestebin 2.0

Diwaker Gupta
Floating Sun
Published in
3 min readOct 12, 2015

AngularJS + Go + AppEngine = Gaestebin 2.0

A while back, I wrote a secure pastebin that can be deployed on Google AppEngine for use at work.

It has served us well since then, but I was itching to learn some new things and so few weekends ago, I rewrote it and am proud to announce Gaestebin
2.0
!

So, what’s new in this release? Functionally, not much. But under the covers,
everything has changed:

I had already started working on this stack when I came across the
appengine-angular-gotodos project — that definitely helped!

AngularJS

A new breed of Javascript frameworks and libraries have cropped up in the past year. Of those, Ember and Angular kept popping up in my feeds. Since I have a positive Google bias, I decided to check out Angular.

It took me some time to get used to this idea of automatic data-binding to DOM elements. I still don’t fully grok Angular, but it was surprisingly easy to get started. Getting data all the way from the backend into the UI was pretty straightforward, especially with Angular’s JSON support. In particular, Angular resources made for a very smooth interaction with a REST:

Angular’s data-centric view does make some things harder though (or perhaps I still haven’t fully enbraced the Angular way). For instance, on page load I wanted a text field to be pre-selected and the contents of the field already copied into the clipboard. Is this even a problem that I should expect Angular to solve? Likewise, I wanted to add some keyboard shortcuts to the app but did not find the Angular way to do it.

GO

I’ve been peripherally interested in Go ever since it launched but beyond
curiosity, I hadn’t really written anything meaningful in Go. While REST
backends is not exactly Go’s forte (doesn’t really exercise many of Go’s
more-popular features like goroutines), I figured building something that we use daily would be a good way to learn a new language.

  • Like: gofmt, concise syntax, fast compiles, strict compiler
  • Dislike: interfaces, types (or lack thereof), tabs
  • Was worried I’d dislike but didn’t care: error checking

Here’s the backend definition of a Paste:

And here’s a function to generate random strings. I’m still very much a go-noob, so would love to hear about suggestions for improvements or more idiomatic ways of doing the same thing:

A few things I struggled with:

  • The Go AppEngine runtime is still marked experimental, and this shows in their documentation and tools support. For instance, the AppEngine launcher doesn’t support Go yet.
  • Migrating from Python to Go was lossy in the sense that the Python runtime has features that are missing in the Go runtime. Specifically, the Python datastore supports richer types like Email that are not available in the Go datastore.

Bootstrap 3.1

Twitter’s Bootstrap makes it so easy to put together a good looking website
that I can’t believe there are still ugly websites out there — no more excuses!
I load all the CSS/JS assets from cdnjs. And glyphicons
provide some nice flourishes. So much better than writing your own CSS! This is all of gaestebin’s custom css:

So there you have it! Feel free to try out the public version and if you do deploy gaestebin as an app in your personal or corporate accounts, please do send your feedback and suggestions!

--

--

Diwaker Gupta
Floating Sun

Geek, open source enthusiast, software architect, virtualization research