How it works...
The transaction handling, as the preceding code illustrates, is very simple. The method, Begin, of the DB struct pointer creates the transaction with a default isolation level (depends on driver). The transaction, by its nature, is kept on the single connection and is represented by the returned pointer to the Tx struct.
The pointer, Tx, implements all the methods available to the DB struct pointer; the exception is that all the operations are done within the transaction (if the database is able to process the statement in the transaction). The transaction is ended by calling the Rollback or Commit method on the Tx struct pointer. After this call, the transaction is finished and other operations will end by the error ErrTxDone ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access