Quick Recall of Go Concepts
Learn about the basics of Go.
We'll cover the following...
Due to its easy-to-use syntax, lightweight executable, and high performance, Go would be a great choice to build the backend of any application.
For those who have not used Go in a while, we'll go over a few of the key concepts at lightning-fast speed. We won't be touching concurrency.
Variables
A variable is a means to store a value. It could be a string, a number (int
, float
), or something a little more complicated, like an array, a map, or a struct. In case you forgot how those work in Go, don’t worry! We’ll go over them soon enough.
Variables can be declared and defined in two ways.
var a int
The line above declares a variable a
of type int
.
var a = 10
The line above declares a variable a
and assigns it the value 10
.
a := 10
This is a shorthand way of declaring and defining a variable. One thing to keep in mind is that this notation works only for local variables.
Arrays and slices
Both arrays and slices in Go represent a collection of similar items, but they have a few subtle differences.