run golangci-lint in CI

This commit is contained in:
Krystian Chmura committed 2024-05-11 14:41:25 +02:00
1 parent 36f353b8a6
commit 03865f9b94
8 files changed
+66 -49

No files matched your search

+8 -3
View File
@@ -28,9 +28,13 @@ import (
"github.com/pagefaultgames/rogueserver/db"
)
func Init(mux *http.ServeMux) {
scheduleStatRefresh()
daily.Init()
func Init(mux *http.ServeMux) error {
if err := scheduleStatRefresh(); err != nil {
return err
}
if err := daily.Init(); err != nil {
return err
}
// account
mux.HandleFunc("GET /account/info", handleAccountInfo)
@@ -54,6 +58,7 @@ func Init(mux *http.ServeMux) {
mux.HandleFunc("GET /daily/seed", handleDailySeed)
mux.HandleFunc("GET /daily/rankings", handleDailyRankings)
mux.HandleFunc("GET /daily/rankingpagecount", handleDailyRankingPageCount)
return nil
}
func tokenFromRequest(r *http.Request) ([]byte, error) {
+7 -4
View File
@@ -159,7 +159,7 @@ func handleGameTitleStats(w http.ResponseWriter, r *http.Request) {
}
func handleGameClassicSessionCount(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(strconv.Itoa(classicSessionCount)))
_, _ = w.Write([]byte(strconv.Itoa(classicSessionCount)))
}
func handleSaveData(w http.ResponseWriter, r *http.Request) {
@@ -274,7 +274,10 @@ func handleSaveData(w http.ResponseWriter, r *http.Request) {
return
}
} else {
db.UpdateTrainerIds(trainerId, secretId, uuid)
if err := db.UpdateTrainerIds(trainerId, secretId, uuid); err != nil {
httpError(w, r, err, http.StatusInternalServerError)
return
}
}
}
@@ -365,7 +368,7 @@ func handleDailySeed(w http.ResponseWriter, r *http.Request) {
return
}
w.Write([]byte(seed))
_, _ = w.Write([]byte(seed))
}
func handleDailyRankings(w http.ResponseWriter, r *http.Request) {
@@ -420,5 +423,5 @@ func handleDailyRankingPageCount(w http.ResponseWriter, r *http.Request) {
httpError(w, r, err, http.StatusInternalServerError)
}
w.Write([]byte(strconv.Itoa(count)))
_, _ = w.Write([]byte(strconv.Itoa(count)))
}
-10
View File
@@ -20,15 +20,11 @@ package savedata
import (
"fmt"
"log"
"strconv"
"github.com/klauspost/compress/zstd"
"github.com/pagefaultgames/rogueserver/db"
"github.com/pagefaultgames/rogueserver/defs"
)
var zstdEncoder, _ = zstd.NewWriter(nil)
// /savedata/update - update save data
func Update(uuid []byte, slot int, save any) error {
err := db.UpdateAccountLastActivity(uuid)
@@ -62,12 +58,6 @@ func Update(uuid []byte, slot int, save any) error {
if slot < 0 || slot >= defs.SessionSlotCount {
return fmt.Errorf("slot id %d out of range", slot)
}
filename := "session"
if slot != 0 {
filename += strconv.Itoa(slot)
}
return db.StoreSessionSaveData(uuid, save, slot)
default:
+6 -2
View File
@@ -32,15 +32,19 @@ var (
classicSessionCount int
)
func scheduleStatRefresh() {
scheduler.AddFunc("@every 30s", func() {
func scheduleStatRefresh() error {
_, err := scheduler.AddFunc("@every 30s", func() {
err := updateStats()
if err != nil {
log.Printf("failed to update stats: %s", err)
}
})
if err != nil {
return err
}
scheduler.Start()
return nil
}
func updateStats() error {