Go Language Data Types

Numeric types
Numeric types are built in, will be familiar:

int

uint

float

int8

uint8 = byte

int16

uint16

int32

uint32

float32

int64

uint64

float64

Also uintptr, an integer big enough to store a pointer.
These are all distinct types; int is not int32 even on a 32-bit machine.
No implicit conversions.

Bool

The usual boolean type, bool, with values true and false (predefined constants).
The if statement etc. use boolean expressions.
Pointers and integers are [...]

Numeric types

Numeric types are built in, will be familiar:

int

uint

float

int8

uint8 = byte

int16

uint16

int32

uint32

float32

int64

uint64

float64

  • Also uintptr, an integer big enough to store a pointer.
  • These are all distinct types; int is not int32 even on a 32-bit machine.
  • No implicit conversions.

Bool

  • The usual boolean type, bool, with values true and false (predefined constants).
  • The if statement etc. use boolean expressions.
  • Pointers and integers are not booleans.

String

  • The built-in type string represents immutable arrays of bytes – that is, text. Strings are length-delimited not NUL-terminated.
  • String literals have type string.
  • Immutable, just like ints. Can reassign variables but not edit values.

Just as 3 is always 3, “hello” is always “hello”.

No related posts.