Types?
-
Go is statically typed language means every variable's type is fixed at
compile time, which helps catch errors early and makes code reliable.
Types of types
| Type | Description |
|---|---|
| 1. Basic Type |
int, float64, bool, string
|
| 2. Aggregate Types |
1. Arrays:An array is a fixed-size sequence of elements of
the same type.
2. struct
|
| Reference Types |
Pointers: variable that stores the memory address of another
variable (&) slices: maps functions channels |
| 4. Interface Types |
What?
Interface can hold any type (int, string, struct, etc.) without
specifying type. This is similar to Pure Virtual Functions in C++98, Concepts in C++20 Example: Create hashmap of key=string, value=interface{} to hold different types of values
|