Golang

Golang: Reading and writing files

Reading and writing files is a key part of most applications. In Golang, it’s not quite as straightforward as with other languages like Python, but let’s go through it line by line to understand how it all works. First off, let’s go through writing a file. If you look at the Golang documentation for writing […]

Read more
Golang

Golang: Getting started with If statements

If statements in Golang are pretty simple, so this is going to be a really short article. What I would like to do, is compare the same if statements in Python and Golang to give you a feel for how the two languages differ in their constructs. In Python, we’d have something like: Here, we […]

Read more
Golang

Golang: Multiple return values from functions

Okay, so in this article, we’re going to talk about a few things. We’re going to look at how we return multiple values from a function; within that function we’re also going to take subsets of a slice. Let’s go through all of the code below at a high level. We will then zoom in […]

Read more
Golang

Golang: Getting loopy with loops

The simplest form of for loop in Golang is a while loop. What?! Yep, it’s true! In Golang, there are only for loops but they double as while loops. In the below, we have a variable called i which is initially set to be equal to 1; when we call our loop we say, keep […]

Read more
Golang

Golang: defining custom types and receivers

In Python or really any object oriented language we have the concept of classes. So, if you imagine we’re a casino, we might have a class called ‘Deck’ – that is, deck of cards. Associated to that class, we might have functions to shuffle the cards, pick a random card etc… Well, given that Golang […]

Read more
Golang

Golang: Arrays and Slices in Go

Go has two array-like data structures. The first, is called an array; it’s a fixed length list of things, once it’s defined, you can’t add or remove anything from that list; a bit like a tuple in Python. The second type is called a slice. This is an abstraction of the array data type and […]

Read more
Golang

Golang: Variable Assignment & Data Types

Variable assignment and data types are those kind of topics that are absolutely necessary to cover. If we think about Python for a second, we can happily do this: j= ‘Bob Smith’j= 13 Here we have assigned a variable called j to be a string value of Bob Smith and then have immediately assigned the […]

Read more
Golang

Golang: Getting to grips with Hello World

Okay okay I know, hello world is the most boring application it’s possible to make in any programming language BUT there is a reason that it’s always used, it is quite a good usecase. In the below, we have the Golang implementation of Hello World and actually, we can derive quite a lot of information […]

Read more