Is it possible to defer
to the end of an outer function?
// normal transaction
func dbStuff(){
db.Begin()
...
db.Commit()
}
// normal transaction w/ defer
func dbStuff(){
db.Begin()
defer db.Commit()
...
}
Is this possible?
// can you defer to caller / outer function?
func dbStuff(){
db.Trans()
...
}
// will Commit() when dbStuff() returns
func (db Db) Trans(){
db.Begin()
defer db.Commit() // to caller/outer function
}