diff --git a/server/matchmaker_test.go b/server/matchmaker_test.go index 2584a9a4ec..b68cd7a197 100644 --- a/server/matchmaker_test.go +++ b/server/matchmaker_test.go @@ -202,16 +202,16 @@ func TestMatchmakerPropertyRegexSubmatch(t *testing.T) { parsedIndexQuery1, err := ParseQueryString("+properties.game_mode:foo -properties.blocked:/.*4bd6667a\\-2659\\-4888\\-b245\\-e13690ff4a9b.*/") if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } searchRequest1 := bluge.NewTopNSearch(100, parsedIndexQuery1) iter1, err := reader.Search(context.Background(), searchRequest1) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } doc1, err := iter1.Next() if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } if doc1 != nil { t.Fatalf("doc1 not nil") @@ -219,16 +219,16 @@ func TestMatchmakerPropertyRegexSubmatch(t *testing.T) { parsedIndexQuery2, err := ParseQueryString("+properties.game_mode:foo -properties.blocked:/.*cc44260e\\-6b7d\\-4237\\-9871\\-6146d86f7a71.*/") if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } searchRequest2 := bluge.NewTopNSearch(100, parsedIndexQuery2) iter2, err := reader.Search(context.Background(), searchRequest2) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } doc2, err := iter2.Next() if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } if doc2 != nil { t.Fatalf("doc2 not nil") @@ -236,16 +236,16 @@ func TestMatchmakerPropertyRegexSubmatch(t *testing.T) { parsedIndexQuery3, err := ParseQueryString("+properties.game_mode:foo -properties.blocked:/.*324b7447\\-ec0f\\-4b5f\\-9a13\\-06511d0bb527.*/") if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } searchRequest3 := bluge.NewTopNSearch(100, parsedIndexQuery3) iter3, err := reader.Search(context.Background(), searchRequest3) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } doc3, err := iter3.Next() if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } if doc3 != nil { t.Fatalf("doc3 not nil") @@ -253,16 +253,16 @@ func TestMatchmakerPropertyRegexSubmatch(t *testing.T) { parsedIndexQuery4, err := ParseQueryString("+properties.game_mode:bar -properties.blocked:/.*3a3b78a0\\-8622\\-4a23\\-be42\\-70bfbb26582f.*/") if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } searchRequest4 := bluge.NewTopNSearch(100, parsedIndexQuery4) iter4, err := reader.Search(context.Background(), searchRequest4) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } doc4, err := iter4.Next() if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } if doc4 != nil { t.Fatalf("doc4 not nil") @@ -270,16 +270,16 @@ func TestMatchmakerPropertyRegexSubmatch(t *testing.T) { parsedIndexQuery5, err := ParseQueryString("+properties.game_mode:foo -properties.blocked:/.*3a3b78a0\\-8622\\-4a23\\-be42\\-70bfbb26582f.*/") if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } searchRequest5 := bluge.NewTopNSearch(100, parsedIndexQuery5) iter5, err := reader.Search(context.Background(), searchRequest5) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } doc5, err := iter5.Next() if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } if doc5 == nil { t.Fatalf("doc5 nil") @@ -313,31 +313,31 @@ func TestMatchmakerPropertyRegexSubmatchMultiple(t *testing.T) { SessionIDs: map[string]struct{}{"sid1": {}}, }) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } if err := matchMaker.indexWriter.Update(bluge.Identifier("ticket1"), matchmakerIndexDoc1); err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } reader, err := matchMaker.indexWriter.Reader() if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } defer reader.Close() parsedIndexQuery1, err := ParseQueryString("+properties.game_mode:foo +properties.maps:/.*(map3|some_map_foo).*/") if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } searchRequest1 := bluge.NewTopNSearch(100, parsedIndexQuery1) iter1, err := reader.Search(context.Background(), searchRequest1) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } doc1, err := iter1.Next() if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } if doc1 != nil { t.Fatalf("doc1 not nil") @@ -345,16 +345,16 @@ func TestMatchmakerPropertyRegexSubmatchMultiple(t *testing.T) { parsedIndexQuery2, err := ParseQueryString("+properties.game_mode:bar +properties.maps:/.*(map2|map3).*/") if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } searchRequest2 := bluge.NewTopNSearch(100, parsedIndexQuery2) iter2, err := reader.Search(context.Background(), searchRequest2) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } doc2, err := iter2.Next() if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } if doc2 != nil { t.Fatalf("doc2 not nil") @@ -362,16 +362,16 @@ func TestMatchmakerPropertyRegexSubmatchMultiple(t *testing.T) { parsedIndexQuery3, err := ParseQueryString("+properties.game_mode:foo +properties.maps:/.*(map2|map3).*/") if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } searchRequest3 := bluge.NewTopNSearch(100, parsedIndexQuery3) iter3, err := reader.Search(context.Background(), searchRequest3) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } doc3, err := iter3.Next() if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err) } if doc3 == nil { t.Fatalf("doc3 nil") diff --git a/server/runtime_lua_nakama.go b/server/runtime_lua_nakama.go index 9f74adbfc2..c1311cc3dc 100644 --- a/server/runtime_lua_nakama.go +++ b/server/runtime_lua_nakama.go @@ -810,7 +810,7 @@ func (n *RuntimeLuaNakamaModule) localcacheDelete(l *lua.LState) int { return 0 } -func (n *RuntimeLuaNakamaModule) localcacheClear(l *lua.LState) int { +func (n *RuntimeLuaNakamaModule) localcacheClear(_ *lua.LState) int { n.localCache.Clear() return 0 @@ -827,13 +827,13 @@ func (n *RuntimeLuaNakamaModule) time(l *lua.LState) int { tbl := l.CheckTable(1) msec := getIntField(l, tbl, "msec", 0) sec := getIntField(l, tbl, "sec", 0) - min := getIntField(l, tbl, "min", 0) + mins := getIntField(l, tbl, "min", 0) hour := getIntField(l, tbl, "hour", 12) day := getIntField(l, tbl, "day", -1) month := getIntField(l, tbl, "month", -1) year := getIntField(l, tbl, "year", -1) isdst := getBoolField(l, tbl, "isdst", false) - t := time.Date(year, time.Month(month), day, hour, min, sec, msec*int(time.Millisecond), time.UTC) + t := time.Date(year, time.Month(month), day, hour, mins, sec, msec*int(time.Millisecond), time.UTC) // TODO dst if false { print(isdst) @@ -1147,7 +1147,7 @@ func (n *RuntimeLuaNakamaModule) httpRequest(l *lua.LState) int { } // Read the response body. responseBody, err := io.ReadAll(resp.Body) - resp.Body.Close() + _ = resp.Body.Close() if err != nil { l.RaiseError("HTTP response body error: %v", err.Error()) return 0 @@ -1164,7 +1164,7 @@ func (n *RuntimeLuaNakamaModule) httpRequest(l *lua.LState) int { l.Push(lua.LNumber(resp.StatusCode)) l.Push(RuntimeLuaConvertMap(l, responseHeaders)) - l.Push(lua.LString(string(responseBody))) + l.Push(lua.LString(responseBody)) return 3 } @@ -1260,7 +1260,7 @@ func (n *RuntimeLuaNakamaModule) jsonEncode(l *lua.LState) int { return 0 } - l.Push(lua.LString(string(jsonBytes))) + l.Push(lua.LString(jsonBytes)) return 1 } @@ -1697,7 +1697,7 @@ func (n *RuntimeLuaNakamaModule) bcryptCompare(l *lua.LState) int { if err == nil { l.Push(lua.LBool(true)) return 1 - } else if err == bcrypt.ErrHashTooShort || err == bcrypt.ErrMismatchedHashAndPassword { + } else if errors.Is(err, bcrypt.ErrHashTooShort) || errors.Is(err, bcrypt.ErrMismatchedHashAndPassword) { l.Push(lua.LBool(false)) return 1 } @@ -2711,7 +2711,7 @@ func (n *RuntimeLuaNakamaModule) usersGetId(l *lua.LState) int { // Get the user accounts. users, err := GetUsers(l.Context(), n.logger, n.db, n.statusRegistry, userIDs, nil, facebookIDs) if err != nil { - l.RaiseError(fmt.Sprintf("failed to get users: %s", err.Error())) + l.RaiseError("failed to get users: %s", err.Error()) return 0 } @@ -2910,7 +2910,7 @@ func (n *RuntimeLuaNakamaModule) usersGetUsername(l *lua.LState) int { // Get the user accounts. users, err := GetUsers(l.Context(), n.logger, n.db, n.statusRegistry, nil, usernameStrings, nil) if err != nil { - l.RaiseError(fmt.Sprintf("failed to get users: %s", err.Error())) + l.RaiseError("failed to get users: %s", err.Error()) return 0 } @@ -3009,7 +3009,7 @@ func (n *RuntimeLuaNakamaModule) usersGetRandom(l *lua.LState) int { users, err := GetRandomUsers(l.Context(), n.logger, n.db, n.statusRegistry, count) if err != nil { - l.RaiseError(fmt.Sprintf("failed to get users: %s", err.Error())) + l.RaiseError("failed to get users: %s", err.Error()) return 0 } @@ -3070,7 +3070,7 @@ func (n *RuntimeLuaNakamaModule) usersBanId(l *lua.LState) int { // Ban the user accounts. err := BanUsers(l.Context(), n.logger, n.db, n.config, n.sessionCache, n.sessionRegistry, n.tracker, uids) if err != nil { - l.RaiseError(fmt.Sprintf("failed to ban users: %s", err.Error())) + l.RaiseError("failed to ban users: %s", err.Error()) return 0 } @@ -3119,7 +3119,7 @@ func (n *RuntimeLuaNakamaModule) usersUnbanId(l *lua.LState) int { // Unban the user accounts. err := UnbanUsers(l.Context(), n.logger, n.db, n.sessionCache, uids) if err != nil { - l.RaiseError(fmt.Sprintf("failed to unban users: %s", err.Error())) + l.RaiseError("failed to unban users: %s", err.Error()) return 0 } @@ -3924,11 +3924,11 @@ func (n *RuntimeLuaNakamaModule) streamUserJoin(l *lua.LState) int { success, newlyTracked, err := n.streamManager.UserJoin(stream, userID, sessionID, hidden, persistence, status) if err != nil { - if err == ErrSessionNotFound { + if errors.Is(err, ErrSessionNotFound) { l.ArgError(2, "session id does not exist") return 0 } - l.RaiseError(fmt.Sprintf("stream user join failed: %v", err.Error())) + l.RaiseError("stream user join failed: %v", err.Error()) return 0 } if !success { @@ -4043,11 +4043,11 @@ func (n *RuntimeLuaNakamaModule) streamUserUpdate(l *lua.LState) int { success, err := n.streamManager.UserUpdate(stream, userID, sessionID, hidden, persistence, status) if err != nil { - if err == ErrSessionNotFound { + if errors.Is(err, ErrSessionNotFound) { l.ArgError(2, "session id does not exist") return 0 } - l.RaiseError(fmt.Sprintf("stream user update failed: %v", err.Error())) + l.RaiseError("stream user update failed: %v", err.Error()) return 0 } if !success { @@ -4149,7 +4149,7 @@ func (n *RuntimeLuaNakamaModule) streamUserLeave(l *lua.LState) int { } if err := n.streamManager.UserLeave(stream, userID, sessionID); err != nil { - l.RaiseError(fmt.Sprintf("stream user leave failed: %v", err.Error())) + l.RaiseError("stream user leave failed: %v", err.Error()) } return 0 @@ -4270,7 +4270,7 @@ func (n *RuntimeLuaNakamaModule) streamUserKick(l *lua.LState) int { } if err := n.streamManager.UserLeave(stream, userID, sessionID); err != nil { - l.RaiseError(fmt.Sprintf("stream user kick failed: %v", err.Error())) + l.RaiseError("stream user kick failed: %v", err.Error()) } return 0 @@ -4769,7 +4769,7 @@ func (n *RuntimeLuaNakamaModule) sessionDisconnect(l *lua.LState) int { } if err := n.sessionRegistry.Disconnect(l.Context(), sessionID, false, reason...); err != nil { - l.RaiseError(fmt.Sprintf("failed to disconnect: %s", err.Error())) + l.RaiseError("failed to disconnect: %s", err.Error()) } return 0 } @@ -4797,7 +4797,7 @@ func (n *RuntimeLuaNakamaModule) sessionLogout(l *lua.LState) int { refreshToken := l.OptString(3, "") if err := SessionLogout(n.config, n.sessionCache, userID, token, refreshToken); err != nil { - l.RaiseError(fmt.Sprintf("failed to logout: %s", err.Error())) + l.RaiseError("failed to logout: %s", err.Error()) } return 0 } @@ -4848,7 +4848,7 @@ func (n *RuntimeLuaNakamaModule) matchGet(l *lua.LState) int { result, _, err := n.matchRegistry.GetMatch(l.Context(), id) if err != nil { - l.RaiseError(fmt.Sprintf("failed to get match: %s", err.Error())) + l.RaiseError("failed to get match: %s", err.Error()) return 0 } @@ -4896,7 +4896,7 @@ func (n *RuntimeLuaNakamaModule) matchSignal(l *lua.LState) int { responseData, err := n.matchRegistry.Signal(l.Context(), id, data) if err != nil { - l.RaiseError(fmt.Sprintf("failed to signal match: %s", err.Error())) + l.RaiseError("failed to signal match: %s", err.Error()) return 0 } @@ -4969,7 +4969,7 @@ func (n *RuntimeLuaNakamaModule) matchList(l *lua.LState) int { results, _, err := n.matchRegistry.ListMatches(l.Context(), limit, authoritative, label, minSize, maxSize, query, nil) if err != nil { - l.RaiseError(fmt.Sprintf("failed to list matches: %s", err.Error())) + l.RaiseError("failed to list matches: %s", err.Error()) return 0 } @@ -5064,7 +5064,7 @@ func (n *RuntimeLuaNakamaModule) notificationSend(l *lua.LState) int { } if err := NotificationSend(l.Context(), n.logger, n.db, n.tracker, n.router, notifications); err != nil { - l.RaiseError(fmt.Sprintf("failed to send notifications: %s", err.Error())) + l.RaiseError("failed to send notifications: %s", err.Error()) } return 0 @@ -5221,7 +5221,7 @@ func (n *RuntimeLuaNakamaModule) notificationsSend(l *lua.LState) int { } if err := NotificationSend(l.Context(), n.logger, n.db, n.tracker, n.router, notifications); err != nil { - l.RaiseError(fmt.Sprintf("failed to send notifications: %s", err.Error())) + l.RaiseError("failed to send notifications: %s", err.Error()) } return 0 @@ -5271,7 +5271,7 @@ func (n *RuntimeLuaNakamaModule) notificationSendAll(l *lua.LState) int { } if err := NotificationSendAll(l.Context(), n.logger, n.db, n.tracker, n.router, notification); err != nil { - l.RaiseError(fmt.Sprintf("failed to send notification: %s", err.Error())) + l.RaiseError("failed to send notification: %s", err.Error()) } return 0 @@ -5571,7 +5571,7 @@ func (n *RuntimeLuaNakamaModule) notificationsGetId(l *lua.LState) int { notifications, err := NotificationsGetId(l.Context(), n.logger, n.db, userId, notifIds...) if err != nil { - l.RaiseError(fmt.Sprintf("failed to get notifications: %s", err.Error())) + l.RaiseError("failed to get notifications: %s", err.Error()) } notificationsTable := l.CreateTable(len(notifications), 0) @@ -5690,7 +5690,7 @@ func (n *RuntimeLuaNakamaModule) walletUpdate(l *lua.LState) int { Metadata: string(metadataBytes), }}, updateLedger) if err != nil { - l.RaiseError(fmt.Sprintf("failed to update user wallet: %s", err.Error())) + l.RaiseError("failed to update user wallet: %s", err.Error()) return 0 } @@ -5815,7 +5815,7 @@ func (n *RuntimeLuaNakamaModule) walletsUpdate(l *lua.LState) int { results, err := UpdateWallets(l.Context(), n.logger, n.db, updates, updateLedger) if err != nil { - l.RaiseError(fmt.Sprintf("failed to update user wallet: %s", err.Error())) + l.RaiseError("failed to update user wallet: %s", err.Error()) return 0 } @@ -5873,7 +5873,7 @@ func (n *RuntimeLuaNakamaModule) walletLedgerUpdate(l *lua.LState) int { item, err := UpdateWalletLedger(l.Context(), n.logger, n.db, itemID, string(metadataBytes)) if err != nil { - l.RaiseError(fmt.Sprintf("failed to update user wallet ledger: %s", err.Error())) + l.RaiseError("failed to update user wallet ledger: %s", err.Error()) return 0 } @@ -5925,7 +5925,7 @@ func (n *RuntimeLuaNakamaModule) walletLedgerList(l *lua.LState) int { items, newCursor, _, err := ListWalletLedger(l.Context(), n.logger, n.db, userID, &limit, cursor) if err != nil { - l.RaiseError(fmt.Sprintf("failed to retrieve user wallet ledger: %s", err.Error())) + l.RaiseError("failed to retrieve user wallet ledger: %s", err.Error()) return 0 } @@ -6081,7 +6081,7 @@ func (n *RuntimeLuaNakamaModule) storageList(l *lua.LState) int { objectList, _, err := StorageListObjects(l.Context(), n.logger, n.db, callerID, userID, collection, limit, cursor) if err != nil { - l.RaiseError(fmt.Sprintf("failed to list storage objects: %s", err.Error())) + l.RaiseError("failed to list storage objects: %s", err.Error()) return 0 } @@ -6104,7 +6104,7 @@ func (n *RuntimeLuaNakamaModule) storageList(l *lua.LState) int { valueMap := make(map[string]interface{}) err = json.Unmarshal([]byte(v.Value), &valueMap) if err != nil { - l.RaiseError(fmt.Sprintf("failed to convert value to json: %s", err.Error())) + l.RaiseError("failed to convert value to json: %s", err.Error()) return 0 } valueTable := RuntimeLuaConvertMap(l, valueMap) @@ -6229,7 +6229,7 @@ func (n *RuntimeLuaNakamaModule) storageRead(l *lua.LState) int { objects, err := StorageReadObjects(l.Context(), n.logger, n.db, uuid.Nil, objectIDs) if err != nil { - l.RaiseError(fmt.Sprintf("failed to read storage objects: %s", err.Error())) + l.RaiseError("failed to read storage objects: %s", err.Error()) return 0 } @@ -6252,7 +6252,7 @@ func (n *RuntimeLuaNakamaModule) storageRead(l *lua.LState) int { valueMap := make(map[string]interface{}) err = json.Unmarshal([]byte(v.Value), &valueMap) if err != nil { - l.RaiseError(fmt.Sprintf("failed to convert value to json: %s", err.Error())) + l.RaiseError("failed to convert value to json: %s", err.Error()) return 0 } valueTable := RuntimeLuaConvertMap(l, valueMap) @@ -6289,7 +6289,7 @@ func (n *RuntimeLuaNakamaModule) storageWrite(l *lua.LState) int { acks, _, err := StorageWriteObjects(l.Context(), n.logger, n.db, n.metrics, n.storageIndex, true, ops) if err != nil { - l.RaiseError(fmt.Sprintf("failed to write storage objects: %s", err.Error())) + l.RaiseError("failed to write storage objects: %s", err.Error()) return 0 } @@ -6465,7 +6465,7 @@ func storageOpWritesToTable(l *lua.LState, ops StorageOpWrites) (*lua.LTable, er valueMap := make(map[string]interface{}) err := json.Unmarshal([]byte(v.Object.Value), &valueMap) if err != nil { - l.RaiseError(fmt.Sprintf("failed to convert value to json: %s", err.Error())) + l.RaiseError("failed to convert value to json: %s", err.Error()) return nil, err } valueTable := RuntimeLuaConvertMap(l, valueMap) @@ -6590,7 +6590,7 @@ func (n *RuntimeLuaNakamaModule) storageDelete(l *lua.LState) int { } if _, err := StorageDeleteObjects(l.Context(), n.logger, n.db, n.storageIndex, true, ops); err != nil { - l.RaiseError(fmt.Sprintf("failed to remove storage: %s", err.Error())) + l.RaiseError("failed to remove storage: %s", err.Error()) } return 0 @@ -7381,7 +7381,7 @@ func (n *RuntimeLuaNakamaModule) leaderboardRecordsListCursorFromRank(l *lua.LSt expiryOverride := l.OptInt64(3, 0) leaderboard := n.leaderboardCache.Get(id) - if l == nil { + if leaderboard == nil { l.RaiseError(ErrLeaderboardNotFound.Error()) return 0 } @@ -7684,7 +7684,7 @@ func (n *RuntimeLuaNakamaModule) purchaseValidateApple(l *lua.LState) int { } receipt := l.CheckString(2) - if input == "" { + if receipt == "" { l.ArgError(2, "expects receipt") return 0 } @@ -7731,7 +7731,7 @@ func (n *RuntimeLuaNakamaModule) purchaseValidateGoogle(l *lua.LState) int { } receipt := l.CheckString(2) - if input == "" { + if receipt == "" { l.ArgError(2, "expects receipt") return 0 } @@ -7782,13 +7782,13 @@ func (n *RuntimeLuaNakamaModule) purchaseValidateHuawei(l *lua.LState) int { } signature := l.CheckString(2) - if input == "" { + if signature == "" { l.ArgError(2, "expects signature") return 0 } receipt := l.CheckString(3) - if input == "" { + if receipt == "" { l.ArgError(3, "expects receipt") return 0 } @@ -7830,7 +7830,7 @@ func (n *RuntimeLuaNakamaModule) purchaseValidateFacebookInstant(l *lua.LState) } signedRequest := l.CheckString(2) - if input == "" { + if signedRequest == "" { l.ArgError(2, "expects signedRequest") return 0 } @@ -7948,7 +7948,7 @@ func (n *RuntimeLuaNakamaModule) subscriptionValidateApple(l *lua.LState) int { } receipt := l.CheckString(2) - if input == "" { + if receipt == "" { l.ArgError(2, "expects receipt") return 0 } @@ -7995,7 +7995,7 @@ func (n *RuntimeLuaNakamaModule) subscriptionValidateGoogle(l *lua.LState) int { } receipt := l.CheckString(2) - if input == "" { + if receipt == "" { l.ArgError(2, "expects receipt") return 0 } @@ -8349,7 +8349,7 @@ func (n *RuntimeLuaNakamaModule) tournamentsGetId(l *lua.LState) int { // Get the tournaments. list, err := TournamentsGet(l.Context(), n.logger, n.db, n.leaderboardCache, tournamentIDStrings) if err != nil { - l.RaiseError(fmt.Sprintf("failed to get tournaments: %s", err.Error())) + l.RaiseError("failed to get tournaments: %s", err.Error()) return 0 } @@ -8869,7 +8869,7 @@ func (n *RuntimeLuaNakamaModule) groupsGetId(l *lua.LState) int { // Get the groups. groups, err := GetGroups(l.Context(), n.logger, n.db, groupIDStrings) if err != nil { - l.RaiseError(fmt.Sprintf("failed to get groups: %s", err.Error())) + l.RaiseError("failed to get groups: %s", err.Error()) return 0 } @@ -8891,7 +8891,7 @@ func (n *RuntimeLuaNakamaModule) groupsGetId(l *lua.LState) int { metadataMap := make(map[string]interface{}) err = json.Unmarshal([]byte(g.Metadata), &metadataMap) if err != nil { - l.RaiseError(fmt.Sprintf("failed to convert metadata to json: %s", err.Error())) + l.RaiseError("failed to convert metadata to json: %s", err.Error()) return 0 } metadataTable := RuntimeLuaConvertMap(l, metadataMap) @@ -8979,7 +8979,7 @@ func (n *RuntimeLuaNakamaModule) groupCreate(l *lua.LState) int { metadataMap := make(map[string]interface{}) err = json.Unmarshal([]byte(group.Metadata), &metadataMap) if err != nil { - l.RaiseError(fmt.Sprintf("failed to convert metadata to json: %s", err.Error())) + l.RaiseError("failed to convert metadata to json: %s", err.Error()) return 0 } metadataTable := RuntimeLuaConvertMap(l, metadataMap) @@ -9552,7 +9552,7 @@ func (n *RuntimeLuaNakamaModule) groupsGetRandom(l *lua.LState) int { groups, err := GetRandomGroups(l.Context(), n.logger, n.db, count) if err != nil { - l.RaiseError(fmt.Sprintf("failed to get groups: %s", err.Error())) + l.RaiseError("failed to get groups: %s", err.Error()) return 0 } @@ -9648,7 +9648,7 @@ func (n *RuntimeLuaNakamaModule) groupUsersList(l *lua.LState) int { metadataMap := make(map[string]interface{}) err = json.Unmarshal([]byte(u.Metadata), &metadataMap) if err != nil { - l.RaiseError(fmt.Sprintf("failed to convert metadata to json: %s", err.Error())) + l.RaiseError("failed to convert metadata to json: %s", err.Error()) return 0 } metadataTable := RuntimeLuaConvertMap(l, metadataMap) @@ -9727,7 +9727,7 @@ func (n *RuntimeLuaNakamaModule) userGroupsList(l *lua.LState) int { metadataMap := make(map[string]interface{}) err = json.Unmarshal([]byte(g.Metadata), &metadataMap) if err != nil { - l.RaiseError(fmt.Sprintf("failed to convert metadata to json: %s", err.Error())) + l.RaiseError("failed to convert metadata to json: %s", err.Error()) return 0 } metadataTable := RuntimeLuaConvertMap(l, metadataMap) @@ -9922,7 +9922,7 @@ func (n *RuntimeLuaNakamaModule) friendsList(l *lua.LState) int { fut, err := userToLuaTable(l, u) if err != nil { - l.RaiseError(fmt.Sprintf("failed to convert user data to lua table: %s", err.Error())) + l.RaiseError("failed to convert user data to lua table: %s", err.Error()) return 0 } @@ -9979,7 +9979,7 @@ func (n *RuntimeLuaNakamaModule) friendsOfFriendsList(l *lua.LState) int { fut, err := userToLuaTable(l, u) if err != nil { - l.RaiseError(fmt.Sprintf("failed to convert user data to lua table: %s", err.Error())) + l.RaiseError("failed to convert user data to lua table: %s", err.Error()) return 0 } @@ -10316,18 +10316,18 @@ func (n *RuntimeLuaNakamaModule) fileRead(l *lua.LState) int { f, err := FileRead(rootPath, relPath) if err != nil { - l.RaiseError(fmt.Sprintf("failed to open file: %s", err.Error())) + l.RaiseError("failed to open file: %s", err.Error()) return 0 } defer f.Close() fileContent, err := io.ReadAll(f) if err != nil { - l.RaiseError(fmt.Sprintf("failed to read file: %s", err.Error())) + l.RaiseError("failed to read file: %s", err.Error()) return 0 } - l.Push(lua.LString(string(fileContent))) + l.Push(lua.LString(fileContent)) return 1 } @@ -10715,7 +10715,7 @@ func (n *RuntimeLuaNakamaModule) storageIndexList(l *lua.LState) int { valueMap := make(map[string]interface{}) err = json.Unmarshal([]byte(v.Value), &valueMap) if err != nil { - l.RaiseError(fmt.Sprintf("failed to convert value to json: %s", err.Error())) + l.RaiseError("failed to convert value to json: %s", err.Error()) return 0 } valueTable := RuntimeLuaConvertMap(l, valueMap) @@ -10883,7 +10883,7 @@ func (n *RuntimeLuaNakamaModule) satoriAuthenticate(l *lua.LState) int { var err error defaultPropsMap, err = RuntimeLuaConvertLuaTableString(defaultProps) if err != nil { - l.RaiseError(fmt.Sprintf("failed to convert default properties table to map: %s", err.Error())) + l.RaiseError("failed to convert default properties table to map: %s", err.Error()) return 0 } } @@ -10894,7 +10894,7 @@ func (n *RuntimeLuaNakamaModule) satoriAuthenticate(l *lua.LState) int { var err error customPropsMap, err = RuntimeLuaConvertLuaTableString(customProps) if err != nil { - l.RaiseError(fmt.Sprintf("failed to convert custom properties table to map: %s", err.Error())) + l.RaiseError("failed to convert custom properties table to map: %s", err.Error()) return 0 } }