Primitive Data Types (Basic Data Types)

string
bool
float32  // no default. float64 is accurate to 6 digits. Using period 22. is a good habit (no numeric conversion)
float64 // no default. float64 is accurate to 15 digits. Using period 22. is a good habit (no numeric conversion)
int, int8, int16, int32, int64 // Int is the default
uint, uint8, uint16, uint32, uint64, uintptr
byte // alias for uint8
rune // alias for int32
complex64 complex128

Integer Types

The predefine architecture-independent integer types are:

S.N. Types and Description
1 uint8 Unsigned 8-bit integers (0 to 255)
2 uint16 Unsigned 16-bit integers (0 to 65535)
3 uint32 Unsigned 32-bit integers (0 to 4294967295)
4 uint64 Unsigned 64-bit integers (0 to 18446744073709551615)
5 int8 Signed 8-bit integers (-128 to 127)
6 int16 Signed 16-bit integers (-32768 to 32767)
7 int32 Signed 32-bit integers (-2147483648 to 2147483647)
8 int64 Signed 64-bit integers (-9223372036854775808 to 9223372036854775807)

Aggregate types

array, structs

Reference types

pointers, slices, maps, func, channels

Interface types

An interface type specifies a set of methods that a concrete type must possess to be considered an instance of that interface.

Use of types

Types provide the compiler two informations: how much memory to allocate and what the memory represents

int64: 8byte, 64bits
int32: 4byte, 32bits
bool: 1byte, 8bits

results matching ""

    No results matching ""