DevOps, Security How-To Guides

Go Development Tools for Testing and Hot Reloading

James Wickett

Often found at the intersection of DevOps and security, creator of gauntlt and author of DevOps Fundamentals — a course on Lynda.com and LinkedIn Learning.

Those new to the Go language (golang) often are excited about the simplicity, speed and portability of the language. Golang also has a wonderful ecosystem of tooling for testing and helpers for working on web applications and APIs. In this post, we look at a few.

Keep Go development moving with hot-reloading using Fresh. Photo by Anthony Legrand on Unsplash

Along with Ernest Mueller I have recorded a few courses over at Lynda.com and LinkedIn Learning on DevOps, Continuous Delivery and Infrastructure Automation. In those courses Ernest and I take an approach of covering theory and philosophy and then follow it up with real world experiences, code samples, and tooling.

Our latest course DevOps Foundations: Continuous Delivery/Continuous Integration just shipped this week and we are really hoping that the course helps people get started or advance their CI/CD efforts. In this course, I covered some tools to do unit testing and I wanted to share those with you here as well. We are going to look at 2 tools I particularly like for Go web development.

1. GoConvey

“GoConvey is awesome Go testing” as written in the readme in the project’s github repo. From my experience it is! There is a lot to love here with GoConvey. Let’s start with this lovely UI (screencap from Lynda.com course on CI/CD).

Screen Shot 2017-09-12 at 9.00.20 AM.png

GoConvey’s UI is lovely, with green, yellow, red and gray status bars taking the main real estate to let you know when something is wrong (or right!). Additionally, I love being able to have a single dashboard to see code coverage, statistics, and a package-by-package breakdown of my project.

I often turn GoConvey on as I work on a project, and then I just forget about it. That is until I write a something new or update a test. In fact every time I save a file in my project, I get a nifty notification to my desktop letting me know whether what I just did passed or failed. It seems like GoConvey has special hooks for Sublime, however I can’t speak to that as I just use vim. Old habits die hard. (Image of HTML5 notification from goconvey.co)

1-K3VCw5eaaw2FUHJ2yZI81Q.png

Some people get turned off of GoConvey because they think that you have to use to use the package’s testing DSL in order to get the benefit of the tool. That would mean refactoring a bunch of tests and that wouldn’t be too much fun. I am happy to report that is not the case at all, the tool works natively with go test.

Check out more on GoConvey at goconvey.co

2. Fresh

You were wondering about the apricots weren’t you? Well, fear no more.

Have you ever been working on a project where you made a change in the code but for some reason are not able to see the change reflected in the web application? Maybe it was just a color change or new text or maybe an update to the API. Why doesn’t it show up? You dig around the documentation, check the library you are using, you fumble around to check the tests. Only after 10 minutes of this you realize you forgot to restart the application: doh!

anthony-legrand-134706 (2).jpg

This is where Fresh comes in. Fresh does hot-reloading of config on changes. What does this mean? This means that when you write a new feature or change a button or even update a template that the web application you are working on gets restarted automatically. No more remembering to restart, it just does it for you.

To get started with Fresh, check out github.com/pilu/fresh.

The DevOps Roadmap for Security  This Signal Sciences report provides a playbook to help bridge the gap between  DevOps and Security tribes in your organization. Free eBook  <https://info.signalsciences.com/book/>