diff

package
v0.0.0-...-4fc52a7 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package diff provides line-by-line text comparison functionality.

This package compares two text strings and produces a structured diff showing which lines were added, removed, or unchanged.

Example:

result := diff.Compare(oldText, newText)
for _, line := range result.Lines {
    fmt.Printf("%s: %s\n", line.Type, line.Content)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Line

type Line struct {
	Type    LineType
	OldLine *int
	NewLine *int
	Content string
}

Line represents a single line in a diff

type LineType

type LineType string

LineType represents the type of change in a diff line

const (
	LineTypeUnchanged LineType = "unchanged"
	LineTypeAdded     LineType = "added"
	LineTypeRemoved   LineType = "removed"
)

type Result

type Result struct {
	Lines []Line
}

Result represents the result of comparing two texts

func Compare

func Compare(oldText, newText string) Result

Compare generates a line-by-line diff between two text strings

Jump to

Keyboard shortcuts

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