Defer and parameters
package main
import "fmt"
func main() {
text := "start"
defer fmt.Println(text)
defer say(text)
text = "end"
fmt.Printf("end: %v\n", text)
}
func say(text string) {
fmt.Println(text)
}
- The deffered function will see the its parameter when we defer the function not when it is executed