github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/staticcheck/sa1031/testdata/src/example.com/CheckEncodingHex/CheckEncodingHex.go (about) 1 package pkg 2 3 import ( 4 "encoding/hex" 5 ) 6 7 func fn() { 8 hex.Encode(nil, nil) 9 hex.Encode(make([]byte, 0), nil) 10 sliceA := make([]byte, 8) 11 sliceB := make([]byte, 8) 12 hex.Encode(sliceA, sliceB) 13 hex.Encode(sliceA, sliceA) //@ diag(`overlapping dst and src`) 14 hex.Encode(sliceA[1:], sliceA[2:]) 15 hex.Encode(sliceA[1:], sliceA[1:]) //@ diag(`overlapping dst and src`) 16 sliceC := sliceA 17 hex.Encode(sliceA, sliceC) //@ diag(`overlapping dst and src`) 18 if true { 19 hex.Encode(sliceA, sliceC) //@ diag(`overlapping dst and src`) 20 } 21 sliceD := sliceA[1:] 22 sliceE := sliceA[1:] 23 if true { 24 hex.Encode(sliceD, sliceE) //@ diag(`overlapping dst and src`) 25 } 26 var b bool 27 if !b && true { 28 hex.Encode(sliceD, sliceE) //@ diag(`overlapping dst and src`) 29 } 30 } 31 32 func fooSigmaA(a *[4]byte) { 33 low := 2 34 x := a[low:] 35 36 if true { 37 y := a[low:] 38 hex.Encode(x, y) //@ diag(`overlapping dst and src`) 39 } 40 } 41 42 func fooSigmaB(a *[4]byte) { 43 x := a[:] 44 45 if true { 46 y := a[:] 47 hex.Encode(x, y) //@ diag(`overlapping dst and src`) 48 } 49 }