4 ms·
Go's defer feature, combined with named return values, lets you do this: func someFunction(b bool) (i int) { defer func() { log.Printf(
by enneff 15y ago
Go's defer feature, combined with named return values, lets you do this:
func someFunction(b bool) (i int) {
defer func() {
log.Printf("I'm returning %d", i)
}()
if b {
return 1
}
return 0
}
For more on defer, see this blog post: http://blog.golang.org/2010/08/defer-panic-and-recover.html http://blog.golang.org/2010/08/defer-panic-and-recover.html