Main menu

Pages

Golang Data types - go programming language

Golang Data types - go programming language, data types define the type of data that a usable Go variable can contain. In Go, data types are divided into four classes as follows.


Golang Data types - go programming language


Data types in Go


  • Basic types: These include numbers, strings, and Booleans.
  • Aggregate type: Arrays and Structs are the most complex data types.
  • Reference types: These include a variety of types such as pointers, slices, and maps.
  • Interface types.


Basic data types in Go Basic types


In the Go Language, basic data types are divided into several categories.


Integers


Integers in Go are divided into four different sizes: 8-bit, 16-bit, 32-bit, 64-bit (int8, int16, int32, int64) and may be preceded by a (+) or (-) sign. It is called (Signed integer), and the other type of these numbers is (Unsigned integer) and is not preceded by any sign. and also comes in different sizes and is called the following names: (uint8, unit16 unit32, unit64).


Floating Point Numbers


These are numbers that contain a decimal point. There are two types of these numbers: (float32 and float64) and their arithmetic properties are governed by the (IEEE 754) standard that is applied by all modern processors.


Complex Numbers


Go offers two sizes of this type of number (complex64 and complex128), and their components are (float32 and float64).


Booleans


A value of type (Boolean) has two possible values ​​(false or true), and the conditions in (if and for) statements are Boolean values, ​​and comparison factors such as: (<), (> ), (=) also result in Boolean values.


Strings


In the Go programming language, text strings differ from other languages ​​such as (Java, C) and Python, as they are a series of characters (characters) each character is represented by one or more bytes using UTF-8 Encoding. and because Go uses this type of encoding, strings can contain text that is a mixture of any language in the world, and strings are written using double quotes. ).


You can read more about golang libraries here in this article.