diff --git a/syft/internal/unionreader/lazy_union_reader.go b/syft/internal/unionreader/lazy_union_reader.go index f81991348..546306fd2 100644 --- a/syft/internal/unionreader/lazy_union_reader.go +++ b/syft/internal/unionreader/lazy_union_reader.go @@ -127,9 +127,9 @@ func min(ints ...int64) int64 { return minSeeen } -func newLazyUnionReader(readCloser io.ReadCloser) (UnionReader, error) { +func newLazyUnionReader(readCloser io.ReadCloser) UnionReader { return &lazyUnionReader{ rc: readCloser, mu: sync.Mutex{}, - }, nil + } } diff --git a/syft/internal/unionreader/lazy_union_reader_test.go b/syft/internal/unionreader/lazy_union_reader_test.go index bd82d0b35..a7ff014ba 100644 --- a/syft/internal/unionreader/lazy_union_reader_test.go +++ b/syft/internal/unionreader/lazy_union_reader_test.go @@ -26,16 +26,14 @@ func Test_lazyUnionReader_Close(t *testing.T) { false, r, } - subject, err := newLazyUnionReader(sc) - require.NoError(t, err) + subject := newLazyUnionReader(sc) require.NoError(t, subject.Close()) assert.True(t, sc.closed) } func Test_lazyUnionReader_ReadAll(t *testing.T) { rc := io.NopCloser(strings.NewReader("some data")) - subject, err := newLazyUnionReader(rc) - require.NoError(t, err) + subject := newLazyUnionReader(rc) b, err := io.ReadAll(subject) require.NoError(t, err) @@ -45,8 +43,7 @@ func Test_lazyUnionReader_ReadAll(t *testing.T) { func Test_lazyUnionReader_RepeatedlyRead(t *testing.T) { data := "some data for our reader that we need to read!" rc := io.NopCloser(strings.NewReader(data)) - subject, err := newLazyUnionReader(rc) - require.NoError(t, err) + subject := newLazyUnionReader(rc) var readErr error var readResult []byte for readErr == nil { @@ -119,8 +116,7 @@ func Test_lazyUnionReader_ReadAt(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { rc := io.NopCloser(strings.NewReader("0123456789abcdef")) - subject, err := newLazyUnionReader(rc) - require.NoError(t, err) + subject := newLazyUnionReader(rc) n, err := subject.ReadAt(tt.dst, tt.off) assert.Equal(t, tt.wantN, n) assert.Equal(t, string(tt.wantBytes), string(tt.dst[:tt.wantN])) @@ -195,8 +191,7 @@ func Test_lazyUnionReader_Seek(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { rc := io.NopCloser(bytes.NewReader(data)) - subject, err := newLazyUnionReader(rc) - require.NoError(t, err) + subject := newLazyUnionReader(rc) var readSeekErr error var readResult []byte for _, c := range tt.commands { diff --git a/syft/internal/unionreader/union_reader.go b/syft/internal/unionreader/union_reader.go index 9dc7a7b74..7fa64cfe1 100644 --- a/syft/internal/unionreader/union_reader.go +++ b/syft/internal/unionreader/union_reader.go @@ -41,5 +41,5 @@ func GetUnionReader(readerCloser io.ReadCloser) (UnionReader, error) { if ok { return reader, nil } - return newLazyUnionReader(readerCloser) + return newLazyUnionReader(readerCloser), nil }