func (l *lock) Unlock() error {
	l.mu.Lock()
	defer l.mu.Unlock()

	if !l.locked {
		return fmt.Errorf("attempted to unlock when no lock has been acquired")
	}
	if l.tx == nil {
		return fmt.Errorf("attempted to unlock but no transaction is populdated in scanLock")
	}

	// commiting the transaction will free the pg_advisory lock allowing other
	// instances utilizing a lock to proceed
	err := l.tx.Commit()
	if err != nil {
		return fmt.Errorf("failed to commit transaction and free lock: %v", err)
	}
	l.locked = false

	return nil
}
// UnLock first checks if the scanLock is in a locked state, secondly checks to
// confirm the tx field is not nil, and lastly will commit the tx allowing
// other calls to Lock() to succeed and sets l.locked = false.
UnLock first checks if the scanLock is in a locked state, secondly checks to
confirm the tx field is not nil, and lastly will commit the tx allowing
other calls to Lock() to succeed and sets l.locked = false.
// UnLock first checks if the scanLock is in a locked state secondly checks to // confirm the tx field is not nil and lastly will commit the tx allowing // other calls to Lock () to succeed and sets l . locked = false .
func (l *lock) Unlock() error {
	l.mu.Lock()
	defer l.mu.Unlock()
	if !l.locked {
		return fmt.Errorf("attempted to unlock when no lock has been acquired")
	}
	if l.tx == nil {
		return fmt.Errorf("attempted to unlock but no transaction is populdated in scanLock")
	}
	err := l.tx.Commit()
	if err != nil {
		return fmt.Errorf("failed to commit transaction and free lock: %v", err)
	}
	l.locked = false
	return nil
}
func ( l * lock ) Unlock ( ) error { l . mu . Lock ( ) defer l . mu . Unlock ( ) if ! l . locked { return fmt . Errorf ( " " ) } if l . tx == nil { return fmt . Errorf ( " " ) } err := l . tx . Commit ( ) if err != nil { return fmt . Errorf ( " " , err ) } l . locked = false return nil }
UnLock first checks if the scanLock is in a locked state, secondly checks to
confirm the tx field is not nil, and lastly will commit the tx allowing
other calls to Lock() to succeed and sets l.locked = false.
UnLock first checks if the scanLock is in a locked state secondly checks to confirm the tx field is not nil and lastly will commit the tx allowing other calls to Lock () to succeed and sets l . locked = false .
// commiting the transaction will free the pg_advisory lock allowing other // instances utilizing a lock to proceed