When testing our applications we often have a lot of external dependencies, and often we’re not running our tests in an environment where we have room to boot up Redis, MySQL etc.

Recently I was trying to solve the problem of needing a Redis connection in one of my applications, but I didn’t want to have to keep a Redis server running whilst I ran my tests, I felt this was unnecessary.

I stumbled upon an elegant solution to this: https://github.com/alicebob/miniredis

This library spins up a Redis compatible server in your application that you can use without dependencies when running…

So unlike modern PHP, Go handles the way we interact with types in our applications in a different way, through the use of structs. In fact it tailors itself to be more primitive, like it’s grandfather C.

Go does however have similar concepts implemented, which to an outsiders point of view, could be mistaken for the same constructs which we see in PHP.

For example: Structs.

Structs in Go are a way of defining a type of data, which itself has properties. These properties have their own types, which too can be structs. …

For all you beginner, intermediate or expert PHP developers, here’s an article which should provide you with a little guidance on how to get started writing your applications in Golang and how it compares to a similar workflow with PHP.

But first, let’s grab the things we need to start writing Go applications. Head on over to Go’s website to get it installed here. Follow the guidance there to get things setup for your OS of choice.

In this article we’ll take a look at the example test code they suggest you try to ensure your installation is working as…



Developing Go applications can often be a slog, especially if you’re the Go application is a service in a larger ecosystem, that you need to run locally during development.

Every time we make a change to our code we’d have to kill our Docker container, re-build our Go binary and re-run the Docker container. This is inefficient and could easily be automated. Let’s get cracking shall we?

I’m making the assumption you know the basics of how Go programs work and how to develop them. I’m also assuming you know what Docker & Containers are.

Setting Up Fresh & Glide

The problem we’re facing here…


2017 has been an interesting year for me, I feel like I’ve learned so much about myself, my skills and the industry which is “Web Applications”. I’ve stumbled upon so many great, new ideas & technologies that have been released by well-known contributors and large tech companies such as Facebook, all of which make me glad I have a passion for this line of work.

Yet I’ve not found the time to dive into any of them in great detail, as there’s so much to learn and discover.

However I’m going to discuss some of them anyway, and try to…

Have you ever wondered how you can interact with a database in Go using the Model pattern? Well here’s a quick example of how you can get started with GORM, an ORM for Go.

In this example we connect to an SQLite database called database.db and migrate a new table for users. We then add a new user row with the name “Craig” and fetch all users. We finish by printing out the JSON representation of this list of users.

GORM makes interacting with databases in Go dead simple and is just one of the many tools you can use to encapsulate your data layer in the Model architecture.

Check it out here.

Before running this, please ensure the environment you’re running this on has SQLite and that you’ve run the following go get commands:

go get github.com/jinzhu/gorm & go get github.com/jinzhu/gorm/dialects/sqlite

To start, I’m sat in a coffee shop, 72 miles from my flat and I’m working. Crazy, I know. Technically right at this moment I’m writing this article, shhhhhh.

I always thought when the time came for me to plunge into full-time work, my working day would go something like this: Me, sat in some office, surrounded by my colleagues, some I enjoyed the company of, some I did not. Slaving away to get everything done within the 9–5 slot; with which I am required to be present. …

Recently I’ve been implementing a small side project in Go with Gin. I know how easy it is to setup tests with Go, but I was very surprised not many people had covered examples of how to test the JSON responses for your APIs. With Gin specifically.

I discovered, it’s quite simple.

First we want an endpoint to test so here we go. The following would return a simple {"hello":"world"} JSON response. On a GET request to / in a file called main.go put:

package mainimport (
func main() {
router := SetupRouter()


I’m going to assume you’ve got Go and Docker installed locally, if you haven’t then head on over to these links and head back here once you’re done :)



Jumping In

So first we’ll create our Dockerfile ready to run our compiled web server, called main

FROM scratchADD main /EXPOSE 80
CMD ["/main"]

I like to use Docker-Compose because it makes it really easy to setup a Docker based environment on your local machine. This is the docker-compose.yml we’ll be using.

version: "2"services:
container_name: application
build: .
- 80:80
- HOST=:80

This defines our…

Just the way I do things

I've always been intrigued by the way people work, what editors they use, any cool workflow apps, which version control system they're using and why? So I thought I'd share the way I do things.

These are my opinions; Some of you may find them useful, some might agree and share similar opinions and others may downright disagree or hopefully be willing to share their thoughts and maybe show me how I can improve or even advance my current setup.

I’m able to develop in multiple languages, though my specialist area is web development using PHP, so that'll be my…

Craig Childs

Multi-pronged web developer with a passion for cutting edge tooling! https://craigchilds.dev

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