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