batch.go
func (wb *WriteBatch) Flush() error {
	wb.Lock()
	_ = wb.commit()
	wb.txn.Discard()
	wb.Unlock()

	wb.wg.Wait()
	// Safe to access error without any synchronization here.
	return wb.err
}
func (wb *WriteBatch) Flush() error {
	wb.Lock()
	_ = wb.commit()
	wb.txn.Discard()
	wb.Unlock()

	wb.wg.Wait()
	// Safe to access error without any synchronization here.
	return wb.err
}
func ( wb * WriteBatch ) Flush ( ) error { wb . Lock ( ) _ = wb . commit ( ) wb . txn . Discard ( ) wb . Unlock ( ) wb . wg . Wait ( ) // Safe to access error without any synchronization here. return wb . err }
// Flush must be called at the end to ensure that any pending writes get committed to Badger. Flush
// returns any error stored by WriteBatch.
Flush must be called at the end to ensure that any pending writes get committed to Badger . Flush returns any error stored by WriteBatch .