diff

package
v0.0.0-rc6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiffAsStringOptions

func DiffAsStringOptions() *diffItemsAsStringOptions

Types

type DiffItem

type DiffItem struct {
	Line string
	From DiffSource
}

type DiffItems

type DiffItems []DiffItem

DiffItems is array of diff items, that has useful `AsString` method which can give you a readable format. You can use default String method if you want default settings

func Diff

func Diff(a, b []string) (diffItems DiffItems, err error)

Diff takes two array of strings of arbitrary size and returns array of DiffItem. Each diff item repesents a Line and it's purpose -- added from left string array, added from right string, or equal in both left and right string arrays.

func LineDiff

func LineDiff(a, b string) (DiffItems, error)

LineDiff takes two strings and calculates diff in terms of lines that came from a or from b. It calculates DiffItems, which is array of []DiffItem -- an array of minimal length that describes what lines came from a, what lines came from b, and what lines are common. Further DiffItems can be converted to string with AsString method.

func (DiffItems) AsString

func (d DiffItems) AsString(options *diffItemsAsStringOptions) string

AsString converts array of DiffItem into single string. You can control the result with parameter `options *DiffItemsAsStringOptions`, or set it to null for default configuration

func (DiffItems) String

func (d DiffItems) String() string

String converts DiffItems to string with AsString method with default string conversion options

type DiffSource

type DiffSource string
const (
	DiffSourceBoth  DiffSource = "both"
	DiffSourceLeft  DiffSource = "left"
	DiffSourceRight DiffSource = "right"
)

Jump to

Keyboard shortcuts

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