fix: fix all lint warning in pkg (#1263)
* fix:fix lint errors in internal * fix:fix lint error in interal/tools * fix: fix lint errros in pkg/statics * fix: fix lint erros in pkg/authverify,pkg/rpcclien * fix: fix lint erros in pkg/common/cmd * fix: fix lint erros in pkg/common/config,convert * fix: fix lint erros in pkg/common/db/cache * fix: fix lint errors in pkg/common/db/controller * fix:fix lint errors in pkg/common/db/relation and pkg/common/db/localcache * fix: fix rest lint errors in pkg/common/db * fix: fix rest lint errors in pkg * fix:set back go.work to use go 1.19
This commit is contained in:
Vendored
+40
-19
@@ -109,6 +109,7 @@ func NewGroupCacheRedis(
|
||||
opts rockscache.Options,
|
||||
) GroupCache {
|
||||
rcClient := rockscache.NewClient(rdb, opts)
|
||||
|
||||
return &GroupCacheRedis{
|
||||
rcClient: rcClient, expireTime: groupExpireTime,
|
||||
groupDB: groupDB, groupMemberDB: groupMemberDB, groupRequestDB: groupRequestDB,
|
||||
@@ -169,6 +170,7 @@ func (g *GroupCacheRedis) GetGroupIndex(group *relationtb.GroupModel, keys []str
|
||||
return i, nil
|
||||
}
|
||||
}
|
||||
|
||||
return 0, errIndex
|
||||
}
|
||||
|
||||
@@ -179,6 +181,7 @@ func (g *GroupCacheRedis) GetGroupMemberIndex(groupMember *relationtb.GroupMembe
|
||||
return i, nil
|
||||
}
|
||||
}
|
||||
|
||||
return 0, errIndex
|
||||
}
|
||||
|
||||
@@ -187,10 +190,11 @@ func (g *GroupCacheRedis) GetGroupsInfo(
|
||||
ctx context.Context,
|
||||
groupIDs []string,
|
||||
) (groups []*relationtb.GroupModel, err error) {
|
||||
var keys []string
|
||||
keys := make([]string, 0, len(groupIDs))
|
||||
for _, group := range groupIDs {
|
||||
keys = append(keys, g.getGroupInfoKey(group))
|
||||
}
|
||||
|
||||
return batchGetCache(
|
||||
ctx,
|
||||
g.rcClient,
|
||||
@@ -216,13 +220,14 @@ func (g *GroupCacheRedis) GetGroupInfo(ctx context.Context, groupID string) (gro
|
||||
}
|
||||
|
||||
func (g *GroupCacheRedis) DelGroupsInfo(groupIDs ...string) GroupCache {
|
||||
new := g.NewCache()
|
||||
var keys []string
|
||||
newGroupCache := g.NewCache()
|
||||
keys := make([]string, 0, len(groupIDs))
|
||||
for _, groupID := range groupIDs {
|
||||
keys = append(keys, g.getGroupInfoKey(groupID))
|
||||
}
|
||||
new.AddKeys(keys...)
|
||||
return new
|
||||
newGroupCache.AddKeys(keys...)
|
||||
|
||||
return newGroupCache
|
||||
}
|
||||
|
||||
func (g *GroupCacheRedis) GetJoinedSuperGroupIDs(
|
||||
@@ -239,6 +244,7 @@ func (g *GroupCacheRedis) GetJoinedSuperGroupIDs(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return userGroup.GroupIDs, nil
|
||||
},
|
||||
)
|
||||
@@ -248,10 +254,11 @@ func (g *GroupCacheRedis) GetSuperGroupMemberIDs(
|
||||
ctx context.Context,
|
||||
groupIDs ...string,
|
||||
) (models []*unrelationtb.SuperGroupModel, err error) {
|
||||
var keys []string
|
||||
keys := make([]string, 0, len(groupIDs))
|
||||
for _, group := range groupIDs {
|
||||
keys = append(keys, g.getSuperGroupMemberIDsKey(group))
|
||||
}
|
||||
|
||||
return batchGetCache(
|
||||
ctx,
|
||||
g.rcClient,
|
||||
@@ -263,6 +270,7 @@ func (g *GroupCacheRedis) GetSuperGroupMemberIDs(
|
||||
return i, nil
|
||||
}
|
||||
}
|
||||
|
||||
return 0, errIndex
|
||||
},
|
||||
func(ctx context.Context) ([]*unrelationtb.SuperGroupModel, error) {
|
||||
@@ -273,23 +281,25 @@ func (g *GroupCacheRedis) GetSuperGroupMemberIDs(
|
||||
|
||||
// userJoinSuperGroup.
|
||||
func (g *GroupCacheRedis) DelJoinedSuperGroupIDs(userIDs ...string) GroupCache {
|
||||
new := g.NewCache()
|
||||
var keys []string
|
||||
newGroupCache := g.NewCache()
|
||||
keys := make([]string, 0, len(userIDs))
|
||||
for _, userID := range userIDs {
|
||||
keys = append(keys, g.getJoinedSuperGroupsIDKey(userID))
|
||||
}
|
||||
new.AddKeys(keys...)
|
||||
return new
|
||||
newGroupCache.AddKeys(keys...)
|
||||
|
||||
return newGroupCache
|
||||
}
|
||||
|
||||
func (g *GroupCacheRedis) DelSuperGroupMemberIDs(groupIDs ...string) GroupCache {
|
||||
new := g.NewCache()
|
||||
var keys []string
|
||||
newGroupCache := g.NewCache()
|
||||
keys := make([]string, 0, len(groupIDs))
|
||||
for _, groupID := range groupIDs {
|
||||
keys = append(keys, g.getSuperGroupMemberIDsKey(groupID))
|
||||
}
|
||||
new.AddKeys(keys...)
|
||||
return new
|
||||
newGroupCache.AddKeys(keys...)
|
||||
|
||||
return newGroupCache
|
||||
}
|
||||
|
||||
// groupMembersHash.
|
||||
@@ -368,12 +378,14 @@ func (g *GroupCacheRedis) GetGroupMemberHashMap(
|
||||
}
|
||||
res[groupID] = &relationtb.GroupSimpleUserID{Hash: hash, MemberNum: uint32(num)}
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (g *GroupCacheRedis) DelGroupMembersHash(groupID string) GroupCache {
|
||||
cache := g.NewCache()
|
||||
cache.AddKeys(g.getGroupMembersHashKey(groupID))
|
||||
|
||||
return cache
|
||||
}
|
||||
|
||||
@@ -399,12 +411,14 @@ func (g *GroupCacheRedis) GetGroupsMemberIDs(ctx context.Context, groupIDs []str
|
||||
}
|
||||
m[groupID] = userIDs
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (g *GroupCacheRedis) DelGroupMemberIDs(groupID string) GroupCache {
|
||||
cache := g.NewCache()
|
||||
cache.AddKeys(g.getGroupMemberIDsKey(groupID))
|
||||
|
||||
return cache
|
||||
}
|
||||
|
||||
@@ -421,12 +435,13 @@ func (g *GroupCacheRedis) GetJoinedGroupIDs(ctx context.Context, userID string)
|
||||
}
|
||||
|
||||
func (g *GroupCacheRedis) DelJoinedGroupID(userIDs ...string) GroupCache {
|
||||
var keys []string
|
||||
keys := make([]string, 0, len(userIDs))
|
||||
for _, userID := range userIDs {
|
||||
keys = append(keys, g.getJoinedGroupsKey(userID))
|
||||
}
|
||||
cache := g.NewCache()
|
||||
cache.AddKeys(keys...)
|
||||
|
||||
return cache
|
||||
}
|
||||
|
||||
@@ -450,10 +465,11 @@ func (g *GroupCacheRedis) GetGroupMembersInfo(
|
||||
groupID string,
|
||||
userIDs []string,
|
||||
) ([]*relationtb.GroupMemberModel, error) {
|
||||
var keys []string
|
||||
keys := make([]string, 0, len(userIDs))
|
||||
for _, userID := range userIDs {
|
||||
keys = append(keys, g.getGroupMemberInfoKey(groupID, userID))
|
||||
}
|
||||
|
||||
return batchGetCache(
|
||||
ctx,
|
||||
g.rcClient,
|
||||
@@ -482,6 +498,7 @@ func (g *GroupCacheRedis) GetGroupMembersPage(
|
||||
userIDs = groupMemberIDs
|
||||
}
|
||||
groupMembers, err = g.GetGroupMembersInfo(ctx, groupID, utils.Paginate(userIDs, int(showNumber), int(showNumber)))
|
||||
|
||||
return uint32(len(userIDs)), groupMembers, err
|
||||
}
|
||||
|
||||
@@ -493,6 +510,7 @@ func (g *GroupCacheRedis) GetAllGroupMembersInfo(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return g.GetGroupMembersInfo(ctx, groupID, groupMemberIDs)
|
||||
}
|
||||
|
||||
@@ -504,10 +522,11 @@ func (g *GroupCacheRedis) GetAllGroupMemberInfo(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var keys []string
|
||||
keys := make([]string, 0, len(groupMemberIDs))
|
||||
for _, groupMemberID := range groupMemberIDs {
|
||||
keys = append(keys, g.getGroupMemberInfoKey(groupID, groupMemberID))
|
||||
}
|
||||
|
||||
return batchGetCache(
|
||||
ctx,
|
||||
g.rcClient,
|
||||
@@ -521,12 +540,13 @@ func (g *GroupCacheRedis) GetAllGroupMemberInfo(
|
||||
}
|
||||
|
||||
func (g *GroupCacheRedis) DelGroupMembersInfo(groupID string, userIDs ...string) GroupCache {
|
||||
var keys []string
|
||||
keys := make([]string, 0, len(userIDs))
|
||||
for _, userID := range userIDs {
|
||||
keys = append(keys, g.getGroupMemberInfoKey(groupID, userID))
|
||||
}
|
||||
cache := g.NewCache()
|
||||
cache.AddKeys(keys...)
|
||||
|
||||
return cache
|
||||
}
|
||||
|
||||
@@ -543,11 +563,12 @@ func (g *GroupCacheRedis) GetGroupMemberNum(ctx context.Context, groupID string)
|
||||
}
|
||||
|
||||
func (g *GroupCacheRedis) DelGroupsMemberNum(groupID ...string) GroupCache {
|
||||
var keys []string
|
||||
keys := make([]string, 0, len(groupID))
|
||||
for _, groupID := range groupID {
|
||||
keys = append(keys, g.getGroupMemberNumKey(groupID))
|
||||
}
|
||||
cache := g.NewCache()
|
||||
cache.AddKeys(keys...)
|
||||
|
||||
return cache
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user