From 63bdc74d93b8b0af9a7eddd7e23e3dec33feb24f Mon Sep 17 00:00:00 2001 From: taoky Date: Wed, 24 Jul 2024 04:35:37 +0800 Subject: [PATCH] ci: add nilness check in govet (#86) * fix(server): check db error correctly in handlerGetRepo * ci: add nilness check in govet --- .golangci.yml | 3 +++ pkg/server/repo_handlers.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index cb221b7..c242661 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -65,6 +65,9 @@ linters-settings: - standard # Standard section: captures all standard packages. - default # Default section: contains all imports that could not be matched to another section type. - prefix(github.com/ustclug/Yuki) + govet: + enable: + - nilness exhaustive: # Only run exhaustive check on switches with "//exhaustive:enforce" comment. explicit-exhaustive-switch: true diff --git a/pkg/server/repo_handlers.go b/pkg/server/repo_handlers.go index b369e6f..ce269ac 100644 --- a/pkg/server/repo_handlers.go +++ b/pkg/server/repo_handlers.go @@ -62,7 +62,7 @@ func (s *Server) handlerGetRepo(c echo.Context) error { Where(model.Repo{Name: name}). Limit(1). Find(&repo) - if err != nil { + if res.Error != nil { const msg = "Fail to get Repo" l.Error(msg, slogErrAttr(err)) return newHTTPError(http.StatusInternalServerError, msg)