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
+15 -15
View File
@@ -42,35 +42,35 @@ func newCopyReader(_ []byte, _ uint64, readers []io.ReadCloser) (io.ReadCloser,
//nolint:gochecknoinits
func init() {
// Copy
RegisterDecompressor([]byte{0x00}, Decompressor(newCopyReader))
RegisterDecompressor([]byte{0x00}, newCopyReader)
// Delta
RegisterDecompressor([]byte{0x03}, Decompressor(delta.NewReader))
RegisterDecompressor([]byte{0x03}, delta.NewReader)
// LZMA
RegisterDecompressor([]byte{0x03, 0x01, 0x01}, Decompressor(lzma.NewReader))
RegisterDecompressor([]byte{0x03, 0x01, 0x01}, lzma.NewReader)
// BCJ
RegisterDecompressor([]byte{0x03, 0x03, 0x01, 0x03}, Decompressor(bra.NewBCJReader))
RegisterDecompressor([]byte{0x03, 0x03, 0x01, 0x03}, bra.NewBCJReader)
// BCJ2
RegisterDecompressor([]byte{0x03, 0x03, 0x01, 0x1b}, Decompressor(bcj2.NewReader))
RegisterDecompressor([]byte{0x03, 0x03, 0x01, 0x1b}, bcj2.NewReader)
// PPC
RegisterDecompressor([]byte{0x03, 0x03, 0x02, 0x05}, Decompressor(bra.NewPPCReader))
RegisterDecompressor([]byte{0x03, 0x03, 0x02, 0x05}, bra.NewPPCReader)
// ARM
RegisterDecompressor([]byte{0x03, 0x03, 0x05, 0x01}, Decompressor(bra.NewARMReader))
RegisterDecompressor([]byte{0x03, 0x03, 0x05, 0x01}, bra.NewARMReader)
// SPARC
RegisterDecompressor([]byte{0x03, 0x03, 0x08, 0x05}, Decompressor(bra.NewSPARCReader))
RegisterDecompressor([]byte{0x03, 0x03, 0x08, 0x05}, bra.NewSPARCReader)
// Deflate
RegisterDecompressor([]byte{0x04, 0x01, 0x08}, Decompressor(deflate.NewReader))
RegisterDecompressor([]byte{0x04, 0x01, 0x08}, deflate.NewReader)
// Bzip2
RegisterDecompressor([]byte{0x04, 0x02, 0x02}, Decompressor(bzip2.NewReader))
RegisterDecompressor([]byte{0x04, 0x02, 0x02}, bzip2.NewReader)
// Zstandard
RegisterDecompressor([]byte{0x04, 0xf7, 0x11, 0x01}, Decompressor(zstd.NewReader))
RegisterDecompressor([]byte{0x04, 0xf7, 0x11, 0x01}, zstd.NewReader)
// Brotli
RegisterDecompressor([]byte{0x04, 0xf7, 0x11, 0x02}, Decompressor(brotli.NewReader))
RegisterDecompressor([]byte{0x04, 0xf7, 0x11, 0x02}, brotli.NewReader)
// LZ4
RegisterDecompressor([]byte{0x04, 0xf7, 0x11, 0x04}, Decompressor(lz4.NewReader))
RegisterDecompressor([]byte{0x04, 0xf7, 0x11, 0x04}, lz4.NewReader)
// AES-CBC-256 & SHA-256
RegisterDecompressor([]byte{0x06, 0xf1, 0x07, 0x01}, Decompressor(aes7z.NewReader))
RegisterDecompressor([]byte{0x06, 0xf1, 0x07, 0x01}, aes7z.NewReader)
// LZMA2
RegisterDecompressor([]byte{0x21}, Decompressor(lzma2.NewReader))
RegisterDecompressor([]byte{0x21}, lzma2.NewReader)
}
// RegisterDecompressor allows custom decompressors for a specified method ID.