q Read more on defer statement https://go.dev/blog/defer-panic-and-recover

defer keyword defers the execution of a function until the current function returns (arguments evaluated immediately though).

package main
 
import "fmt"
 
func main() {
	defer fmt.Println("world")
 
	fmt.Println("hello")
}

Output:

hello
world

Deferred calls are pushed onto a stack.