I’ve been using Go for a number of years now and occasionally I will come across a small coding hack that makes my life better. So I decided to share them with you!

1. Checking if a key is in a map

This one is probably quite well known, but I use it so often I felt it should get a mention. If you want to check if a key is in a map, you can call:

_, keyIsInMap := myMap["keyToCheck"]
if !keyIsInMap {
fmt.Println("key not in map")
}

2. Check when casting a variable.

Sometimes you need to cast variables from one type to another. The downside is if you get the type wrong…


In a previous article, I wrote about coding hacks in Go that I’d come across over the years. For this article, I decided to write about a few of the pitfalls I’ve also come across. These are the type of bug causing quirks that the compiler will overlook and are easily missed in a code review.

1. Referencing a loop variable isn’t a good idea

This one is quite well known, but it still catches me out from time to time. If you are looping through values and create a pointer to the loop variable, it might not have the outcome you expect. …


In a recent Go project, I had to choose what data format to use for sending and receiving data. My usual go-to is JSON, but I decided I would give an honest comparison of the options. As I’m sure you’ve gleaned from the title, the main contenders are YAML, JSON and XML. The criteria I have evaluated them on are:

  1. Human readability. It’s good to be able to read the data during development and debugging.
  2. Size. What size will the data be once it’s been encoded?
  3. Speed. How long does it take to parse and encode the formats?

To evaluate…


AutoML is a fantastic suite of products from Google that lowers the barrier to entry for those wanting to make use of machine learning (ML). It allows you to upload a dataset and it will take care of creating the machine learning model for you. It then hosts the model for you to make use of. Which as you can imagine is amazingly useful for people who want to make use of machine learning but have limited experience creating and deploying models. It can however, as I learnt the hard way, get expensive to run. …


This is Part 2 in a guide to creating your own AutoML Text Classifier using off the shelf parts like spaCy and Firebase. In Part 1, I talked about the architecture of the project and how to set up the various components needed to run it. In this article, I will discuss the key bits of code needed to glue the parts together and then how to deploy the code. The complete code for the project can be found in the repo, specifically branch “v1.0.0”. I’m not going to go through every piece of code, just the key parts needed…


Google Cloud Platform logo. Source: Google

I stumbled on this problem during some SaaS musings. If a customer wants their on-prem devices to communicate with your SaaS running in GCP, how would you go about it?

The obvious answer for GCP is service accounts. However, you are limited to 100 service accounts per project in GCP, so that won’t scale well. So what else can we use that can authenticate large numbers of devices and works well with GCP? IoT Core of course!

IoT Core is a fully managed service (serverless) that allows you to securely connect millions of devices globally to GCP. While it’s meant…


Source: https://grpc.io/

This is Part 2 in a series of articles on gRPC that my colleague Scott Walker and I are working on. It continues on from Part 1, and we will show some examples of exposing a gRPC service using REST and auto-generating a swagger file for it too. The full code for all our examples can be found in our repo.

Didn’t you say in Part 1 that gRPC can replace REST?

I did, but sometimes you have to use REST. Maybe that’s for a third-party to integrate into your service, or even for your UI. …


Source: https://grpc.io/

gRPC is an open-source high-performance RPC framework that can efficiently connect services in and across data centres and is magic as far as I’m concerned. I first came across gRPC a few years ago and was blown away by how good it was. My colleague Scott Walker and I decided to create a talk on gRPC for the Cloud Native Computing Belfast Meetup to help show others how good it was. However we had to gloss of a few things for the talk, so we decided to a series of articles to go into more detail.

What’s special with gRPC?

Remote Procedure Calls have…


Source: Google Cloud Platform

I’m working on a small side project, for which I’m using Firebase and Google Cloud Functions. So far it’s been great however one of the use cases requires a response from the Cloud Function within a certain time limit. Occasionally, usually after the weekend, the Cloud Function will need to cold start and will take just too long. ‘Cold Starts’ are when a ‘serverless’ service is not cached by the cloud provider and the execution environment needs to be initialized from scratch.

I followed all the tips and tricks recommended by Google in their documentation, however it was never quite…

Staff Software Engineer @ Harness Belfast

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store