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:
2026-04-21 21:15:59 -04:00
parent ad27902790
commit e389df92c3
23 changed files with 85 additions and 75 deletions
+10 -10
View File
@@ -257,8 +257,8 @@ func (h *DeviceHandler) ListDevices(c *echo.Context) error {
ID: device.ID.Bytes,
DeviceName: device.DeviceName,
DeviceType: device.DeviceType,
LastSync: (*time.Time)(&device.LastSync.Time),
LastSeen: (*time.Time)(&device.LastSeen.Time),
LastSync: &device.LastSync.Time,
LastSeen: &device.LastSeen.Time,
SyncEnabled: syncEnabled,
AutoSync: autoSync,
SyncFrequency: syncFreq,
@@ -301,8 +301,8 @@ func (h *DeviceHandler) GetDevicesData(c *echo.Context) ([]DeviceInfo, error) {
ID: device.ID.Bytes,
DeviceName: device.DeviceName,
DeviceType: device.DeviceType,
LastSync: (*time.Time)(&device.LastSync.Time),
LastSeen: (*time.Time)(&device.LastSeen.Time),
LastSync: &device.LastSync.Time,
LastSeen: &device.LastSeen.Time,
SyncEnabled: syncEnabled,
AutoSync: autoSync,
SyncFrequency: syncFreq,
@@ -353,8 +353,8 @@ func (h *DeviceHandler) GetDevice(c *echo.Context) error {
ID: device.ID.Bytes,
DeviceName: device.DeviceName,
DeviceType: device.DeviceType,
LastSync: (*time.Time)(&device.LastSync.Time),
LastSeen: (*time.Time)(&device.LastSeen.Time),
LastSync: &device.LastSync.Time,
LastSeen: &device.LastSeen.Time,
SyncEnabled: syncEnabled,
AutoSync: autoSync,
SyncFrequency: syncFreq,
@@ -447,8 +447,8 @@ func (h *DeviceHandler) UpdateDevice(c *echo.Context) error {
ID: updatedDevice.ID.Bytes,
DeviceName: updatedDevice.DeviceName,
DeviceType: updatedDevice.DeviceType,
LastSync: (*time.Time)(&updatedDevice.LastSync.Time),
LastSeen: (*time.Time)(&updatedDevice.LastSeen.Time),
LastSync: &updatedDevice.LastSync.Time,
LastSeen: &updatedDevice.LastSeen.Time,
SyncEnabled: syncEnabled,
AutoSync: autoSync,
SyncFrequency: syncFreq, // Now correctly returns the updated value
@@ -566,8 +566,8 @@ func (h *DeviceHandler) RegenerateDeviceToken(c *echo.Context) error {
ID: updatedDevice.ID.Bytes,
DeviceName: updatedDevice.DeviceName,
DeviceType: updatedDevice.DeviceType,
LastSync: (*time.Time)(&updatedDevice.LastSync.Time),
LastSeen: (*time.Time)(&updatedDevice.LastSeen.Time),
LastSync: &updatedDevice.LastSync.Time,
LastSeen: &updatedDevice.LastSeen.Time,
SyncEnabled: syncEnabled,
AutoSync: autoSync,
SyncFrequency: syncFreq,