diff

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	Path      string
	Operation ChangeOperation
	OldValue  interface{}
	NewValue  interface{}
	Context   []string
}

type ChangeOperation

type ChangeOperation string
const (
	ChangeOpAdd     ChangeOperation = "add"
	ChangeOpRemove  ChangeOperation = "remove"
	ChangeOpReplace ChangeOperation = "replace"
)

type DiffFormat

type DiffFormat string
const (
	DiffFormatUnified    DiffFormat = "unified"
	DiffFormatSideBySide DiffFormat = "side-by-side"
	DiffFormatJSONPatch  DiffFormat = "json-patch"
	DiffFormatSemantic   DiffFormat = "semantic"
)

type DiffOptions

type DiffOptions struct {
	Format         DiffFormat
	IgnoreMetadata bool
	IgnoreOrder    bool
	ContextLines   int
	Colorize       bool
	Semantic       bool
}

type DiffResult

type DiffResult struct {
	HasChanges bool
	Changes    []Change
	Summary    DiffSummary
	Patch      string
	LeftLabel  string
	RightLabel string
}

type DiffSummary

type DiffSummary struct {
	Added    int
	Removed  int
	Modified int
	Impact   ImpactLevel
}

type Differ

type Differ struct {
	// contains filtered or unexported fields
}

func NewDiffer

func NewDiffer(opts DiffOptions) *Differ

func (*Differ) Compare

func (d *Differ) Compare(left, right interface{}, leftLabel, rightLabel string) (*DiffResult, error)

func (*Differ) CompareData

func (d *Differ) CompareData(leftData, rightData []byte, leftLabel, rightLabel string) (*DiffResult, error)

CompareData compares two already-read YAML or JSON documents. Callers that resolve their own inputs (e.g. stdin for `-f -`) use it instead of CompareFiles; the labels name each side in the output.

func (*Differ) CompareFiles

func (d *Differ) CompareFiles(leftPath, rightPath string) (*DiffResult, error)

func (*Differ) WithVFS

func (d *Differ) WithVFS(env vfs.Env) *Differ

WithVFS sets the filesystem and stdin CompareFiles reads from. The zero Env keeps the process's.

type Formatter

type Formatter interface {
	Format(result *DiffResult) (string, error)
}

type ImpactLevel

type ImpactLevel string
const (
	ImpactLow      ImpactLevel = "low"
	ImpactMedium   ImpactLevel = "medium"
	ImpactHigh     ImpactLevel = "high"
	ImpactCritical ImpactLevel = "critical"
)

type JSONPatchFormatter

type JSONPatchFormatter struct{}

func (*JSONPatchFormatter) Format

func (f *JSONPatchFormatter) Format(result *DiffResult) (string, error)

type SemanticFormatter

type SemanticFormatter struct{}

func (*SemanticFormatter) Format

func (f *SemanticFormatter) Format(result *DiffResult) (string, error)

type SideBySideFormatter

type SideBySideFormatter struct {
	// contains filtered or unexported fields
}

func (*SideBySideFormatter) Format

func (f *SideBySideFormatter) Format(result *DiffResult) (string, error)

type UnifiedFormatter

type UnifiedFormatter struct {
	// contains filtered or unexported fields
}

func (*UnifiedFormatter) Format

func (f *UnifiedFormatter) Format(result *DiffResult) (string, error)

Jump to

Keyboard shortcuts

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