From 0e03fb6393cca5df7311cb28fd432a1d335c2b82 Mon Sep 17 00:00:00 2001 From: wangchuxiao <wangchuxiao97@outlook.com> Date: Wed, 18 May 2022 12:51:33 +0800 Subject: [PATCH] organization --- internal/rpc/office/office.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/rpc/office/office.go b/internal/rpc/office/office.go index 1cade65eb..91b8ab669 100644 --- a/internal/rpc/office/office.go +++ b/internal/rpc/office/office.go @@ -240,6 +240,7 @@ func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagR var tagSendLogs db.TagSendLog wg.Add(len(userIDList)) + var lock sync.Mutex for _, userID := range userIDList { go func(userID string) { defer wg.Done() @@ -248,10 +249,12 @@ func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagR log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserNameByUserID failed", err.Error()) return } + lock.Lock() tagSendLogs.UserList = append(tagSendLogs.UserList, db.TagUser{ UserID: userID, UserName: userName, }) + lock.Unlock() }(userID) } wg.Wait()