Golang Project Structure

Tips and tricks for writing and structuring Go code

go programming

Tag

Functional Programming With Slices

This post will explore the programming paradigm known as functional programming and discuss what restrictions it places on programmers, as well as how it helps in the process of developing and structuring code. We will then go through some practical examples of functional-style code written in Go, specifically looking at how generic functions can be […]

The Best Golang Task Runner

Okay, I’m biased — it’s my task runner — but hear me out. This post will start by discussing what a task runner actually is and exploring how it works by building a very basic version of one in Go code. Then we’ll look at some example tasks that can be completed with the help […]

How to Read a File Line by Line

Sometimes you want to read a file that contains many lines of text or a list of structured data and you want to process each line individually, rather than working with the entire content of the file at once. This post will discuss various ways to read a file line by line, looking first at […]

Hash Functions in Go

This post will explain what hash functions are and how they’re used. We will then go on to look at some examples of hashing algorithms in Go code. Finally, we will look at importing external packages that export hash functions, including from the standard library. What Is a Hash Function? A hash function takes data […]

How to Concatenate Slices

Slices are one of the most important data structures used in Go. In this post, we will look at how to concatenate slices. We will start by explaining the general concept of concatenation, then we will look at examples of concatenating two or more slices in Go. Finally, we will build functions that can help […]

Adding Elements to a Slice

This post will discuss the various ways to add elements to a slice. Appending an element adds it to the end of the slice, whereas prepending it adds it to the beginning of a slice. It is also, of course, possible to add an element at any position in between. We will finish by looking […]

How to Pixelate Images in Go

When an image is pixelated, it has a visual effect applied to reduce its level of detail through the use of many same-sized blocks, each painted with a single colour. Each of those blocks can be thought of as a large pixel (since a pixel is the smallest unit that can contain a colour in […]

Ways to Work Out the Average Colour of an Image

It’s reasonable to look at a picture and to wonder how it might look if it were distilled down into a single colour, which somehow still encapsulates a sense of the original. In this post, we will look at various methods that can be used to calculate the average colour of an image in Go, […]