Go language data types
In the Go programming language, data types are used to declare functions and variables.
The emergence of data types is to divide data into data with different required memory sizes. When programming, you need to apply for large memory when you need to use big data, so that you can make full use of the memory.
Go language has the following data types according to categories:
Serial number | Type and description |
---|---|
1 | Boolean type The value of Boolean type can only be the constant true or false. A simple example: var b bool = true. |
2 | Number type Integer int and floating point float, Go language supports integer and floating point numbers, And it natively supports complex numbers, and its bit operations use complement codes. |
3 | String type: A string is a sequence of characters connected by a fixed length of characters. Go's strings are concatenated from single bytes. The bytes of Go language strings use UTF-8 encoding to identify Unicode text. |
4 | Derived types: Includes:
|
Number types
Go also has schema-based types, such as int, uint and uintptr.
Serial number | Type and description |
---|---|
uint8Unsigned 8-bit integer type (0 to 255) | |
uint16Unsigned 16-bit integer type (0 to 65535) | |
uint32Unsigned 32-bit integer (0 to 4294967295) | |
uint64Unsigned 64-bit integer (0 to 18446744073709551615) | |
int8Signed 8-bit integer (-128 to 127) | |
int16Signed 16-bit integer (-32768 to 32767) | |
int32Signed 32-bit Integer type (-2147483648 to 2147483647) | |
##int64 | Signed 64-bit integer type (-9223372036854775808 to 9223372036854775807) |
Type and description | |
---|---|
float32 | IEEE-754 32-bit floating point number |
float64 | IEEE-754 64-bit floating point number |
complex64 | 32 bits Real and imaginary numbers |
complex128 | 64-bit real and imaginary numbers |
Serial number | Type and Description |
---|---|
1 | byte Similar to uint8 |
2 | rune Similar to int32 |
3 | uint 32 or 64-bit |
4 | int The same size as uint |
5 | uintptr Unsigned integer, used to store a pointer |