

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
With so many types for what is essentially just a number, developers coming from languages that only have one kind of Number type (like JavaScript) may find the choices daunting.
A problem arises when we have a uint16, and the function we are trying to pass it into takes an int. We're forced to write code riddled with type conversions like:
var myAge uint16 = 25
myAgeInt := int(myAge)
This style of code can be slow and annoying to read. When Go developers stray from the "default" type for any given type family, the code can get messy quickly. Unless you have a good performance related reason, you'll typically just want to use the "default" types:
boolstringintuintbyterunefloat64complex128When you're super concerned about performance and memory usage.
That's about it. The only reason to deviate from the defaults is to squeeze out every last bit of performance when you are writing an application that is resource-constrained. (Or, in the special case of uint64, you need an absurd range of unsigned integers).