How to Use Mutexes in Go

Golang is King when it comes to concurrency. No other language has so many tools right out-of-the-box, and one of those tools is the standard library’s sync.Mutex{}. What Problem Do Mutexes Solve? We don’t want multiple threads accessing the same memory at the same time. In concurrent programming, we have many different threads (or in … Read more

Best Practices for Interfaces in Go

Best Practices For Writing Clean Interfaces in Go

Interfaces in Go allow us to treat different types as the same data type temporarily because both types implement the same kind of behavior. They’re central to a Go programmer’s toolbelt and are often used improperly by new Go developers, which leads to unreadable and often buggy code. Before we dive in too deep, if … Read more

Wrapping Errors in Go – How to Handle Nested Errors

photo 1495863367063 b9ac3e6394f7

Errors in Go are a hot topic. Many newcomers to the language immediately level their first criticism, “errors in go are clunky! Let me just use try/catch!” This criticism is well-meaning but misguided. The paradigm of errors as a type, rather than something to be thrown and cause panics, allows for more control of how … Read more

JWT Authentication in Golang

logo 400

Go is becoming very popular for backend web development, and JWT’s are one of the most popular ways to handle authentication on API requests. In this article, we’ll go over the basics of JWT’s and how to implement a secure authentication strategy in Go! In fact, the Qvault app uses almost this exact same strategy … Read more

BitBanged SPI in Go, An Explanation

1 5WD0gV6autEIzv8GMkc5gQ

I’m going to focus mostly on some design decisions and also how I went about writing an SPI interface using Go on a Raspberry Pi. I assume my readers have a basic understanding of what a Raspberry Pi is, and how basic electronics work. If not, read on anyway and I will be sure to … Read more

Top 6 Golang Logging Best Practices

guest writing on table

Let’s cover some rules of thumb for logging in Go, as well as some functions you may not have heard of that can make your debugging life easier. Best practices for logging in Go aren’t super obvious, and sometimes we have to take a deeper look to see what the best choice is given Go’s … Read more

How to Create Constant Maps, Slices, & Arrays in Golang

How to Create Constant Maps and Slices in Go

For the most part, I’ve noticed that Go developers are pretty good about using global constants for configuration, rather than global variables. A problem arises however when we want a constant version of some of the more complex types. The Go compiler doesn’t allow array, map, or slice constants. Many developers, upon making this realization, … Read more

The Proper Use of Pointers in Go (Golang)

photo 1497005367839 6e852de72767

Go has become increasingly popular in recent years, especially in my local area. It has been consistently displacing other backend languages like Ruby, Python, C# and Java. Go is wanted for its simplicity, explicitness, speed, and low memory consumption. Many developers that are new to the language, or new to a language that can handle … Read more