Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Go language data type


May 11, 2021 Go


Table of contents


Go language data type

In the Go programming language, data types are used to declare functions and variables.

Data types appear to divide data into data of different memory sizes, programming requires big data when you need to apply 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 boolean can only be constant true or false. A simple example: var b bool s true.
2 The type of number
Integer int and float, the Go language supports integer and floating-point numbers, and the native supports complex numbers, where bit operations use complements.
3 String type:
A string is a sequence of characters connected by a fixed-length string of characters. G o's strings are connected by a single byte. Bytes of strings in the Go language identify Unicode text using UTC-8 encoding.
4 Derived type:
Including:
  • (a) Pointer type (Pointer)
  • (b) Array type
  • (c) Structured type (struct)
  • (d) Union type (union)
  • (e) The type of function
  • (f) The type of slice
  • (g) Interface type (interface)
  • (h) Map type
  • (i) Channel type

The type of number

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 1844674073709551615)
5 int8
Signed 8-bit integer (-128 to 127)
6 int16
Signed 16-bit integer (-32768 to 32767)
7 int32
Symbolic 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
4 complex128
64-bit real and imaginary numbers

Other numeric types

More number types are listed below:

Serial number Type and description
1 byte
Similar to uint8
2 rune
Similar to int32
3 uint
32 or 64 bits
4 Int
The same size as uint
5 uintptr
Unsigned integer for storing a pointer