O'Reilly logo

Go Standard Library Cookbook by Radomir Sohlich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required