differ

package
v1.1.0-rc4 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MatchNone   = MatchResult(0) // 匹配失败
	MatchPrefix = MatchResult(1) // 前缀匹配
	MatchFull   = MatchResult(2) // 全部匹配
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AbsentValue

type AbsentValue string

type Comparator

type Comparator func(a, b interface{}) bool

Comparator 值比较器。

type DiffItem

type DiffItem struct {
	A interface{}
	B interface{}
}

type DiffResult

type DiffResult struct {
	Differs map[string]DiffItem
	Ignores map[string]DiffItem
	Equals  map[string]DiffItem
}

func DiffValue

func DiffValue(a, b interface{}) *DiffResult

DiffValue 比较 a,b 两个任意值,返回它们异同之处。

type JsonDiffItem

type JsonDiffItem struct {
	A string
	B string
}

type JsonDiffResult

type JsonDiffResult struct {
	Differs map[string]JsonDiffItem
	Ignores map[string]JsonDiffItem
	Equals  map[string]JsonDiffItem
}

func DiffJSON

func DiffJSON(a, b string, configs ...*JsonPathConfig) *JsonDiffResult

DiffJSON 比较 a,b 两个 JSON 字符串,返回它们异同之处。

type JsonDiffer

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

JsonDiffer JSON 比较器。

func NewJsonDiffer

func NewJsonDiffer() *JsonDiffer

NewJsonDiffer 创建新的 JSON 比较器。

func (*JsonDiffer) Diff

func (d *JsonDiffer) Diff(a, b string) *JsonDiffResult

Diff 比较 a,b 两个 JSON 字符串,返回它们异同之处。

func (*JsonDiffer) Path

func (d *JsonDiffer) Path(path JsonPath) *JsonPathConfig

Path 获取路径的配置。

type JsonPath

type JsonPath interface {
	Match(path string) MatchResult
}

JsonPath 使用 JSON 路径表达式定义的路径。

func ToJsonPath

func ToJsonPath(expr string) JsonPath

ToJsonPath 解析使用 JSON 路径表达式定义的路径。

type JsonPathConfig

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

func ConfigJsonPath

func ConfigJsonPath(path JsonPath) *JsonPathConfig

func (*JsonPathConfig) IgnoreArrayOrder

func (c *JsonPathConfig) IgnoreArrayOrder() *JsonPathConfig

func (*JsonPathConfig) IgnoreExtraItems

func (c *JsonPathConfig) IgnoreExtraItems() *JsonPathConfig

func (*JsonPathConfig) IgnorePath

func (c *JsonPathConfig) IgnorePath() *JsonPathConfig

func (*JsonPathConfig) IgnoreValue

func (c *JsonPathConfig) IgnoreValue() *JsonPathConfig

func (*JsonPathConfig) SetComparator

func (c *JsonPathConfig) SetComparator(comparator Comparator) *JsonPathConfig

func (*JsonPathConfig) TreatNullAsAbsent

func (c *JsonPathConfig) TreatNullAsAbsent() *JsonPathConfig

func (*JsonPathConfig) UnquoteExpand

func (c *JsonPathConfig) UnquoteExpand() *JsonPathConfig

type MatchResult

type MatchResult int

MatchResult 路径匹配结果。

type Strategy

type Strategy int

Strategy 比较策略。

type UnquoteString

type UnquoteString string

type ValueDiffer

type ValueDiffer struct {
}

ValueDiffer 值比较器。

func NewValueDiffer

func NewValueDiffer() *ValueDiffer

NewValueDiffer 创建新的值比较器。

func (*ValueDiffer) Diff

func (d *ValueDiffer) Diff(a, b interface{}) *DiffResult

Diff 比较 a,b 两个任意值,返回它们异同之处。

type XmlDiffItem

type XmlDiffItem struct {
	A interface{}
	B interface{}
}

type XmlDiffResult

type XmlDiffResult struct {
	Differs map[string]XmlDiffItem
	Ignores map[string]XmlDiffItem
	Equals  map[string]XmlDiffItem
}

func DiffXML

func DiffXML(a, b string) *XmlDiffResult

DiffXML 比较 a,b 两个 XML 字符串,返回它们异同之处。

type XmlDiffer

type XmlDiffer struct {
}

XmlDiffer XML 比较器。

func NewXmlDiffer

func NewXmlDiffer() *XmlDiffer

NewXmlDiffer 创建新的 XML 比较器。

func (*XmlDiffer) Diff

func (d *XmlDiffer) Diff(a, b string) *XmlDiffResult

Diff 比较 a,b 两个 XML 字符串,返回它们异同之处。

Jump to

Keyboard shortcuts

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