Road to Go Pro — Types & Structures

Song X.
The Startup
Published in
7 min readSep 2, 2020

--

Before we start, you can find the code used in this tutorial in this repository. You can find the full contents of Road to Go Pro here. If you missed the last one, you can find it via this link.

Last but not the least, a special thank you to Mark Hume-Cook for reviewing this article.

Primitive types

Primitive types are the most basic types we use in any programming languages. We’re going to cover the most common four primitive types used in Go. They are boolean, integer, float and string. Let’s get right into it.

Boolean

Boolean is the simplest primitive type. It has only two possible values, true and false.

Integer

Go has multiple integer types. We can categorise them into two groups.

The first group is signed integers, in plain English, signed integers are +ints & -ints & zero. Furthermore, we can use different signed integer types depending on the size. For example, for storing an 8-bit signed integer (-128 to 127), we can use int8. These are the other sizes, int, int8, int16, int32, int64.

--

--

Song X.
The Startup

Software engineer and tech enthusiast. Consulting at DigIO in Melbourne. A big fan of Go. Enjoy reading, cycling and board-gaming.