diff

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyPatch

func ApplyPatch(content, patch []byte) ([]byte, error)

ApplyPatch applies a patch to the given content

func Compare

func Compare(path1, path2 string) (bool, error)

Compare returns true if the given files are different

func CreatePatch

func CreatePatch(oldContent, newContent []byte) []byte

CreatePatch creates a patch from the given old and new content

func Merge

func Merge(oldContent, newContent []byte) ([]byte, error)

Merge merges the given old and new content

func MergeFiles

func MergeFiles(oldPath, newPath, outputPath string) error

MergeFiles merges the given old and new files

Types

type Diff

type Diff struct {
	Path    string
	Patches []diffmatchpatch.Patch
}

Diff represents a diff

func FromBytes

func FromBytes(path string, data []byte) (*Diff, error)

FromBytes returns a diff from bytes

func New

func New(path string, oldContent, newContent []byte) *Diff

New creates a new diff

func (*Diff) Apply

func (d *Diff) Apply() error

Apply applies the diff

func (*Diff) ApplyToContent

func (d *Diff) ApplyToContent(content []byte) ([]byte, error)

ApplyToContent applies the diff to the given content

func (*Diff) HasChanges

func (d *Diff) HasChanges() bool

HasChanges returns true if the diff has changes

func (*Diff) ToBytes

func (d *Diff) ToBytes() []byte

ToBytes returns the diff as bytes

Jump to

Keyboard shortcuts

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