diff

package module
v0.0.0-...-c7f18ee Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2017 License: MIT Imports: 3 Imported by: 55

README

diff

Quick'n'easy string diffing functions for Golang based on github.com/sergi/go-diff. Mainly for diffing strings in tests.

See the docs on GoDoc.

Get it:

go get -u github.com/andreyvit/diff

Example:

import (
    "strings"
    "testing"
    "github.com/andreyvit/diff"
)

const expected = `
...
`

func TestFoo(t *testing.T) {
    actual := Foo(...)
    if a, e := strings.TrimSpace(actual), strings.TrimSpace(expected); a != e {
        t.Errorf("Result not as expected:\n%v", diff.LineDiff(e, a))
    }
}

Documentation

Overview

diff provides quick and easy string diffing functions based on github.com/sergi/go-diff, mainly for diffing strings in tests

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CharacterDiff

func CharacterDiff(a, b string) string

CharacterDiff returns an inline diff between the two strings, using (++added++) and (~~deleted~~) markup.

func LineDiff

func LineDiff(a, b string) string

LineDiff returns a normal linewise diff between the two given strings.

func LineDiffAsLines

func LineDiffAsLines(a, b string) []string

LineDiffAsLines returns the lines of a linewise diff between the two given strings.

func TrimLines

func TrimLines(input []string) []string

TrimLines applies TrimSpace to each string in the given array.

func TrimLinesInString

func TrimLinesInString(input string) string

TrimLinesInString applies TrimSpace to each line in the given string, and returns the new trimmed string. Empty lines are not removed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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