A breaking change have been made to slices package in golang.org/x/exp module (slices.SortFunc in particular).
slices: update to current standard library version
Update x/exp/slices to the current standard library slices package,
while retaining the ability to use it with Go 1.18 through Go 1.20.
Note that this changes some of the sorting functions to use a
comparison function rather than a less function. We don't promise
backward compatibility in x/exp packages. Being compatible with the
Go 1.21 package seems more useful for people not yet using 1.21,
as it will make the transition to 1.21 easier.
Currently there are no problems, but when updating dependent modules the following error occurs:
How to reproduce error
$ cat version.json
{
"version": "v0.10.1"
}
$ go test ./...
? github.com/multiformats/go-multiaddr/multiaddr [no test files]
ok github.com/multiformats/go-multiaddr 0.262s
ok github.com/multiformats/go-multiaddr/net 0.533s
$ go get -u golang.org/x/exp
go: upgraded golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df => v0.0.0-20230725093048-515e97ebf090
$ go test ./...
# github.com/multiformats/go-multiaddr
./multiaddr.go:223:25: type func(a Multiaddr, b Multiaddr) bool of func(a, b Multiaddr) bool {…} does not match inferred type func(a Multiaddr, b Multiaddr) int for func(a E, b E) int
FAIL github.com/multiformats/go-multiaddr [build failed]
FAIL github.com/multiformats/go-multiaddr/net [build failed]
FAIL
A breaking change have been made to
slices
package ingolang.org/x/exp
module (slices.SortFunc
in particular).It is the comparison function, an argument of
slices.SortFunc
, that affects our package.func(a, b E) bool
vsfunc(a, b E) int
.Currently there are no problems, but when updating dependent modules the following error occurs:
How to reproduce error
Proposed fix
https://github.com/multiformats/go-multiaddr/blob/07e6e8da9164552c482f6dd4bc95c7477915b528/multiaddr.go#L223
Note
Even if all other modules are updated, no further changes seem to be necessary at this stage.
Env info