Welcome to tutorial no. 29 in Golang tutorial series. What is Defer? Defer statement is used to execute a function call just before the surrounding function where the defer statement is present returns. The definition might seem complex but it’s pretty simple to understand by means of an example. Example 1package main 2 3import ( 4 "fmt" 5 "time" 6) 7 8func totalTime(start time.Time) { 9 fmt.Printf("Total time taken %f seconds", time.