Skip to content

Commit

Permalink
add compile time check
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrav committed Jan 19, 2024
1 parent 5fe1d72 commit 28efb74
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/sources/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sources

import (
"sync"
"unsafe"

"google.golang.org/protobuf/types/known/anypb"

Expand All @@ -11,6 +12,14 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/sourcespb"
)

const (
// Convert to int64 to handle potential negative size differences correctly.
sizeofChunk = int64(unsafe.Sizeof(Chunk{}))
maxChunkSize = 80
)

var _ = [1]bool{}[sizeofChunk-maxChunkSize]

Check failure on line 21 in pkg/sources/sources.go

View workflow job for this annotation

GitHub Actions / lint

invalid argument: index sizeofChunk - maxChunkSize (constant -3 of type int64) must not be negative (typecheck)

type (
SourceID int64
JobID int64
Expand Down

0 comments on commit 28efb74

Please sign in to comment.