config

package
v0.0.0-...-b13b7c6 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package config provides shared configuration mechanisms for packages this module.

This package is an implementation detail, the configuration surface for users is provided via diff.Option.

Index

Constants

This section is empty.

Variables

View Source
var Default = Config{
	Context:                 3,
	Mode:                    ModeDefault,
	IndentHeuristic:         false,
	ForceAnchoringHeuristic: false,
}

Default is the default configuration.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Context is the number of matches to include as a prefix and postfix for hunks returned.
	Context int

	// Diff algorithm mode.
	Mode Mode

	// If set, textdiff will apply ident heuristics.
	IndentHeuristic bool

	// If set, internal/myers will always use the anchoring heuristic. This configuration is not
	// exposed via an option API, it's main use is for testing.
	ForceAnchoringHeuristic bool
}

Config collects all configurable parameters for comparison functions in this module.

func FromOptions

func FromOptions(opts []Option, allowed Flag) Config

FromOptions creates a configuration from a set of options.

type Flag

type Flag int

Flag describes a single config entry. This is used to detect if configurations are being set that are not

const (
	Context Flag = 1 << iota
	Optimal
	Fast
	IndentHeuristic
)

type Mode

type Mode int

Mode describes the mode of the diff algorithm.

const (
	// Limit the cost for large inputs with many differences by applying heuristics that reduce the
	// time complexity at the cost of non-minimal diffs.
	ModeDefault Mode = iota

	// Find a minimal diff irrespective of the cost.
	ModeOptimal

	// Find a diff as fast as possible.
	ModeFast
)

type Option

type Option func(*Config) Flag

Option is the mechanism used to expose the configuration to users.

Jump to

Keyboard shortcuts

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