refactor: remove unnecessary type conversions and handle ignored errors across codebase
Remove redundant type conversions that Go 1.26 makes unnecessary or that
were already no-ops:
- uuid.UUID(x.Bytes) → x.Bytes (uuid.UUID is [16]byte, same as pgtype UUID Bytes)
- pgtype.UUID{Bytes: [16]byte(u), Valid: true} → pgtype.UUID{Bytes: u, Valid: true}
- (*time.Time)(&x.Time) → &x.Time
- json.RawMessage(x) → x where x is already []byte
- []byte(stringVal) → stringVal where []byte is expected
- int()/int64()/byte() casts on values already of the target type
- Decompressor(fn) → fn (type is identical)
Handle previously ignored error returns:
- collections.go: check json.Unmarshal error in GetCollection
- conversion_service.go: check fileSize.Scan() error
- app_test.go: check app.Shutdown() error in benchmark
This commit is contained in:
@@ -424,8 +424,8 @@ func dbItemToSyncQueueItem(item database.SyncQueue) SyncQueueItem {
|
||||
Attempts: item.Attempts.Int32,
|
||||
MaxAttempts: item.MaxAttempts.Int32,
|
||||
Status: item.Status.String,
|
||||
ErrorMessage: (*string)(&item.ErrorMessage.String),
|
||||
ErrorMessage: &item.ErrorMessage.String,
|
||||
CreatedAt: item.CreatedAt.Time,
|
||||
ProcessedAt: (*time.Time)(&item.ProcessedAt.Time),
|
||||
ProcessedAt: &item.ProcessedAt.Time,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,10 +50,10 @@ func TestSyncStatusConstants(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPriorityConstants(t *testing.T) {
|
||||
assert.Equal(t, int(1), PriorityUserInitiated)
|
||||
assert.Equal(t, int(2), PriorityBookCompletion)
|
||||
assert.Equal(t, int(3), PriorityCriticalNote)
|
||||
assert.Equal(t, int(5), PriorityPageTurn)
|
||||
assert.Equal(t, int(7), PriorityCheckpoint)
|
||||
assert.Equal(t, int(10), PriorityBackgroundSync)
|
||||
assert.Equal(t, 1, PriorityUserInitiated)
|
||||
assert.Equal(t, 2, PriorityBookCompletion)
|
||||
assert.Equal(t, 3, PriorityCriticalNote)
|
||||
assert.Equal(t, 5, PriorityPageTurn)
|
||||
assert.Equal(t, 7, PriorityCheckpoint)
|
||||
assert.Equal(t, 10, PriorityBackgroundSync)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user