Skip to content

Commit

Permalink
Change to use slices.Equal
Browse files Browse the repository at this point in the history
  • Loading branch information
sorairolake committed Apr 5, 2024
1 parent 734cf73 commit 94dd290
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lzip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package lzip_test

import (
"slices"
"testing"

"github.com/sorairolake/lzip-go"
Expand All @@ -29,8 +30,9 @@ func TestTrailerSize(t *testing.T) {
func TestMagic(t *testing.T) {
t.Parallel()

if magic := lzip.Magic; magic != "LZIP" {
t.Errorf("expected magic number `%v`, got `%v`", "LZIP", magic)
expected := [lzip.MagicSize]byte{0x4c, 0x5a, 0x49, 0x50}
if !slices.Equal([]byte(lzip.Magic), expected[:]) {
t.Error("unexpected magic number")
}
}

Expand Down
3 changes: 1 addition & 2 deletions reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"errors"
"hash/crc32"
"io"
"reflect"
"slices"

"github.com/ulikunitz/xz/lzma"
Expand All @@ -33,7 +32,7 @@ func NewReader(r io.Reader) (*Reader, error) {
return nil, err
}

if !reflect.DeepEqual(header[:magicSize], []byte(magic)) {
if !slices.Equal(header[:magicSize], []byte(magic)) {
return nil, ErrInvalidMagic
}

Expand Down

0 comments on commit 94dd290

Please sign in to comment.