In the Go programming language, data types are used to declare functions and variables.
A variable can be a boolean (True/False), a number (1,2,3), text etc. The Go language needs to know what kinds of data you want to store.
There are several types of data by category:
No. | Type and Description |
---|---|
1 | Boolean Boolean values ββcan only be constants true or false. A simple example: var b bool = true. |
2 | numeric type Int integer and floating-point float, Go language support integer and floating point numbers, and native support complex, wherein the position calculation using complement. |
3 | string type: Character string is a string of fixed length connecting the character sequence. Go strings are connected by a single byte. Go byte language string using UTF-8 encoding of a Unicode text identifier. |
4 | derived types: pointer, an array, struct, Union, function, slice, interface, map, channel |
numeric type
Go is also based on the type of architecture, such as: int, uint and uintptr.
No. | Type 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 4,294,967,295) |
4 | uint64 64-bit unsigned integer (0-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) |
Float:
No. | 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 |
4 | complex128 64-bit real and imaginary |
other numeric types
Here are more of the other types of numbers:
No. | Type and Description |
---|---|
1 | byte Similar uint8 |
2 | rune Similar int32 |
3 | uint 32 or 64 |
4 | int And the same size as uint |
5 | uintptr Unsigned int, for storing a pointer |
Top comments (0)