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:
@@ -194,7 +194,7 @@ func (h *OPDSHandler) GetDeviceCatalog(c *echo.Context) error {
|
||||
if err == nil {
|
||||
collectionScheme := fmt.Sprintf("%s/collections", baseURL)
|
||||
for _, col := range collections {
|
||||
if col.UserID.Valid && uuid.UUID(col.UserID.Bytes) == userUUID {
|
||||
if col.UserID.Valid && col.UserID.Bytes == userUUID {
|
||||
entry.AddCategory(collectionScheme, col.Name)
|
||||
}
|
||||
}
|
||||
@@ -312,7 +312,7 @@ func (h *OPDSHandler) SearchDeviceCatalog(c *echo.Context) error {
|
||||
if err == nil {
|
||||
collectionScheme := fmt.Sprintf("%s/collections", baseURL)
|
||||
for _, col := range collections {
|
||||
if col.UserID.Valid && uuid.UUID(col.UserID.Bytes) == userUUID {
|
||||
if col.UserID.Valid && col.UserID.Bytes == userUUID {
|
||||
entry.AddCategory(collectionScheme, col.Name)
|
||||
}
|
||||
}
|
||||
@@ -367,7 +367,7 @@ func (h *OPDSHandler) DownloadBook(c *echo.Context) error {
|
||||
// Check if book is in visible library
|
||||
visible := false
|
||||
for _, lib := range libraries {
|
||||
if uuid.UUID(lib.ID.Bytes) == uuid.UUID(mediaItem.LibraryID.Bytes) {
|
||||
if lib.ID.Bytes == mediaItem.LibraryID.Bytes {
|
||||
visible = true
|
||||
break
|
||||
}
|
||||
@@ -514,7 +514,7 @@ func (h *OPDSHandler) GetCoverImage(c *echo.Context) error {
|
||||
// Check if book is in visible library
|
||||
visible := false
|
||||
for _, lib := range libraries {
|
||||
if uuid.UUID(lib.ID.Bytes) == uuid.UUID(mediaItem.LibraryID.Bytes) {
|
||||
if lib.ID.Bytes == mediaItem.LibraryID.Bytes {
|
||||
visible = true
|
||||
break
|
||||
}
|
||||
@@ -655,7 +655,7 @@ func (h *OPDSHandler) ListFormats(c *echo.Context) error {
|
||||
// Check if book is in visible library
|
||||
visible := false
|
||||
for _, lib := range libraries {
|
||||
if uuid.UUID(lib.ID.Bytes) == uuid.UUID(mediaItem.LibraryID.Bytes) {
|
||||
if lib.ID.Bytes == mediaItem.LibraryID.Bytes {
|
||||
visible = true
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user