Skip to content

Instantly share code, notes, and snippets.

@maciej
Last active December 2, 2019 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maciej/3178356ae94d4e8dc8e4dbbf36ad1773 to your computer and use it in GitHub Desktop.
Save maciej/3178356ae94d4e8dc8e4dbbf36ad1773 to your computer and use it in GitHub Desktop.
package main
import "fmt"
func defer1() {
var s = "Hello!"
defer fmt.Println(s)
s = "Ahoy!"
}
func defer2() {
var s = "Hello!"
defer func() { fmt.Println(s) }()
s = "Ahoy!"
}
func main() {
defer1()
defer2()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment