Datatype in Go

  • Data types specify the type of data that a valid Go variable can hold.
  1. Basic type: Numbers, strings, and Booleans come under this category.
  2. Aggregate type: Array and structs come under this category.
  3. Reference type: Pointers, slices, maps, functions, and channels come under this category.
  4. Interface type

*In Go language, numbers are divided into three sub-categories that are: Integers: In Go language, both signed and unsigned integers are available in four different sizes

Data TypeDescription
int88-bit signed integer
int1616-bit signed integer
int3232-bit signed integer
int6464-bit signed integer
uint88-bit unsigned integer
uint1616-bit unsigned integer
uint3232-bit unsigned integer
uint6464-bit unsigned integer
intBoth int and uint contain same size, either 32 or 64 bit.
uintBoth int and uint contain same size, either 32 or 64 bit.
runeIt is a synonym of int32 and also represent Unicode code points.
byteIt is a synonym of uint8.
uintptrIt is an unsigned integer type. Its width is not defined, but its can hold all the bits of a pointer value.

Floating-Point Numbers: In Go language, floating-point numbers are divided into two categories

Data TypeDescription
float3232-bit IEEE 754 floating-point number
float6464-bit IEEE 754 floating-point number

==Complex Numbers==: The complex numbers are divided into two parts are shown in the below table.

Data TypeDescription
complex64Complex numbers which contain float32 as a real and imaginary component.
complex128Complex numbers which contain float64 as a real and imaginary component.

Booleans : The Boolean data type represents only one bit of information either true or false.

Strings : The string data type represents a sequence of Unicode code points.