EndTransactionWithCheck ends a transaction and overwrites the error pointer if its value was nil. If the transaction succeeded then it is committed, otherwise it is rolledback. Designed to be used with defer (see EndTransaction otherwise).
(txn Transaction, succeeded *bool, err *error)
| 51 | // If the transaction succeeded then it is committed, otherwise it is rolledback. |
| 52 | // Designed to be used with defer (see EndTransaction otherwise). |
| 53 | func EndTransactionWithCheck(txn Transaction, succeeded *bool, err *error) { |
| 54 | if e := EndTransaction(txn, succeeded); e != nil && *err == nil { |
| 55 | *err = e |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | // WithTransaction runs a block of code passing in an SQL transaction |
| 60 | // If the code returns an error or panics then the transactions is rolledback |
no test coverage detected