Skip to content

Commit 48bea97

Browse files
committed
fix: correct struct field alignment and spelling
Fix remaining golangci-lint issues: Field Alignment: - Reorder Cache struct: pointers first (store, logger), then map, then RWMutex - This ordering reduces struct size from 48 to 24 pointer bytes - Aligns with Go's memory layout optimization requirements Spelling: - Fix 'cancelled' → 'canceled' in test comment - Maintains consistent American English spelling throughout codebase Both issues were caught by golangci-lint v1.64 fieldalignment and misspell linters.
1 parent 83f6bc2 commit 48bea97

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

cache/cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import (
1010

1111
// Cache provides a high-performance in-memory cache
1212
type Cache struct {
13-
mu sync.RWMutex
14-
ttls map[string]time.Time
1513
store *ristretto.Cache[string, any]
1614
logger *zap.Logger
15+
ttls map[string]time.Time
16+
mu sync.RWMutex
1717
}
1818

1919
// Config holds cache configuration

server_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -338,26 +338,26 @@ func TestServer_Shutdown(t *testing.T) {
338338
}
339339
}
340340

341-
srv, err := New(cfg, logger)
342-
if err != nil {
343-
t.Fatalf("failed to create server: %v", err)
344-
}
345-
346-
var ctx context.Context
347-
var cancel context.CancelFunc
348-
349-
if tt.withTimeout {
350-
// Create a context that's already cancelled to simulate timeout
351-
ctx, cancel = context.WithCancel(context.Background())
352-
cancel()
353-
} else {
354-
ctx = context.Background()
355-
}
356-
357-
err = srv.Shutdown(ctx)
358-
if (err != nil) != tt.wantErr {
359-
t.Errorf("Shutdown() error = %v, wantErr %v", err, tt.wantErr)
360-
}
341+
srv, err := New(cfg, logger)
342+
if err != nil {
343+
t.Fatalf("failed to create server: %v", err)
344+
}
345+
346+
var ctx context.Context
347+
var cancel context.CancelFunc
348+
349+
if tt.withTimeout {
350+
// Create a context that's already canceled to simulate timeout
351+
ctx, cancel = context.WithCancel(context.Background())
352+
cancel()
353+
} else {
354+
ctx = context.Background()
355+
}
356+
357+
err = srv.Shutdown(ctx)
358+
if (err != nil) != tt.wantErr {
359+
t.Errorf("Shutdown() error = %v, wantErr %v", err, tt.wantErr)
360+
}
361361
})
362362
}
363363
}

0 commit comments

Comments
 (0)