Lesson 4 of 60 · Go
Primitive Types & Constants
Duration: 15 minutes
Primitive Types & Constants
Go has a small set of fundamental types, which makes the language easier to learn and reason about.
Primitive types
| Type | Description |
|---|---|
bool | true/false |
string | immutable UTF-8 text |
int, int8, int16, int32, int64 | signed integers |
uint, uint8, uint16, uint32, uint64 | unsigned integers |
float32, float64 | floating-point numbers |
byte | alias for uint8 |
rune | alias for int32 (Unicode code point) |
Go uses int and uint as the default integer types when specific size is not required.
Constants
Constants are values that cannot change after they are declared.
const Pi = 3.14159
const (
Red = iota
Green
Blue
)
iota is a tool for automatically incrementing constant values within a block.