Package diff implements methods for comparing objects and producing edit scripts. The motivation for creating the package was to be able to use the diff output format in tests where the output of go-cmp wasn’t suitable. Comparing sequences of lengths N and M whose shortest edit script has D operations takes O((N+M)D) time and O(N+M) space. See the package documentation for more information.
$ go get mibk.dev/diff
v0.1.0 shipped without a go.mod
and was imported as github.com/mibk/diff.
The module is now mibk.dev/diff, so go get -u refuses the upgrade
and restores v0.1.0, reporting a path mismatch.
To move over:
-
Move the imports over, from the root of your module:
$ go run mibk.dev/mvimport@latest github.com/mibk/diff mibk.dev/diffThat rewrites every import in the module, swaps the
requirefor the new path at its latest version, prunes the oldgo.sumlines, and gofmts what it touched, so there is nothing left forgo mod tidyto do. It needs Go 1.25 or newer. -
Rewrite the calls to the deprecated
IntSlices,Float64SlicesandStringSlices:$ go fix -inline ./...The wrappers carry inline directives, and
-inlineis what limits the run to those. Needs Go 1.26 or newer.Plain
go fix ./...also does the job, but it runs every analyzer it has --min/max,strings.Builder, range-over-int and a dozen more -- so it will modernize code that has nothing to do with this migration.
To take the new version without touching the import paths yet, map the old path onto the new module instead:
replace github.com/mibk/diff => mibk.dev/diff v0.2.0
Where a pair of sequences has several shortest edit scripts, v0.2.0 may report a different one than v0.1.0 did. Both are equally minimal, but tests pinned to the exact output can need updating.