defer tx.Rollback()
...
tx.Commit() // at the end
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to golang-nuts+unsubscr...@googlegroups.com.
For more options,
Then there should only be a single err variable, and the address should not
change. Not sure why it isn’t working are you sure you are not in a code
block that is causing a shadowing of err?
> On Dec 3, 2018, at 4:54 PM, Ben Hoyt wrote:
>
> Ah, quite right. That's what comes of trying to
Ah, quite right. That's what comes of trying to modify the code snippet
from our actual code on the fly. It was more like:
t, err := InsertFoo(tx)
-Ben
On Mon, Dec 3, 2018, 5:50 PM Robert Engels How can you write this
>
> err := InsertFoo(tx)
>
> Don’t you get no new variables defined error
How can you write this
err := InsertFoo(tx)
Don’t you get no new variables defined error here?
> On Dec 3, 2018, at 3:53 PM, Ben Hoyt wrote:
>
> Hi folks,
>
> We found some subtle bugs in our db transaction code for handling
> commits/rollbacks. Here's the pattern we were using (not real,
Hi folks,
We found some subtle bugs in our db transaction code for handling
commits/rollbacks. Here's the pattern we were using (not real, but shows
the issue):
func DoTwoThings() error {
tx, err := db.Begin()
if err != nil {
return err
}
// commit or rollback the