YouTip LogoYouTip

Go Data Types

# Go Data Types In the Go programming language, data types are used to declare functions and variables. The purpose of data types is to divide data into different memory sizes. When programming, you only need to request large memory when you need to use large data, which allows for efficient memory utilization. Go has the following data types by category: | No. | Type and Description | | --- | --- | | 1 | **Boolean** The value of a boolean type can only be the constant true or false. A simple example: var b bool = true. | | 2 | **Numeric Types** Integer types int and floating-point types float32, float64. Go supports integer and floating-point numbers, and also supports complex numbers, where bitwise operations use two's complement. | | 3 | **String Type:** A string is a sequence of characters of fixed length connected together. Go strings are made up of single bytes. The bytes of Go strings use UTF-8 encoding to identify Unicode text. | | 4 | **Derived Types:** Include: * (a) Pointer types (Pointer) * (b) Array types * (c) Structured types (struct) * (d) Channel types * (e) Function types * (f) Slice types * (g) Interface types (interface) * (h) Map types | * * * ## Numeric Types Go also has architecture-dependent types, such as: int, uint, and uintptr. | No. | 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 Types | 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 parts | | 4 | **complex128** 64-bit real and imaginary parts | * * * ## Other Numeric Types The following lists other more numeric types: | No. | Type and Description | | --- | --- | | 1 | **byte** Similar to uint8 | | 2 | **rune** Similar to int32 | | 3 | **uint** 32 or 64 bits | | 4 | **int** Same size as uint | | 5 | **uintptr** An unsigned integer used to store a pointer |
← Python3 Month DaysPython3 Check String β†’