Table of Contents
Prerequisites for learning Go
Documents related to go are following a series on Udemy by Maximilian Schwarzmüller among some other prominent developers and course creators on LinkedIn Learning. To follow along with learning go, it is highly recommended to know the basics of another language.
Abstract
Basic Types
Go comes predefined with a couple of built-in basic types, these include but are not limited to the following:
int
: A number WITHOUT a decimal place (e.g., -5, 10, 15)float64
: A number WITH a decimal place (e.g., -5.2, 10.0, 15.9)string
: A textual value (created via ` or ”) (e.g.,"Hello World"
)
bool
: Can only be eithertrue
orfalse
There are however, many more “niche” basic types that should be known and are used often:
uint
: An unsigned integer, which means a strictly non-negative meaning NO negative integers (e.g., 0, 5, 10, 15)int32
: A 32-bit signed integer, which is an integer with a specific range from -2,147,483,648 to 2,147,483,647.rune
An alias forint32
, represents a single Unicode code point (i.e., a single character), and is used for dealing with Unicode characters.uint32
: A 32-bit unsigned integer, an integer that can represent values from 0 to 4,294,967,295.int64
⇒ A 64-bit signed integer, an integer that can represent a larger range of values which are from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
There are many other types like int8
or uint8
these all work in a similar fashion.
What are Types?
Go has a very comprehensive type system, however types in go are very simple and straightforward. Go as of now, currently consists of the following types:
- Strict Types;
- Pre-declared (Named) Types;
- Composite (Unnamed) Types.
Strict Types in Go
var counter int // def: 0
var mask int32 // def: 0
var message string // def: ""
Named Types in Go
Composite Types in Go
What are Null Types?
All go value types come with a so-called “null value” which is the value stored in a variable if no other value is predefined (explicitly) set. You can consider them also as default values for each data type before assignment.
Here is a list of all null values for different types:
int
: 0float64
: 0.0string
:""
(also known as an Empty String)bool
: false
Definitions
TL;DR
Extensions ✨
Courses on Go
- Go - The Complete Guide by Maximillian Schwarzmüller
- Go Essentials - Concurrency, Connectivity, and High-Performance Apps by Miki Tebeka
- Learning Go by David Gassner
- Learning the Go Standard Library by Joe Marini
- Go Design Patterns by Joe Marini