Go

Advantages of Go

  1. Code runs fast
  2. Garbage Collection
  3. Simpler Objects
  4. Concurrency is efficient

Nuances

  • An init function is automatically called before the main function in go
  • Everything in go has some interface associated with it

Function Concepts

Variable Function Arguments

func a(test ...int){

}

Variadic Slice Argument

b := []int{1,3,4,5}
a(b...)

Deferred Function Calls

Don’t execute right away. When the surrounding function completes Use keyword defer before function call

argument is evaluated right away

func main() {
	i := 1
	defer fmt.Println(i+1)
	fmt.Println(i)
	i++
	fmt.Println(i)
}

this prints

1
2
2

Tricks