|
1 |
| -# go-diff [](https://godoc.org/github.com/sergi/go-diff) [](https://travis-ci.org/sergi/go-diff) [](https://coveralls.io/r/sergi/go-diff?branch=master) |
| 1 | +# go-diff [](https://godoc.org/github.com/sergi/go-diff/diffmatchpatch) [](https://travis-ci.org/sergi/go-diff) [](https://coveralls.io/r/sergi/go-diff?branch=master) |
2 | 2 |
|
3 |
| -Go-diff is a Go language port of Neil Fraser's google-diff-match-patch code. His original code is available at: |
| 3 | +go-diff offers algorithms to perform operations required for synchronizing plain text: |
4 | 4 |
|
5 |
| -http://code.google.com/p/google-diff-match-patch/ |
| 5 | +- Compare two texts and return their differences. |
| 6 | +- Perform fuzzy matching of text. |
| 7 | +- Apply patches onto text. |
6 | 8 |
|
7 |
| -## Current state for this Go library |
| 9 | +## Installation |
8 | 10 |
|
9 |
| -In order to run the tests: |
| 11 | +```bash |
| 12 | +go get -u github.com/sergi/go-diff/... |
| 13 | +``` |
10 | 14 |
|
11 |
| -`cd diff && go test` |
| 15 | +## Usage |
12 | 16 |
|
13 |
| -## Installation |
| 17 | +The following example compares two texts and writes out the differences to standard output. |
| 18 | + |
| 19 | +```go |
| 20 | +package main |
| 21 | + |
| 22 | +import ( |
| 23 | + "fmt" |
| 24 | + |
| 25 | + "github.com/sergi/go-diff/diffmatchpatch" |
| 26 | +) |
| 27 | + |
| 28 | +const ( |
| 29 | + text1 = "Lorem ipsum dolor." |
| 30 | + text2 = "Lorem dolor sit amet." |
| 31 | +) |
| 32 | + |
| 33 | +func main() { |
| 34 | + dmp := diffmatchpatch.New() |
| 35 | + |
| 36 | + diffs := dmp.DiffMain(text1, text2, false) |
| 37 | + |
| 38 | + fmt.Println(dmp.DiffPrettyText(diffs)) |
| 39 | +} |
| 40 | +``` |
| 41 | + |
| 42 | +## Found a bug or are you missing a feature in go-diff? |
| 43 | + |
| 44 | +Please make sure to have the latest version of go-diff. If the problem still persists go through the [open issues](https://github.com/sergi/go-diff/issues) in the tracker first. If you cannot find your request just open up a [new issue](https://github.com/sergi/go-diff/issues/new). |
| 45 | + |
| 46 | +## How to contribute? |
| 47 | + |
| 48 | +You want to contribute to go-diff? GREAT! If you are here because of a bug you want to fix or a feature you want to add, you can just read on. Otherwise we have a list of [open issues in the tracker](https://github.com/sergi/go-diff/issues). Just choose something you think you can work on and discuss your plans in the issue by commenting on it. |
| 49 | + |
| 50 | +Please make sure that every behavioral change is accompanied by test cases. Additionally, every contribution must pass the `lint` and `test` Makefile targets which can be run using the following commands in the repository root directory. |
| 51 | + |
| 52 | +```bash |
| 53 | +make lint |
| 54 | +make test |
| 55 | +``` |
| 56 | + |
| 57 | +After your contribution passes these commands, [create a PR](https://help.github.com/articles/creating-a-pull-request/) and we will review your contribution. |
| 58 | + |
| 59 | +## Origins |
14 | 60 |
|
15 |
| - go get github.com/sergi/go-diff/diffmatchpatch |
| 61 | +go-diff is a Go language port of Neil Fraser's google-diff-match-patch code. His original code is available at [http://code.google.com/p/google-diff-match-patch/](http://code.google.com/p/google-diff-match-patch/). |
16 | 62 |
|
17 | 63 | ## Copyright and License
|
18 | 64 |
|
19 |
| -The original Google Diff, Match and Patch Library is licensed under |
20 |
| -the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0). |
21 |
| -The full terms of that license are included here in the |
22 |
| -`APACHE-LICENSE-2.0` file. |
| 65 | +The original Google Diff, Match and Patch Library is licensed under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0). The full terms of that license are included here in the [APACHE-LICENSE-2.0](/APACHE-LICENSE-2.0) file. |
23 | 66 |
|
24 | 67 | Diff, Match and Patch Library
|
25 | 68 |
|
26 |
| - Written by Neil Fraser |
27 |
| - Copyright (c) 2006 Google Inc. |
28 |
| - <http://code.google.com/p/google-diff-match-patch/> |
| 69 | +> Written by Neil Fraser |
| 70 | +> Copyright (c) 2006 Google Inc. |
| 71 | +> <http://code.google.com/p/google-diff-match-patch/> |
29 | 72 |
|
30 |
| -This Go version of Diff, Match and Patch Library is licensed under |
31 |
| -the [MIT License](http://www.opensource.org/licenses/MIT) (a.k.a. |
32 |
| -the Expat License) which is included here in the `LICENSE` file. |
| 73 | +This Go version of Diff, Match and Patch Library is licensed under the [MIT License](http://www.opensource.org/licenses/MIT) (a.k.a. the Expat License) which is included here in the [LICENSE](/LICENSE) file. |
33 | 74 |
|
34 | 75 | Go version of Diff, Match and Patch Library
|
35 | 76 |
|
36 |
| - Copyright (c) 2012 Sergi Mansilla <[email protected]> |
37 |
| - <https://github.com/sergi/go-diff> |
| 77 | +> Copyright (c) 2012-2016 The go-diff authors. All rights reserved. |
| 78 | +> <https://github.com/sergi/go-diff> |
38 | 79 |
|
39 | 80 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
40 | 81 |
|
|
0 commit comments