1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-05 22:37:42 +02:00

Merge pull request #3274 from divayprakash/fix-go

Fix defer wording, closes #2673
This commit is contained in:
Divay Prakash
2018-10-09 23:04:02 +05:30
committed by GitHub

View File

@@ -277,7 +277,8 @@ func sentenceFactory(mystring string) func(before, after string) string {
} }
func learnDefer() (ok bool) { func learnDefer() (ok bool) {
// Deferred statements are executed just before the function returns. // A defer statement pushes a function call onto a list. The list of saved
// calls is executed AFTER the surrounding function returns.
defer fmt.Println("deferred statements execute in reverse (LIFO) order.") defer fmt.Println("deferred statements execute in reverse (LIFO) order.")
defer fmt.Println("\nThis line is being printed first because") defer fmt.Println("\nThis line is being printed first because")
// Defer is commonly used to close a file, so the function closing the // Defer is commonly used to close a file, so the function closing the