Last active
August 30, 2018 19:01
-
-
Save taichino/53e7202e8f219fbc503a5f8717fd6004 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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