Skip to content

Instantly share code, notes, and snippets.

@xavierskip
Last active March 4, 2017 14:56
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 xavierskip/8fc8526ec3af545d30de130020d0bc8a to your computer and use it in GitHub Desktop.
Save xavierskip/8fc8526ec3af545d30de130020d0bc8a to your computer and use it in GitHub Desktop.
gopl.io 5.19 使用panic和recover编写一个不包含return语句但能返回一个非零值的函数
func noReturn() (result int) {
defer func() {
p := recover()
result = p.(int)
}()
panic(42)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment