Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify defer using a stack to store the function in example #32179

Closed
Windsooon opened this issue May 22, 2019 · 1 comment
Closed

Clarify defer using a stack to store the function in example #32179

Windsooon opened this issue May 22, 2019 · 1 comment

Comments

@Windsooon
Copy link

I'm not sure using multiple defer is common. But In the https://tour.golang.org/flowcontrol/12, I think we can mention that defer would put the functions into an extra stack(LIFO)

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

// hello
// world2
// world

IMO, we may add a note in the docs or update the code.

@Windsooon
Copy link
Author

I found that https://tour.golang.org/flowcontrol/13 mentioned it.

@golang golang locked and limited conversation to collaborators May 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants