Categoryezpkg.io/diffz
modulepackage
0.2.2
Repository: https://github.com/ezpkg/diffz.git
Documentation: pkg.go.dev

# README

gopherz

ezpkg.io/diffz

PkgGoDev GitHub License version

Package diffz provides functions for comparing and displaying differences between two strings. It's based on kylelemons/godebug and sergi/go-diff. It provides additional features of ignoring spaces and supporting placeholders.

Installation

go get -u ezpkg.io/[email protected]

Examples

// diff by char
left, right := "onetwo thr33four five", "onetwothree fourfive"
diffs := diffz.IgnoreSpace().DiffByChar(left, right)
fmt.Println(diffz.Format(diffs))

// diff by line
left, right := "one\ntwo\nthree\nfour", "one\ntwo\nfour"
diffs := diffz.IgnoreSpace().DiffByLine(left, right)
fmt.Println(diffz.Format(diffs))

// placeholder is useful for comparing tests with uuid or random values
diffs := diffz.Placeholder().AndIgnoreSpace().DiffByLine(left, right)
left := "id: ████\ncode: AF███\nname: Alice\n"
right := "id: 1234\ncode: AF123\nname: Baby\n"
fmt.Println(diffz.Format(diffs))

Similar Packages

This package is based on these packages:

About ezpkg.io

As I work on various Go projects, I often find myself creating utility functions, extending existing packages, or developing packages to solve specific problems. Moving from one project to another, I usually have to copy or rewrite these solutions. So I created this repository to have all these utilities and packages in one place. Hopefully, you'll find them useful as well.

For more information, see the main repository.

Author

Oliver Nguyen  github

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author