diff

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package diff is a utility to create visual diffs for key/value changes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(changes KVChanges, pretty bool) string

Diff returns a visual representation of the changes.

Types

type Add

type Add struct {
	Pair
}

Add is an addition change.

func NewAdd

func NewAdd(key, val string) *Add

NewAdd create Add.

func (Add) Pretty

func (c Add) Pretty() string

Pretty returns colorful string representation of the addition.

func (Add) String

func (c Add) String() string

String returns string representation of the addition.

type KVChange

type KVChange interface {
	Key() string
	Val() string
	String() string
	Pretty() string
}

KVChange represent one change in key/value storage.

type KVChanges

type KVChanges []KVChange

KVChanges is a collection of key/value changes.

func (KVChanges) Len

func (c KVChanges) Len() int

func (KVChanges) Less

func (c KVChanges) Less(i, j int) bool

func (KVChanges) Swap

func (c KVChanges) Swap(i, j int)

type Pair

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

Pair is a single key/value pair.

func (Pair) Key

func (p Pair) Key() string

Key returns the key of the Pair.

func (Pair) Val

func (p Pair) Val() string

Val returns the value of the Pair.

type Remove

type Remove struct {
	Pair
}

Remove is an removal change.

func NewRemove

func NewRemove(key, val string) *Remove

NewRemove creates Remove.

func (Remove) Pretty

func (c Remove) Pretty() string

Pretty returns colorful string representation of the removal.

func (Remove) String

func (c Remove) String() string

String returns string representation of the removal.

type Update

type Update struct {
	Pair
	// contains filtered or unexported fields
}

Update is an update change.

func NewUpdate

func NewUpdate(key, val, newVal string) *Update

NewUpdate creates update.

func (Update) NewVal

func (c Update) NewVal() string

NewVal return the new value of the update change.

func (Update) Pretty

func (c Update) Pretty() string

Pretty returns colorful string representation of the update.

func (Update) String

func (c Update) String() string

String returns string representation of the update.

Jump to

Keyboard shortcuts

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