From 79428c528684a1640d35d55502efd334d9197385 Mon Sep 17 00:00:00 2001 From: Evan Goode Date: Sat, 19 Jul 2025 18:30:04 -0400 Subject: [PATCH] lint --- api.go | 2 +- front.go | 5 +++-- main.go | 2 +- model.go | 2 +- player.go | 5 +++-- services.go | 4 ++-- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/api.go b/api.go index 0acce45..c8e9891 100644 --- a/api.go +++ b/api.go @@ -120,7 +120,7 @@ func (app *App) APIRequestToMaybeUser(c echo.Context) (mo.Option[User], error) { bearerExp := regexp.MustCompile("^Bearer (.*)$") tokenMatch := bearerExp.FindStringSubmatch(authorizationHeader) - if tokenMatch == nil || len(tokenMatch) < 2 { + if len(tokenMatch) < 2 { return mo.None[User](), NewUserErrorWithCode(http.StatusUnauthorized, "Malformed Authorization header") } token := tokenMatch[1] diff --git a/front.go b/front.go index 1fad342..274a725 100644 --- a/front.go +++ b/front.go @@ -1335,7 +1335,8 @@ func frontChallenge(app *App, action string) func(c echo.Context) error { var playerName string var userUUID *string - if action == ChallengeActionRegister { + switch action { + case ChallengeActionRegister: if useIDToken { provider, _, claims, err := app.getIDTokenCookie(&c) if err != nil { @@ -1358,7 +1359,7 @@ func frontChallenge(app *App, action string) func(c echo.Context) error { } else { playerName = c.QueryParam("playerName") } - } else if action == ChallengeActionCreatePlayer { + case ChallengeActionCreatePlayer: playerName = c.QueryParam("playerName") userUUID = Ptr(c.QueryParam("userUuid")) } diff --git a/main.go b/main.go index 8689e7b..c985ade 100644 --- a/main.go +++ b/main.go @@ -439,7 +439,7 @@ func setup(config *Config) *App { locales := map[language.Tag]*gotext.Locale{} localeTags := make([]language.Tag, 0) localesPath := path.Join(config.DataDirectory, "locales") - langPaths, err := filepath.Glob(path.Join(localesPath, "*")) + langPaths := Unwrap(filepath.Glob(path.Join(localesPath, "*"))) defaultLang := "en-US" // TODO config option? var defaultLocale *gotext.Locale for _, lang_path := range langPaths { diff --git a/model.go b/model.go index d23c4b2..266bf9d 100644 --- a/model.go +++ b/model.go @@ -402,7 +402,7 @@ func (app *App) GetClient(accessToken string, stalePolicy StaleTokenPolicy) *Cli } var client Client - result := app.DB.Preload("User").Preload("Player").First(&client, "uuid = ?", claims.RegisteredClaims.Subject) + result := app.DB.Preload("User").Preload("Player").First(&client, "uuid = ?", claims.Subject) if result.Error != nil { return nil } diff --git a/player.go b/player.go index 3d5dadf..25bb50d 100644 --- a/player.go +++ b/player.go @@ -30,9 +30,10 @@ func (app *App) getTexture( if textureReader != nil || textureURL != nil { allowed := false - if textureType == TextureTypeSkin { + switch textureType { + case TextureTypeSkin: allowed = app.Config.AllowSkins - } else if textureType == TextureTypeCape { + case TextureTypeCape: allowed = app.Config.AllowCapes } if !allowed && !callerIsAdmin { diff --git a/services.go b/services.go index 84851a3..3bb90a2 100644 --- a/services.go +++ b/services.go @@ -34,7 +34,7 @@ func withBearerAuthentication(app *App, f func(c echo.Context, user *User, playe } accessTokenMatch := bearerExp.FindStringSubmatch(authorizationHeader) - if accessTokenMatch == nil || len(accessTokenMatch) < 2 { + if len(accessTokenMatch) < 2 { return &YggdrasilError{Code: http.StatusUnauthorized} } accessToken := accessTokenMatch[1] @@ -114,7 +114,7 @@ func getServicesProfile(app *App, player *Player) (ServicesProfile, error) { return nil } - var skins []ServicesProfileSkin = []ServicesProfileSkin{} + skins := []ServicesProfileSkin{} if skin := getServicesProfileSkin(); skin != nil { skins = []ServicesProfileSkin{*skin} }