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

var a int = 42
str := "Go is awesome" // Type inference
b := true
var f float64 = float64(a)      //Type Conversion
                
2. Aggregate Types 1. Arrays:An array is a fixed-size sequence of elements of the same type.

colors := [3]string{"red", "green", "blue"}
            
2. struct

type Person struct {
    Name string
    Age  int
}
func (p Person) fun() string {  //Define function for struct
    return "Hello, my name is " + p.Name
}
                
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

{
	message := map[string]interface{}{
		"timestamp": time.Now().Unix(),
		"sound": "default",
		"title": "title",
		"body":  json{},
	}
	return MakeHTTPPOSTCall(message)
}