From 4efcc770ac76198442ef9b976806eee55f21eb08 Mon Sep 17 00:00:00 2001 From: Vladimir Zagainov Date: Sat, 30 May 2026 20:00:54 +0300 Subject: [PATCH] fix: format all Go files with gofmt - Fix alignment in struct fields (sessionProfileResponse, textureInfo, Handler) - Align struct field values in internal/templates/templates.go, internal/api/api.go --- internal/admin/admin.go | 2 +- internal/api/api.go | 4 ++-- internal/auth/auth.go | 16 ++++++++-------- internal/cas/cas.go | 24 ++++++++++++------------ internal/cas/cas_test.go | 8 ++++---- internal/config/config.go | 12 ++++++------ internal/middleware/middleware.go | 10 +++++----- internal/templates/templates.go | 8 ++++---- 8 files changed, 42 insertions(+), 42 deletions(-) diff --git a/internal/admin/admin.go b/internal/admin/admin.go index 44d349b..d74a7e9 100644 --- a/internal/admin/admin.go +++ b/internal/admin/admin.go @@ -15,10 +15,10 @@ import ( "strconv" "strings" - "gitea.mrixs.me/Mrixs/MrixsCraft-server/pkg/utils" "gitea.mrixs.me/Mrixs/MrixsCraft-server/internal/auth" "gitea.mrixs.me/Mrixs/MrixsCraft-server/internal/config" "gitea.mrixs.me/Mrixs/MrixsCraft-server/internal/database" + "gitea.mrixs.me/Mrixs/MrixsCraft-server/pkg/utils" ) // Handler serves admin endpoints. diff --git a/internal/api/api.go b/internal/api/api.go index eea3e1c..887913a 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -122,8 +122,8 @@ type textureInfo struct { // Mojang session server profile response (for game client). type sessionProfileResponse struct { - ID string `json:"id"` - Name string `json:"name"` + ID string `json:"id"` + Name string `json:"name"` Props []sessionProfileProp `json:"properties"` } diff --git a/internal/auth/auth.go b/internal/auth/auth.go index a8bb4bf..b89cc65 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -52,11 +52,11 @@ type authenticateRequest struct { } type authenticateResponse struct { - AccessToken string `json:"accessToken"` - ClientToken string `json:"clientToken"` - AvailableProfile []profile `json:"availableProfiles"` - SelectedProfile *profile `json:"selectedProfile,omitempty"` - User *userProperties `json:"user,omitempty"` + AccessToken string `json:"accessToken"` + ClientToken string `json:"clientToken"` + AvailableProfile []profile `json:"availableProfiles"` + SelectedProfile *profile `json:"selectedProfile,omitempty"` + User *userProperties `json:"user,omitempty"` } type profile struct { @@ -65,7 +65,7 @@ type profile struct { } type userProperties struct { - ID string `json:"id"` + ID string `json:"id"` Properties []property `json:"properties"` } @@ -92,8 +92,8 @@ type errorResponse struct { // Session server types (Mojang-compatible). type sessionProfileResponse struct { - ID string `json:"id"` - Name string `json:"name"` + ID string `json:"id"` + Name string `json:"name"` Props []sessionProfileProp `json:"properties"` } diff --git a/internal/cas/cas.go b/internal/cas/cas.go index 289a293..d993ed1 100644 --- a/internal/cas/cas.go +++ b/internal/cas/cas.go @@ -20,18 +20,18 @@ import ( // mimeByExtension maps common file extensions to MIME types for CAS serving. var mimeByExtension = map[string]string{ - ".jar": "application/java-archive", - ".json": "application/json", - ".png": "image/png", - ".zip": "application/zip", - ".toml": "application/toml", - ".cfg": "text/plain", - ".conf": "text/plain", - ".txt": "text/plain", - ".log": "text/plain", - ".xml": "application/xml", - ".yml": "application/x-yaml", - ".yaml": "application/x-yaml", + ".jar": "application/java-archive", + ".json": "application/json", + ".png": "image/png", + ".zip": "application/zip", + ".toml": "application/toml", + ".cfg": "text/plain", + ".conf": "text/plain", + ".txt": "text/plain", + ".log": "text/plain", + ".xml": "application/xml", + ".yml": "application/x-yaml", + ".yaml": "application/x-yaml", ".properties": "text/plain", } diff --git a/internal/cas/cas_test.go b/internal/cas/cas_test.go index ac4dedd..02b2993 100644 --- a/internal/cas/cas_test.go +++ b/internal/cas/cas_test.go @@ -14,10 +14,10 @@ func TestIsValidHash(t *testing.T) { {"a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2", true}, {"0000000000000000000000000000000000000000", true}, {"ffffffffffffffffffffffffffffffffffffffff", true}, - {"A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2", false}, // uppercase - {"g1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2", false}, // non-hex - {"a1b2c3d4e5f6", false}, // too short - {"", false}, // empty + {"A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2", false}, // uppercase + {"g1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2", false}, // non-hex + {"a1b2c3d4e5f6", false}, // too short + {"", false}, // empty {"a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3", false}, // too long (41) } for _, tt := range tests { diff --git a/internal/config/config.go b/internal/config/config.go index 957679f..df3532f 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -35,13 +35,13 @@ func Load() (*Config, error) { } cfg := &Config{ - Port: port, + Port: port, DatabaseURL: getEnv("DATABASE_URL", ""), - CASDir: getEnv("CAS_DIR", "/var/www/cdn/files"), - SkinsDir: getEnv("SKINS_DIR", "/var/www/cdn/skins"), - JWTSecret: getEnv("JWT_SECRET", ""), - CIsecret: getEnv("CI_SECRET", ""), - BaseURL: getEnv("BASE_URL", "https://minecraft.mrixs.me"), + CASDir: getEnv("CAS_DIR", "/var/www/cdn/files"), + SkinsDir: getEnv("SKINS_DIR", "/var/www/cdn/skins"), + JWTSecret: getEnv("JWT_SECRET", ""), + CIsecret: getEnv("CI_SECRET", ""), + BaseURL: getEnv("BASE_URL", "https://minecraft.mrixs.me"), } if cfg.DatabaseURL == "" { diff --git a/internal/middleware/middleware.go b/internal/middleware/middleware.go index 03ba88e..af32fe1 100644 --- a/internal/middleware/middleware.go +++ b/internal/middleware/middleware.go @@ -71,9 +71,9 @@ func (w *statusWriter) WriteHeader(status int) { type RateLimiter struct { mu sync.Mutex clients map[string]*bucket - rate int // tokens per interval + rate int // tokens per interval interval time.Duration - burst int // max bucket size + burst int // max bucket size } type bucket struct { @@ -85,10 +85,10 @@ type bucket struct { // with a maximum burst of `burst`. func NewRateLimiter(rate int, interval time.Duration, burst int) *RateLimiter { rl := &RateLimiter{ - clients: make(map[string]*bucket), - rate: rate, + clients: make(map[string]*bucket), + rate: rate, interval: interval, - burst: burst, + burst: burst, } // Periodically clean up stale entries. go rl.cleanup() diff --git a/internal/templates/templates.go b/internal/templates/templates.go index 15a6fc9..59aee37 100644 --- a/internal/templates/templates.go +++ b/internal/templates/templates.go @@ -19,10 +19,10 @@ type pageData struct { // Handler serves template-rendered pages. type Handler struct { - db *database.DB - cfg *config.Config - tmpl *template.Template - loaded bool + db *database.DB + cfg *config.Config + tmpl *template.Template + loaded bool } // NewHandler creates a new templates handler and parses on-disk templates.