Gopher Coding Logo

Gopher Coding

Go, Docker, DevOps & Distributed Systems
  • Tutorials
  • About

Remove Old Docker Containers (Spring Cleaning)

If you just dabble with Docker, or use it regularly, you will build an arsenal of images and containers as you go along. From time-to-time we need to clear these out. This process used to be more complicated until the docker command implemented a simpler way using system prune.

#docker#prune#clear#space#image#container#system

Check If a Go Client Has Reused a Connection

For logging purposes, performance monitoring, debugging - what ever your reason, it can be useful to know if Go has reused it’s connection when making an initial request, for later use. If it’s not reusing connections, it might be running slower and less efficiently than it needs to be. The code below is used as an example of how to log if connections are being reused, as well as outputting the DNS information gathered.

#http#reuse#log#dns#httptrace#tcp#context#request

Advantages & Disadvantages of Microservices

Microservices are a form of service-orientated architecture - we won’t go into too much detail on what they are, but we will discuss their pro’s and con’s here. As with all architectures, there is no right way that everyone should use so discussing their plus points with the potential issues is important. Advantages First a quick look at why you should use them. Independent Technology Using microservices to split up your infrastructure allows you to use different technology/programming languages/tools very easily. More than this, it means the languages that you do use for a single service are often easier to update and maintain as the list of dependencies and legacy code attached to them is less and with a large monolith system.

#microservices#soa#architecture#reporting#service#scaling#deployment

Install Latest Version of Go (Linux/OSX)

Install Latest Version of Go (Linux/OSX)

This article describes how to install the latest version of Go (golang). It also helpfully updates itself by pulling the latest version numbers directly, so you don’t have to go and dig out the latest version each time they release a version (yay!) - just copy and paste away. For more info, try their installer docs.

#install#update#linux#osx#mac#latest#version#verison#go#golang#package#deb

Using a .env File & Environment Variables

Environment variables are used throughout the coding ecosystem as a way of keeping secrets out of the code. They’re also useful as a way of keeping the code the same between environments, e.g. live, uat and test servers but functionality might work differently.

#environment#variables#set#get#env#file#local#development

Run Tests in All Packages

Life can be simple when all your Go files are in the root folder. But when a project gets a bit bigger, you may want to store much of the logic in packages. The issue comes when our usual command of go test then no longer picks up our tests.

#tests#packages#all#suite#func#files#folders#run

While True Loop in Go

While True Loop in Go

While loops do not actually exist within Go (golang), by name, but the same functionality is achievable with a for loop. Which is great, why have a ‘while’ when the same can be done with ‘for’. Our example below shows how you get a Go program to print out a message every second to the screen. (You’ll have to exit to application to stop it, e.g. Ctrl+C)

#loops#while#infinate#infinite#break#stop#for#sleep

Hello world! Welcome to GopherCoding.com

Hello! This is our first post on GopherCoding.com where we’re going to list snippets of Go (as in Golang) code to make learning and building things easier. A Bit of Background Go is a programming language, heavily backed by Google, and racing up the list of most popular languages to code in. It’s a statically typed, compiled language and is well known for it’s concurrency. Great for web applications, command lines tools and many other things.

#welcome#golang#tutorials#gopher#howto#helloworld
page -= 1 page := 5
Privacy Policy
Site illustrations (of Goldie the Bird) drawn by Carina Roberts.
Tutorials & Site Content © 2024 Gopher Coding
Code Licenced under MIT Licence
Gopher Coding Logo