diff

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package diff performs diffs on sorted channels of data

Index

Constants

View Source
const (
	// NEW is an enum for a new/added value in a diff passed to ResultFunc
	NEW = iota // +
	// OLD is an enum for a removed value in a diff  passed to ResultFunc
	OLD // -
)

Variables

This section is empty.

Functions

func PrintStringDiff

func PrintStringDiff(d Delta, s string) error

PrintStringDiff satisfies StringResultFunc can can be used as resultFunc in diff.Strings()

Types

type Delta

type Delta int

Delta represents the differential value passed to ResultFunc: NEW/OLD

func (Delta) String

func (d Delta) String() string

type Result

type Result struct {
	ExtraA uint64
	ExtraB uint64
	TotalA uint64
	TotalB uint64
	Common uint64
}

Result stores statistics generated from diffing two streams

func Strings

func Strings(ctx context.Context, aChan, bChan chan string, aErrChan chan error, bErrChan chan error, resultFunc StringResultFunc) (r Result, err error)

Strings takes 4 chan inputs, 2 for strings, and 2 for their corresponding error channels, and a StringResultFunc to be called for every new/old record found when done, counter results and errors (if any) are returned string chan input MUST be sorted, for performance reasons this is not checked!

func (*Result) String

func (r *Result) String() string

type StringChanResult

type StringChanResult struct {
	D Delta
	S string
}

StringChanResult hold diff results for DiffStringResultChan

type StringResultFunc

type StringResultFunc func(Delta, string) error

StringResultFunc defines the interface for a function to be called for each delta record

func StringResultChan

func StringResultChan() (StringResultFunc, chan *StringChanResult)

StringResultChan allows diff.Strings() to be called in parallel with its resultFunc prosessing this function returns a StringResultFunc for use in diff.Strings(), and a channel for consuming diff results in another goroutine

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL