This is a creation in Article, where the information may have evolved or changed.
Go Language data type
In the Go programming language, data types are used to declare functions and variables.
Data types appear to be in order to divide the data into the required memory size of the data, programming when you need to use big data when you need to apply for large memory, you can make full use of memory.
The Go language has the following data types by Category:
Serial Number |
Type and Description |
1 |
Boolean type The value of a Boolean can only be a constant true or false. A simple example: var b bool = True. |
2 |
Number Type integer int and floating-point Float,go languages Support integer and floating-point numbers, and natively support complex numbers, where bits are operated in complement. |
3 |
String type: A string is a sequence of characters concatenated with fixed-length characters. The string of Go is connected by a single byte. The byte of the Go language uses UTF-8 encoding to identify Unicode text. |
4 |
derived type: Including:
- (a) pointer type (Pointer)
- (b) Array type
- (c) structured type (struct)
- (d) Type of Consortium (union)
- (e) Function type
- (f) Slice type
- (g) interface type (interface)
- (h) Map type
- (i) Channel type
|
Number Type
Go also has schema-based types, such as: int, uint, and uintptr.
Serial Number |
Type and Description |
1 |
Uint8 Unsigned 8-bit integer (0 to 255) |
2 |
UInt16 Unsigned 16-bit integer (0 to 65535) |
3 |
UInt32 Unsigned 32-bit integer (0 to 4294967295) |
4 |
UInt64 Unsigned 64-bit integer (0 to 18446744073709551615) |
5 |
int8 Signed 8-bit integer (-128 to 127) |
6 |
Int16 Signed 16-bit integer (-32768 to 32767) |
7 |
Int32 Signed 32-bit integer (-2147483648 to 2147483647) |
8 |
Int64 Signed 64-bit integer (-9223372036854775808 to 9223372036854775807) |
Floating point type:
Serial Number |
Type and Description |
1 |
Float32 IEEE-754 32-bit floating-point number |
2 |
Float64 IEEE-754 64-bit floating-point number |
3 |
Complex64 32-bit real and imaginary numbers |
4 |
complex128 64-bit real and imaginary numbers |
Other number types
Additional number types are listed below:
Serial Number |
Type and Description |
1 |
Byte Similar uint8 |
2 |
Rune Similar Int32 |
3 |
UInt 32 or 64 bits |
4 |
Int As large as uint |
5 |
uintptr Unsigned integer for holding a pointer |