From 38027f03566066afab03a11bd032f28a22f40418 Mon Sep 17 00:00:00 2001 From: Celeo Date: Fri, 13 Feb 2026 23:12:25 -0800 Subject: [PATCH 1/2] Fix types --- cmd/database/migration.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cmd/database/migration.go b/cmd/database/migration.go index 8b36991..53b9e00 100644 --- a/cmd/database/migration.go +++ b/cmd/database/migration.go @@ -2,15 +2,16 @@ package main import ( "fmt" + "os" + "sync" + "time" + "github.com/VATUSA/primary-api/pkg/config" "github.com/VATUSA/primary-api/pkg/constants" "github.com/VATUSA/primary-api/pkg/database" "github.com/VATUSA/primary-api/pkg/database/models" "github.com/joho/godotenv" "gorm.io/gorm" - "os" - "sync" - "time" ) type Facility struct { @@ -200,7 +201,6 @@ func MigrateUsers(oldDbConn *gorm.DB) { Home: true, Visiting: false, Status: "Active", - DeletedAt: nil, } if err := roster.Create(); err != nil { @@ -220,7 +220,6 @@ func MigrateUsers(oldDbConn *gorm.DB) { Home: false, Visiting: true, Status: "Active", - DeletedAt: nil, } if err := roster.Create(); err != nil { From 4c50cbb0af761e2483b7001a1952fe1d665e970d Mon Sep 17 00:00:00 2001 From: Celeo Date: Sat, 14 Feb 2026 11:20:56 -0800 Subject: [PATCH 2/2] Fix more lints; add linter configuration --- .golangci.yaml | 10 ++++++++++ cmd/database/migration.go | 4 ++-- pkg/go-chi/middleware/auth/feedback.go | 7 ++++--- views/router.go | 8 +++++--- views/v3/user/login.go | 15 ++++++++------- 5 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 .golangci.yaml diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..c44ceac --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,10 @@ +version: "2" +linters: + default: standard + settings: + errcheck: {} + staticcheck: + checks: + - "-QF1003" +severity: + default: warning diff --git a/cmd/database/migration.go b/cmd/database/migration.go index 53b9e00..da83492 100644 --- a/cmd/database/migration.go +++ b/cmd/database/migration.go @@ -103,7 +103,7 @@ func main() { } func MigrateFacilities(oldDbConn *gorm.DB) { - fmt.Sprintln("Migrating facilities") + fmt.Println("Migrating facilities") var facilities []Facility oldDbConn.Table("facilities").Find(&facilities) @@ -126,7 +126,7 @@ func MigrateFacilities(oldDbConn *gorm.DB) { } } - fmt.Sprintln("Done migrating facilities") + fmt.Println("Done migrating facilities") } func MigrateUsers(oldDbConn *gorm.DB) { diff --git a/pkg/go-chi/middleware/auth/feedback.go b/pkg/go-chi/middleware/auth/feedback.go index 62e84a5..933186a 100644 --- a/pkg/go-chi/middleware/auth/feedback.go +++ b/pkg/go-chi/middleware/auth/feedback.go @@ -2,11 +2,12 @@ package middleware import ( "encoding/json" + "net/http" + "strconv" + "github.com/VATUSA/primary-api/pkg/database/types" "github.com/VATUSA/primary-api/pkg/utils" log "github.com/sirupsen/logrus" - "net/http" - "strconv" ) func CanViewFeedback(next http.Handler) http.Handler { @@ -120,7 +121,7 @@ func CanLeaveFeedback(next http.Handler) http.Handler { if credentials.User != nil { if req.Status != types.Pending { - log.Error("User %d, attempted to create feedback with status: %s. No permissions.", credentials.User.CID, req.Status) + log.Errorf("User %d, attempted to create feedback with status: %s. No permissions.", credentials.User.CID, req.Status) utils.Render(w, r, utils.ErrForbidden) return } diff --git a/views/router.go b/views/router.go index 37acc27..41e0f92 100644 --- a/views/router.go +++ b/views/router.go @@ -2,14 +2,16 @@ package views import ( "fmt" + "github.com/VATUSA/primary-api/pkg/config" "github.com/VATUSA/primary-api/views/docs" - _ "github.com/VATUSA/primary-api/views/docs" + + "net/http" + "strings" + v3 "github.com/VATUSA/primary-api/views/v3" "github.com/go-chi/chi/v5" httpSwagger "github.com/swaggo/http-swagger" - "net/http" - "strings" ) // @title VATUSA API diff --git a/views/v3/user/login.go b/views/v3/user/login.go index e42f1bc..f467b82 100644 --- a/views/v3/user/login.go +++ b/views/v3/user/login.go @@ -4,6 +4,13 @@ import ( "context" "encoding/json" "fmt" + "io" + "net/http" + "net/url" + "strconv" + "strings" + "time" + "github.com/VATUSA/primary-api/pkg/config" "github.com/VATUSA/primary-api/pkg/constants" "github.com/VATUSA/primary-api/pkg/cookie" @@ -14,12 +21,6 @@ import ( gonanoid "github.com/matoous/go-nanoid" log "github.com/sirupsen/logrus" "golang.org/x/oauth2" - "io" - "net/http" - "net/url" - "strconv" - "strings" - "time" ) func GetLogin(w http.ResponseWriter, r *http.Request) { @@ -292,7 +293,7 @@ func exchangeToken(ctx context.Context, oauthConfig *oauth2.Config, code string) if err != nil { return nil, fmt.Errorf("error sending token request: %w", err) } - defer resp.Body.Close() + defer func() { _ = resp.Body.Close() }() if resp.StatusCode != http.StatusOK { return nil, fmt.Errorf("unexpected token response status: %s", resp.Status)