

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Learn Go
incomplete
2: Declaring a Variable
incomplete
3: Basic Variables
incomplete
4: Short Variable Declaration
incomplete
5: Why Go?
incomplete
6: Comments
incomplete
7: The Compilation Process
incomplete
8: Fast and Compiled
incomplete
9: Type Sizes
incomplete
10: Which Type Should I Use?
incomplete
11: Go Is Statically Typed
incomplete
12: Compiled vs. Interpreted
incomplete
13: Same Line Declarations
incomplete
14: Small Memory Footprint
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Integers, uints, floats, and complex numbers all have type sizes.
int int8 int16 int32 int64
uint uint8 uint16 uint32 uint64 uintptr
float32 float64
complex64 complex128
The size (8, 16, 32, 64, 128, etc.) represents how many bits in memory will be used to store the variable. The "default" int and uint types refer to their respective 32 or 64-bit sizes depending on the environment of the user.
The "standard" types that should be used unless you have a specific performance need (e.g. using less memory) are:
intuintfloat64complex128Some types can be easily converted like this:
temperatureFloat := 88.26
temperatureInt := int(temperatureFloat)
Casting a float to an integer in this way truncates the floating point portion.
Our Textio customers want to know how long they have had accounts with us.
On line 7, create an accountAgeInt variable and assign it the value of accountAgeFloat truncated to an integer.