test-errcode
parent
c1af64854c
commit
c3f6a0fa15
@ -1,13 +0,0 @@
|
|||||||
package utilsv2
|
|
||||||
|
|
||||||
import "Open_IM/pkg/common/db/table"
|
|
||||||
|
|
||||||
func demo() {
|
|
||||||
|
|
||||||
groups := []*table.GroupModel{}
|
|
||||||
|
|
||||||
groups = DuplicateRemovalAny(groups, func(t *table.GroupModel) string {
|
|
||||||
return t.GroupID
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,44 @@
|
|||||||
|
package utilsv2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestDistinct(t *testing.T) {
|
||||||
|
arr := []int{1, 1, 1, 4, 4, 5, 2, 3, 3, 3, 6}
|
||||||
|
fmt.Println(Distinct(arr))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDeleteAt(t *testing.T) {
|
||||||
|
arr := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||||
|
fmt.Println(DeleteAt(arr, 0, 1, -1, -2))
|
||||||
|
fmt.Println(DeleteAt(arr))
|
||||||
|
fmt.Println(DeleteAt(arr, 1))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSliceToMap(t *testing.T) {
|
||||||
|
type Item struct {
|
||||||
|
ID string
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
list := []Item{
|
||||||
|
{ID: "111", Name: "111"},
|
||||||
|
{ID: "222", Name: "222"},
|
||||||
|
{ID: "333", Name: "333"},
|
||||||
|
}
|
||||||
|
|
||||||
|
m := SliceToMap(list, func(t Item) string {
|
||||||
|
return t.ID
|
||||||
|
})
|
||||||
|
|
||||||
|
fmt.Printf("%+v\n", m)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIndexOf(t *testing.T) {
|
||||||
|
arr := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||||
|
|
||||||
|
fmt.Println(IndexOf(arr, 3))
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue