Skip to content

Commit

Permalink
fix: linter errors
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Sharov <kvendingoldo@yandex.ru>
  • Loading branch information
kvendingoldo committed Apr 28, 2024
1 parent 26606e8 commit 0d7a082
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/check/binary/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ func Check(filename string) (bool, error) {

const maxBytes = 8000 // Read up to 8000 bytes for analysis
bytes := make([]byte, maxBytes)
n, err := file.Read(bytes)
numberOfBytes, err := file.Read(bytes)
if err != nil {
return false, err
}

// Check for the presence of a null byte within the read bytes
for i := 0; i < n; i++ {
for i := 0; i < numberOfBytes; i++ {
if bytes[i] == 0 {
return true, nil // Null byte found, file is binary
}
}

// If no null byte found, check for a UTF-8 encoding signature (BOM)
if n >= 3 && bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF {
if numberOfBytes >= 3 && bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF {
return false, nil // UTF-8 encoded text file
}

Expand Down

0 comments on commit 0d7a082

Please sign in to comment.