diff

package
v0.0.0-...-8f349c4 Latest Latest
Warning

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

Go to latest
Published: May 5, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyDiff

func ApplyDiff(original string, result *DiffResult) (string, error)

ApplyDiff applies the changes from a DiffResult to a string

func ApplyPatch

func ApplyPatch(filePath, patch string) error

ApplyPatch applies a patch in unified diff format to a file

func FormatDiff

func FormatDiff(diff *DiffResult, colorize bool) string

FormatDiff formats a DiffResult for display

func GenerateUnifiedDiff

func GenerateUnifiedDiff(original, updated, originalName, updatedName string) string

GenerateUnifiedDiff creates a unified diff format string

func WriteDiffToFile

func WriteDiffToFile(diff *DiffResult, filePath string) error

WriteDiffToFile writes a diff to a file

Types

type DiffHunk

type DiffHunk struct {
	LineStart int
	Content   string
	Added     bool
	Removed   bool
}

DiffHunk represents a chunk of changes

type DiffResult

type DiffResult struct {
	Original string
	Updated  string
	Hunks    []DiffHunk
	Stats    DiffStats
}

DiffResult represents the difference between two files

func CompareFunctions

func CompareFunctions(oldFunc, newFunc string) *DiffResult

CompareFunctions compares two versions of a function and returns a diff

func GenerateDiff

func GenerateDiff(original, updated string) *DiffResult

GenerateDiff creates a diff between two strings

type DiffStats

type DiffStats struct {
	Added   int
	Removed int
	Changed int
}

DiffStats contains statistics about the differences

Jump to

Keyboard shortcuts

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