Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultDiffOptions = DiffOptions{ IgnoreSeqOrder: false, }
View Source
var DefaultOutputOptions = FormatOptions{ Plain: false, Silent: false, Metadata: false, }
Functions ¶
This section is empty.
Types ¶
type Diff ¶
type Diff struct {
// contains filtered or unexported fields
}
func (*Diff) Format ¶
func (d *Diff) Format(opts FormatOptions) string
type DiffOptions ¶
type DiffOptions struct { // IgnoreSeqOrder, when true, treats arrays as equal regardless of the order of their items. // For instance, the arrays [1, 2] and [2, 1] will be considered equal. IgnoreSeqOrder bool }
DiffOptions specifies options for customizing the behavior of the comparison.
type DocDiffs ¶
type DocDiffs []*Diff
func (DocDiffs) Format ¶
func (d DocDiffs) Format(opts FormatOptions) string
type FileDiffs ¶
type FileDiffs []DocDiffs
func Compare ¶
Compare compares two yaml files provided as bytes and returns the differences as FileDiffs, or an error if there's an issue parsing the files.
Example ¶
left := []byte(` name: Alice city: New York items: - one - two `) right := []byte(` name: Bob value: 990 items: - one - three `) diffs, err := Compare(left, right, false, DefaultDiffOptions) if err != nil { panic(err) } output := diffs.Format(FormatOptions{ Plain: true, Silent: false, Metadata: false, }) fmt.Println(output)
Output: ~ name: Alice -> Bob - city: New York + value: 990 ~ items[1]: two -> three
func CompareAst ¶
CompareAst compares two yaml documents represented as ASTs and returns the differences as FileDiffs.
func CompareFile ¶
func CompareFile(leftFile string, rightFile string, comments bool, opts DiffOptions) (FileDiffs, error)
CompareFile compares two yaml files specified by file paths and returns the differences as FileDiffs, or an error if there's an issue reading or parsing the files.
func (FileDiffs) Format ¶
func (d FileDiffs) Format(opts FormatOptions) string
type FormatOptions ¶
type FormatOptions struct { // Plain disables colored output when set to true. Plain bool // Silent suppresses the display of values when set to true. Silent bool // Metadata includes additional metadata, such as line numbers or types, when set to true. Metadata bool }
FormatOptions specifies options for formatting the output of the comparison.
Click to show internal directories.
Click to hide internal directories.