Created
September 6, 2019 20:22
-
-
Save michaljemala/6059f1937dde8e308e4fd364baa2ee98 to your computer and use it in GitHub Desktop.
Revisions
-
michaljemala created this gist
Sep 6, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ package main import ( "fmt" "hova.dzia.poliev.ka/slice" ) func main() { x := slice.Unordered{1, 2, 3} y := slice.Unordered{3, 2, 1} fmt.Println(slice.Equal(x, y)) fmt.Println(slice.Match(x, y)) } -- go.mod -- module hova.dzia.poliev.ka -- slice/slice.go -- package slice import ( "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/assert" ) type Unordered []interface{} func Equal(x, y interface{}) bool { return cmp.Equal(x, y) } func Match(x, y interface{}) bool { return cmp.Equal(x, y, cmp.Comparer(func(x, y Unordered) bool { return assert.ElementsMatch(nil, x, y) })) }