Thursday 4 April 2024

go lang derfer

 https://go.dev/tour/flowcontrol/12



Defer

A defer statement defers the execution of a function until the surrounding function returns.

The deferred call's arguments are evaluated immediately, but the function call is not executed until the surrounding function returns.



package main


import "fmt"


func main() {

defer fmt.Println("world")


fmt.Println("hello")

}


No comments:

Post a Comment