Categorygithub.com/sanmin33/diff
modulepackage
0.0.0-20200207032725-19da944e7071
Repository: https://github.com/sanmin33/diff.git
Documentation: pkg.go.dev

# 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/sanmin33/diff  

Example:

    import (
        "strings"
        "testing"
        "github.com/sanmin33/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))
        }
    }

# Functions

CharacterDiff returns an inline diff between the two strings, using (++added++) and (~~deleted~~) markup.
LineDiff returns a normal linewise diff between the two given strings.
LineDiffAsLines returns the lines of a linewise diff between the two given strings.
TrimLines applies TrimSpace to each string in the given array.
TrimLinesInString applies TrimSpace to each line in the given string, and returns the new trimmed string.