SkillAgentSearch skills...

Go.diff

A Go implementation of "An O(NP) Sequence Comparison Algorithm"

Install / Use

/learn @hattya/Go.diff
About this skill

Quality Score

0/100

Supported Platforms

Universal

Tags

README

go.diff

A Go implementation of "An O(NP) Sequence Comparison Algorithm".

pkg.go.dev GitHub Actions Appveyor Codecov

Installation

$ go get github.com/hattya/go.diff

Usage

package main

import (
	"fmt"

	"github.com/hattya/go.diff"
)

func main() {
	a := []rune("acbdeacbed")
	b := []rune("acebdabbabed")
	cl := diff.Runes(a, b)
	i := 0
	for _, c := range cl {
		for ; i < c.A; i++ {
			fmt.Printf("  %c\n", a[i])
		}
		for j := c.A; j < c.A+c.Del; j++ {
			fmt.Printf("- %c\n", a[j])
		}
		for j := c.B; j < c.B+c.Ins; j++ {
			fmt.Printf("+ %c\n", b[j])
		}
		i += c.Del
	}
	for ; i < len(a); i++ {
		fmt.Printf("  %c\n", a[i])
	}
}

License

go.diff is distributed under the terms of the MIT License.

References

S. Wu, U. Manber, G. Myers, and W. Miller, "An O(NP) Sequence Comparison Algorithm" August 1989

View on GitHub
GitHub Stars16
CategoryDevelopment
Updated9d ago
Forks0

Languages

Go

Security Score

95/100

Audited on Mar 27, 2026

No findings