Numbers
Go supports two primary numeric types: integers and floating-point numbers.Integers
Theint type in Go represents signed integers, which means it can store both negative and positive numbers (e.g., -90, 453, 1000000). In addition to int, Go provides several specific integer types that vary in memory allocation:
int8uses 8 bits (1 byte) and has a limited range.uint16uses 16 bits (2 bytes) to represent unsigned integers (only non-negative numbers, including 0).

When choosing an integer type in your Go programs, consider the required range of values and memory footprint.
Floating-point Numbers
Floating-point numbers, or floats, are numbers that include a decimal component. Go provides two floating-point types:float32(single precision, 32 bits or 4 bytes)float64(double precision, 64 bits or 8 bytes)
float64 is recommended due to its higher precision. Examples of floating-point numbers include: 80.09, 0.775, and 50.76.

Strings
A string in Go is a sequence of characters that may include letters, numbers, and symbols. Strings are created using thestring type and must be enclosed in double quotes. For example:
- “abc”
- “90%”
- “home”
- “cat”
- “kodekloud”

Booleans
The boolean data type in Go is defined using thebool keyword. Booleans can only take one of the two values: true or false (always in lowercase). Unlike some other programming languages that allow numeric representations (e.g., 1 and 0), Go requires an explicit boolean value. A boolean in Go occupies 1 byte of memory.

When working with booleans in Go, always use
true or false explicitly rather than numeric equivalents.Arrays, Slices, and Maps
Beyond the basic data types, Go offers more complex data structures such as arrays, slices, and maps. These structures are fundamental for managing collections of data.Example Code Block
Below is an example showcasing arrays, slices, and maps in Go:Data Structures Overview
| Data Structure | Description | Example Syntax |
|---|---|---|
| Array | Fixed-size sequence of elements | [4]int{1,2,4,9} |
| Slice | Dynamically-sized, flexible view into arrays | []string{"foo", "bar"} |
| Map | Collection of key-value pairs | map[string]int{"x":30} |