File: README.md

package info (click to toggle)
golang-github-andreyvit-diff 0.0~git20170406.c7f18ee-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 72 kB
  • sloc: makefile: 2
file content (28 lines) | stat: -rw-r--r-- 660 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# diff

Quick'n'easy string diffing functions for Golang based on [github.com/sergi/go-diff](https://github.com/sergi/go-diff). Mainly for diffing strings in tests.

See [the docs on GoDoc](https://godoc.org/github.com/andreyvit/diff).

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))
        }
    }