Documentation ¶
Overview ¶
Package diff has some helpers for text diffs.
Index ¶
- Variables
- func Cmp(expected, actual interface{}) string
- func ContextDiff(expected, actual string) string
- func ContextDiffColored(expected, actual string) string
- func Diff(expected, actual interface{}) string
- func JSONDiff(expected, actual []byte) string
- func MarshalJSONDiff(expected, actual interface{}) string
- func TextDiff(expected, actual string) string
- func TextDiffColored(expected, actual string) string
Constants ¶
This section is empty.
Variables ¶
var Context = 2
Context indicates the number of lines of context to add.
Functions ¶
func Cmp ¶
func Cmp(expected, actual interface{}) string
Cmp returns both the actual and the expected value neatly aligned.
func ContextDiff ¶
ContextDiff returns a "context diff" of the two passed strings, or "" if they are the same.
This usually works better than a unified diff if the strings are long.
func ContextDiffColored ¶
ContextDiffColored returns a "context diff" of the two passed strings, or "" if they are the same. This function also colors the output
This usually works better than a unified diff if the strings are long.
func Diff ¶
func Diff(expected, actual interface{}) string
Diff returns a unified diff of the two passed arguments, or "" if they are the same.
func JSONDiff ¶
JSONDiff does a diff of two JSON strings. It first unmarshals the two JSON objects into interface{}s, then does a reflect.DeepEqual(). If there is a difference, it then re-marshals the objects into pretty JSON and returns a diff. Errors panic.
func MarshalJSONDiff ¶
func MarshalJSONDiff(expected, actual interface{}) string
MarshalJSONDiff works the same as JSONDiff, but first marshals the two objects to JSON.
func TextDiff ¶
TextDiff returns a unified diff of the two passed strings, or "" if they are the same.
func TextDiffColored ¶
TextDiffColored returns a unified diff of the two passed strings, or "" if they are the same. This function also colors the output
Types ¶
This section is empty.