diff

package
v0.0.0-...-8897d82 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package diff has some helpers for text diffs.

Index

Constants

This section is empty.

Variables

View Source
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

func ContextDiff(expected, actual string) string

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

func ContextDiffColored(expected, actual string) string

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

func JSONDiff(expected, actual []byte) string

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

func TextDiff(expected, actual string) string

TextDiff returns a unified diff of the two passed strings, or "" if they are the same.

func TextDiffColored

func TextDiffColored(expected, actual string) string

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.

Jump to

Keyboard shortcuts

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