diff --git a/cmd/flac2wav/flac2wav.go b/cmd/flac2wav/flac2wav.go index c8596ab..4b76460 100644 --- a/cmd/flac2wav/flac2wav.go +++ b/cmd/flac2wav/flac2wav.go @@ -77,7 +77,7 @@ func flac2wav(path string) error { // Decode FLAC audio samples. frame, err := stream.ParseNext() if err != nil { - if err == io.EOF { + if errors.Cause(err) == io.EOF { break } return errors.WithStack(err) diff --git a/example_test.go b/example_test.go index 757110f..cd74c87 100644 --- a/example_test.go +++ b/example_test.go @@ -46,7 +46,7 @@ func ExampleOpen() { // subframe per audio channel. frame, err := stream.ParseNext() if err != nil { - if err == io.EOF { + if errors.Cause(err) == io.EOF { break } log.Fatal(err) diff --git a/flac.go b/flac.go index 8426cc4..3c32e91 100644 --- a/flac.go +++ b/flac.go @@ -69,7 +69,7 @@ func New(r io.Reader) (stream *Stream, err error) { // Skip the remaining metadata blocks. for !isLast { block, err := meta.New(br) - if err != nil && err != meta.ErrReservedType { + if err != nil && errors.Cause(err) != meta.ErrReservedType { return stream, errors.WithStack(err) } if err = block.Skip(); err != nil { @@ -171,7 +171,7 @@ func Parse(r io.Reader) (stream *Stream, err error) { for !isLast { block, err := meta.Parse(br) if err != nil { - if err != meta.ErrReservedType { + if errors.Cause(err) != meta.ErrReservedType { return stream, errors.WithStack(err) } // Skip the body of unknown (reserved) metadata blocks, as stated by diff --git a/frame/frame.go b/frame/frame.go index 7e136ab..7462e22 100644 --- a/frame/frame.go +++ b/frame/frame.go @@ -590,7 +590,7 @@ func (frame *Frame) correlate() { // unexpected returns io.ErrUnexpectedEOF if err is io.EOF, and returns err // otherwise. func unexpected(err error) error { - if err == io.EOF { + if errors.Cause(err) == io.EOF { return io.ErrUnexpectedEOF } return errors.WithStack(err) diff --git a/frame/frame_test.go b/frame/frame_test.go index 65af833..b47d903 100644 --- a/frame/frame_test.go +++ b/frame/frame_test.go @@ -40,7 +40,7 @@ func TestFrameHash(t *testing.T) { for frameNum := 0; ; frameNum++ { frame, err := stream.ParseNext() if err != nil { - if err == io.EOF { + if errors.Cause(err) == io.EOF { break } t.Errorf("i=%d, frameNum=%d: error while parsing frame; %v", i, frameNum, err) @@ -72,7 +72,7 @@ func BenchmarkFrameParse(b *testing.B) { for { _, err := stream.ParseNext() if err != nil { - if err == io.EOF { + if errors.Cause(err) == io.EOF { break } stream.Close() @@ -98,7 +98,7 @@ func BenchmarkFrameHash(b *testing.B) { for { frame, err := stream.ParseNext() if err != nil { - if err == io.EOF { + if errors.Cause(err) == io.EOF { break } stream.Close() diff --git a/frame/utf8.go b/frame/utf8.go index 3dfc535..0a1768a 100644 --- a/frame/utf8.go +++ b/frame/utf8.go @@ -123,7 +123,7 @@ func decodeUTF8Int(r io.Reader) (n uint64, err error) { n <<= 6 c, err := readByte(r) if err != nil { - if err == io.EOF { + if errors.Cause(err) == io.EOF { return 0, io.ErrUnexpectedEOF } return 0, errors.WithStack(err) diff --git a/internal/bits/reader_test.go b/internal/bits/reader_test.go index e52098d..ce21ab8 100644 --- a/internal/bits/reader_test.go +++ b/internal/bits/reader_test.go @@ -622,7 +622,8 @@ func TestReadEOF(t *testing.T) { for i, test := range tests { r := NewReader(bytes.NewReader(test.data)) - if _, err := r.Read(test.n); err != test.err { + _, e := r.Read(test.n) + if err := errors.Cause(e); err != test.err { t.Errorf("i=%d; Reading %d from %v, expected err=%s, got err=%s", i, test.n, test.data, test.err, err) } } diff --git a/meta/meta.go b/meta/meta.go index 3954ada..4efe12f 100644 --- a/meta/meta.go +++ b/meta/meta.go @@ -203,7 +203,7 @@ func (t Type) String() string { // unexpected returns io.ErrUnexpectedEOF if err is io.EOF, and returns err // otherwise. func unexpected(err error) error { - if err == io.EOF { + if errors.Cause(err) == io.EOF { return io.ErrUnexpectedEOF } return errors.WithStack(err)