If an error is encountered before you are able to commit, you may want to still rollback. You can defer the Rollback for this case and ignore the ErrTxDone error if Commit is successfully invoked.
tx, err := appState.PgConn.Beginx()
if err != nil {
return err
}
defer tx.Rollback()