Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/carlmontanari/difflibgo
https://github.com/carlmontanari/difflibgo
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/carlmontanari/difflibgo
- Owner: carlmontanari
- License: other
- Created: 2021-07-18T16:53:54.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-02-27T21:01:41.000Z (11 months ago)
- Last Synced: 2024-06-20T22:43:47.823Z (7 months ago)
- Language: Go
- Size: 17.6 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
difflibgo
=========difflibgo is a partial port of the Python standard library [`difflib` module](https://github.com/python/cpython/blob/main/Lib/difflib.py)
, and builds upon the [`go-difflib` module](https://github.com/pmezard/go-difflib).This implementation includes the `SequenceMatcher` class, as well as the `compare` function of
the `Differ` class. The only goal of this project is to be able to produce a slice of "diff" strings
with appropriate tags to represent additions and deletions as the original Python module does.## A simple Example
```go
package mainimport (
"github.com/carlmontanari/difflibgo/difflibgo"
"fmt"
)func main() {
seqA := []string{"something", "differentthing", "more", "more", "more"}
seqB := []string{"sometihng", "anotherthing", "more"}d := difflibgo.Differ{}
dLines := d.Compare(seqA, seqB)
for _, v := range dLines {
fmt.Printf("%s\n", v)
}
}
```Which outputs:
```bash
- something
? -+ sometihng
? +- differentthing
+ anotherthing
more
- more
- more
```