I was recently restructuring one of my early Go side projects. As I was changing the project layout, I was reminded there are many recommendations out there but no set standard for structuring Golang projects.
In other programming languages such as Java, there is a typical project layout that most programmers follow inherently. In Python, the framework used (i.e., Django or Flask) will define how the project is structured. However, Go is still at a point where the community hasn’t settled on a defacto standard.
There are, however, some strong recommendations, but as I was going through those recommendations, I…
I see this one question pop up in channels over and over again.
“What is the best way to mock a database for unit tests?”
For most, the thought of mocking responses from a database is daunting. Taking each DB call and creating a unique mock response can be a lot of work, especially within a large service.
This article proposes an alternative idea. One that I’ve been using for both open source and enterprise applications.
Rather than spending forever creating mocks of a database. Run the database itself as part of your continuous integration (CI) pipeline. …
Recently I wanted to revamp one of my side projects go-quick. This project is a boilerplate web application meant to be a starting point for Go apps. Previously, I wrote a custom config package within the project to pull configuration from Environment Variables as per the 12 Factor Apps manifest. But, I wanted to expand how users can configure my project.
Enter HashiCorp Consul. Consul is open source and solves many of the platform pain points of running modern applications. One of those is dynamic configuration via its distributed key-value store. With Consul, applications can boot up using Consul as…
When I was learning Golang, one of the concepts that took me the most time to grasp was Interfaces. Golang’s Interfaces are a great way to make modular and testable code. But they can also be a bit confusing at first glance.
One of the best ways I’ve found to teach how interfaces work is by creating a mock implementation of an existing Interface.
This article will cover creating an interface and creating a mock implementation for that Interface. But before we jump into a working example, we should first understand the value of Interfaces.
When thinking about Interfaces, consider…
Before learning Go, I used to write most of my applications in Python. When I was transitioning from Python to Go, I was familiar with parsing JSON, YAML, etc., into Python dictionaries. What I never understood is why I would see so many examples parsing JSON into Go structs. Why not use maps, which are equivalent to a Python dictionary. What were the benefits of using structs vs. maps, or were maps some secret technique that Python taught me that all these Gophers didn’t know?
The truth is, it all depends on how we use the JSON data; in some…
This article is part of a multi-post series on Software Design. In the last post, we took our design and scaled it up to meet our unique performance needs. In this article, we will start ensuring that our platform is highly available.
As mentioned in previous articles, this application platform is by example. As we cover the design options and challenges for this application, it is essential to keep in mind that it is an example.
Much like scaling, when designing for availability, it is easy to take a simple design and make it complicated. Complexity often happens due to…
This article is part of a multi-post series covering Software Design. In the previous post, we outlined a high-level architecture of our example platform. In today’s article, we are going to explore scaling that high-level architecture to meet new demands.
Since this article is “by example,” It is worth calling out that our scaling problems are fake. They will be in areas we expect. Whereas in the real world, scaling issues show up in the most unexpected ways.
For this article, we will cover scaling the architecture into what I would call the second phase of our design.
One of the goals of Docker is to simplify what it takes to start and run applications. A way Docker tries to achieve this goal is by allowing users to create an isolated runtime environment where they don’t need complex startup scripts.
For the most part, it works. Docker is simple enough that an average application can be started directly with the
ENTRYPOINT instructions within the
However, not every app can start up so simple.
It is not uncommon to require specific tasks to execute within the container environment before the application starts. These tasks could be…
Today I am going to talk about something a bit different than my usual articles. Rather than my typical how-to article, I am going to breakdown the process of software design.
In this multi-post article, we will focus on the creation of an example application. We will first explore the purpose and requirements of the application. Then we will review the architecture and implementation choices we will need to make.
Note: While the concepts and practices in this article are real. The application and design in this article are only an example. This is to show how to design an…
Recently there has been a lot of coverage in both tech and non-tech news outlets about internet privacy and how to prevent snooping both from service providers and governments. In this article I am going to show one method of anonymizing internet traffic; using a TLS enabled HTTP/HTTPS Proxy.
In this article we will walk through using stunnel to create a TLS tunnel with an instance of TinyProxy on the other side.
TinyProxy is an HTTP & HTTPS proxy server. By setting up a TinyProxy instance on a remote server and configuring our HTTP client to use this proxy. We…