- Implementing sqrt() using newton’s method:
-
GO’s switch case format is similar to C, C++ etc. But one thing that sets it apart is it only runs the selected part, not the cases that follow.
-
In switch a condition is same as switch true
. Clean way to write long if-else
statements.
-
A defer statement defers the execution of a function until the surrounding function returns. Deferred function calls are pushed onto a stack. When surrounding function returns, deferred calls are executed in LIFO order
More Types - structs, slice and maps
Structs
-
Pointers in GO are just like they are in C++, but without pointer arithmetic. Zero value of pointer in GO is nil
-
A struct is like a structure in C++. To access fields of a struct .
notation is used. It allows us to use pointer as a variable without dereferencing [in terms of notation]
-
Example of struct literal. These are nothing but variables of particular struct
type.
Array
-
The expression var a [10]int
declares a
as an array of ten integers.
Slice