Member-only story
The Only Introduction to Golang You Need
Learn the basics of Go with 30 useful cheat sheets

Go, or also called Golang, is absolutely trendy, and rightly so.
It is not as difficult to learn as C or C++, but still quite fast, and has a great community & many interesting and helpful packages and libraries. The language was also developed by some of the brightest minds in the computer science world at Google.
These are probably enough reasons to look at the language in which Docker and Kubernetes were written. Here is the ultimate Golang cheatsheet you need to get started. Have fun!
Table of Contents
1. Hello World
2. Variables
3. Getting User Input
4. Data Types
5. Functions
6. Conditionals (if-else)
7. Loops
8. Arrays
9. Pointers
10. Splitting up Code
11. Custom Types & Receiver Functions
12. Maps
Hello World in Go
Let’s start with the absolute basics. If you already have Golang installed, you can type go version
into your terminal and you should see a useful output. If you haven’t installed it yet, you can do that here.
Let’s start with Hello World. For this, we just create a file called main.go
, fill it with the following content, and then we can run our first program with go run main.go
. You should see an output in the terminal.

fmt
stands for formatting and is the default library for input and output in Go. As you can see, we have a main function in the file, it is executed automatically without us having to call it. Every Go project needs such a function.
These are the essential instructions we need. If we want to compile our project and make it into an executable file, we use go build main.go
.

Variables in Golang
Some things are really special about Go. One thing is, there is no null
that describes the value of a variable that has not yet been…