This tutorial shows you how to make small Docker images when building Go programs.

Sample Go program

I wrote two tutorials recently demonstrating Docker Compose and Traefik. They both used a small Docker image containing a simple Go REST API that returns a JSON string with the message Hello World.

Let’s take a look at the code:

As you can see, the code doesn’t do much, it listens on a port specified by the APP_PORT environment variable and returns a JSON response when GET requests are made to /.

The code for this post can be downloaded from this GitHub repository.

Even…


This tutorial will show you how to setup a CI/CD pipeline using GitHub Actions. The pipeline will test, build and publish a Go app to Docker Hub when changes are pushed to a GitHub repository.

Overview

Here is an overview of what’s in this guide:

  • We start by creating a simple console app in Go that prints Hello World along with the version number of the app.
  • We will create a GitHub repository and assign Docker Hub credentials using the Secrets feature of GitHub.
  • We will create a GitHub workflow that runs Go tests each time a change is pushed to…


I’m sure you’ve read the stories of people that accidentally committed their AWS keys to a public Git repo and how costly this mistake can be.

Some random script kiddy scans GitHub for projects that contain API keys, steals the key and uses it to deploy instances that mine cryptocurrency, running up huge bills.

Ouch!

This problem can be avoided with this simple technique.

Store Config in the Environment

First of all, don’t store the API key or any other configuration information in your code. This is rule number three of creating Twelve Factor Apps which I encourage you to read about here.

If you’re…


Learn how to make a simple command line program with Go.

Demo program showing stock price of Tesla (TSLA)

Introduction

I’ve just started learning Go and I put together a simple module called finnhub-go that lets you query the Finnhub Stock API for the current price of a company.

In this post, I’ll show you how to create a simple command line program that takes the company ticker symbol as an argument and outputs its stock price.

Before we begin

Make sure you have Go installed on your local machine. In the following example, I’m using version 1.14.4 on a MacBook Pro.

Step 1: Create a new project

First of all, create a directory to contain your code.

Tony Mackay

I write tutorials for Cloud Architects, DevOps Engineers and System Administrators at https://graspingtech.com

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