Skip to content

Instantly share code, notes, and snippets.

@taichino
Last active August 30, 2018 19:01
Show Gist options
  • Save taichino/53e7202e8f219fbc503a5f8717fd6004 to your computer and use it in GitHub Desktop.
Save taichino/53e7202e8f219fbc503a5f8717fd6004 to your computer and use it in GitHub Desktop.
package main
import "fmt"
func trace(msg string) string {
fmt.Printf("BEGIN %s\n", msg)
return msg
}
func untrace(msg string) string {
fmt.Printf("END %s\n", msg)
return msg
}
func main() {
// begin -> do -> end
defer untrace(trace("main"))
fmt.Printf("Do\n")
}
func trace(_ msg: String) -> String {
print("BEGIN \(msg)")
return msg
}
func untrace(_ msg: String) -> String {
print("END \(msg)")
return msg
}
func main() {
// do -> begin -> end
defer { _ = untrace(trace("main")) }
print("DO")
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment