difflibgo

module
v0.0.0-...-93685b1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: BSD-3-Clause, MIT

README

difflibgo

difflibgo is a partial port of the Python standard library difflib module , and builds upon the go-difflib module.

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

package main

import (
	"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:

- something
?       -

+ sometihng
?      +

- differentthing
+ anotherthing
  more
- more
- more

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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