Types give the user the ability to store values in mnemonic names. All programming languages have types related with numbers (to store integers, negative numbers, or floating point for example) with characters (to store a single character) with strings (to store complete words) and so on. Go language has the common types found in most programming languages:
bool
keyword is for Boolean type which represents a True
or False
state.int
is a signed integer type, so int type represents a number from -2147483648 to 2147483647 in 32 bits machinesbyte
type represents a number from 0 to 255.float32
and float64
types are the set of all IEEE-754 64/-bit floating-point numbers respectively.signed int
type like rune
which is an alias of int32
type, a number that goes from -2147483648 to 2147483647 and complex64
and complex128
which are the set of all complex numbers with float32
/ float64
real and imaginary parts like 2.0i.
string
keyword for string type represents an array of characters enclosed in quotes like "golang"
or "computer"
.array
that is a numbered sequence of elements of a single type and a fixed size (more about arrays later in this chapter). A list of numbers or lists of words with a fixed size is considered arrays.slice
type is a segment of an underlying array (more about this later in this chapter). This type is a bit confusing at the beginning because it seems like an array but we will see that actually, they are more powerful.interface
is incredibly important for the language as they provide many encapsulation and abstraction functionalities that we'll need often. We'll use interfaces extensively during the book and they are presented in greater detail later.map
types are unordered key-value structures. So for a given key, you have an associated value.18.118.139.224