Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode

This commit is contained in:
wangchuxiao 2023-03-08 11:46:03 +08:00
commit 107f4c950b
3 changed files with 18 additions and 1 deletions

View File

@ -8,9 +8,13 @@ import (
"path/filepath"
"runtime"
_ "embed"
"gopkg.in/yaml.v3"
)
//go:embed version
var Version string
var (
_, b, _, _ = runtime.Caller(0)
// Root folder of this project

View File

@ -0,0 +1 @@
v3.0.0

View File

@ -34,7 +34,19 @@ func SliceSubAny[E comparable, T any](a []E, b []T, fn func(t T) E) []E {
// SliceAnySub a中存在,b中不存在 (a-b) fn 返回的是uuid
func SliceAnySub[E any, T comparable](a, b []E, fn func(t E) T) []E {
panic("todo")
m := make(map[T]E)
for i := 0; i < len(b); i++ {
v := b[i]
m[fn(v)] = v
}
var es []E
for i := 0; i < len(a); i++ {
v := a[i]
if _, ok := m[fn(v)]; !ok {
es = append(es, v)
}
}
return es
}
// DistinctAny 去重