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 numberType and description
1Boolean type
The value of Boolean type can only be the constant true or false. A simple example: var b bool = true.
2Number 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.
3String 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:
  • (a) Pointer type (Pointer)

  • (b) Array type

  • (c) Structural type (struct)

  • (d) Union type (union)

  • (e) Function type

  • (f) Slice type

  • (g) Interface type (interface)

  • (h) Map type

  • (i) Channel type


Number types

Go also has schema-based types, such as int, uint and uintptr.

##12345678##int64Floating point type:
Serial numberType 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)
Signed 64-bit integer type (-9223372036854775808 to 9223372036854775807)

Serial number1float322float643complex644complex128

Other numeric types

The following are listed more other numeric types:

Type and description
IEEE-754 32-bit floating point number
IEEE-754 64-bit floating point number
32 bits Real and imaginary numbers
64-bit real and imaginary numbers
Serial numberType and Description
1byte
Similar to uint8
2rune
Similar to int32
3uint
32 or 64-bit
4int
The same size as uint
5uintptr
Unsigned integer, used to store a pointer