diff --git a/cmd/evening_detective_server/main.go b/cmd/evening_detective_server/main.go index df902ce..f6b5b71 100644 --- a/cmd/evening_detective_server/main.go +++ b/cmd/evening_detective_server/main.go @@ -294,7 +294,9 @@ func main() { mainMux.Handle("/docs/", docsHandler) mainMux.HandleFunc("/swagger/doc.json", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") - w.Write(swaggerJSON) + if _, err := w.Write(swaggerJSON); err != nil { + log.Printf("write swagger document: %v", err) + } }) // MaxBytesReader на HTTP-слое: gateway буферизует тело целиком, без лимита // проверки в хендлере не спасут от OOM. Лимиты по маршрутам: файлы — diff --git a/internal/modules/email_sender/sender.go b/internal/modules/email_sender/sender.go index 5f4d48a..ac6f8f9 100644 --- a/internal/modules/email_sender/sender.go +++ b/internal/modules/email_sender/sender.go @@ -76,7 +76,7 @@ func (s *sender) Send(ctx context.Context, message Message) error { if err != nil { return fmt.Errorf("email: smtp dial %s: %w", addr, err) } - defer rawConn.Close() + defer func() { _ = rawConn.Close() }() conn := tls.Client(rawConn, s.tlsConfig) if deadline, ok := ctx.Deadline(); ok { diff --git a/internal/modules/scenario_archive/archive.go b/internal/modules/scenario_archive/archive.go index 0fd72ec..73df55c 100644 --- a/internal/modules/scenario_archive/archive.go +++ b/internal/modules/scenario_archive/archive.go @@ -261,7 +261,9 @@ func (a *scenarioArchive) Unpack(data []byte) (*Bundle, error) { return nil, fmt.Errorf("не удалось открыть запись %q: %w", name, err) } content, err := readEntry(rc) - rc.Close() + if closeErr := rc.Close(); err == nil { + err = closeErr + } if err != nil { return nil, fmt.Errorf("запись %q: %w", name, err) } diff --git a/internal/repos/tickets_repo/repo.go b/internal/repos/tickets_repo/repo.go index 73237b1..0cbf901 100644 --- a/internal/repos/tickets_repo/repo.go +++ b/internal/repos/tickets_repo/repo.go @@ -39,7 +39,7 @@ func (r *Repo) CreateBatch(ctx context.Context, gameID int, tokenHashes [][]byte if err != nil { return nil, err } - defer tx.Rollback(ctx) + defer func() { _ = tx.Rollback(ctx) }() ids := make([]int, 0, len(tokenHashes)) for _, tokenHash := range tokenHashes { diff --git a/internal/services/participation_service/service.go b/internal/services/participation_service/service.go index 2a023a1..77ad51a 100644 --- a/internal/services/participation_service/service.go +++ b/internal/services/participation_service/service.go @@ -58,7 +58,7 @@ func mapParticipationError(err error) error { // рабочими процессами и перезапусками. func participationToken(secret string, id int) string { mac := hmac.New(sha256.New, []byte(secret)) - fmt.Fprintf(mac, "team-participation:v1:%d", id) + _, _ = fmt.Fprintf(mac, "team-participation:v1:%d", id) return hex.EncodeToString(mac.Sum(nil)) }