diffr

package
v0.0.0-...-1a60bb0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoDiff = errors.New("no diff found")

Functions

func Diff

func Diff(ctx context.Context, file1, file2 File, opts Options) error

Diff compares two files recursively through archives If no diff is found, ErrNoDiff is returned

Types

type DiffNode

type DiffNode struct {
	Source1     string     `json:"source1"`
	Source2     string     `json:"source2"`
	UnifiedDiff *string    `json:"unified_diff,omitempty"`
	Comments    []string   `json:"comments,omitempty"`
	Details     []DiffNode `json:"details,omitempty"` // Recursive nodes
}

DiffNode represents a single node in the difference tree. Intended for approximate compatibility with diffoscope's JSON schema.

func (*DiffNode) Status

func (n *DiffNode) Status() NodeStatus

Status determines the status of a node from its comments.

func (DiffNode) String

func (node DiffNode) String() string

type File

type File struct {
	Name   string
	Reader io.ReadSeeker
}

File represents an input file with its name and content reader

type FileType

type FileType int

FileType defines the identified file type

const (
	// TypeBinary represents an unidentified binary file
	TypeBinary FileType = iota
	// TypeText represents an unidentified text file
	TypeText
	// TypeGzip represents a Gzip compressed file
	TypeGzip
	// TypeZip represents a Zip archive
	TypeZip
	// TypeTar represents a Tar archive (specifically ustar)
	TypeTar
)

func DetectFileType

func DetectFileType(r io.ReadSeeker) (FileType, error)

DetectFileType checks the magic bytes of a reader to identify its type.

func (FileType) String

func (ft FileType) String() string

type NodeStatus

type NodeStatus int

NodeStatus indicates whether a node represents a file only in first archive, only in second archive, or in both.

const (
	StatusBoth NodeStatus = iota
	StatusOnlyFirst
	StatusOnlySecond
)

type Options

type Options struct {
	Output     io.Writer // If non-nil, write formatted text diff here
	OutputJSON io.Writer // If non-nil, write JSON diff here
	OutputNode *DiffNode // If non-nil, populated with the diff tree structure
	MaxDepth   int       // Maximum archive nesting depth to recurse into (0 = unlimited)
}

Options for the Diff function

Jump to

Keyboard shortcuts

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