github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/staticcheck/sa4030/testdata/src/example.com/CheckIneffectiveRandInt/CheckIneffectiveRandInt.go (about) 1 package pkg 2 3 import "math/rand" 4 5 func fn() { 6 type T struct { 7 rng rand.Rand 8 } 9 10 _ = rand.Intn(1) //@ diag(re`rand\.Intn\(n\) generates.+rand\.Intn\(1\) therefore`) 11 _ = rand.Int63n(1) //@ diag(re`rand\.Int63n\(n\) generates.+rand\.Int63n\(1\) therefore`) 12 var t T 13 _ = t.rng.Intn(1) //@ diag(re`\(\*math/rand\.Rand\)\.Intn\(n\) generates.+t\.rng\.Intn\(1\) therefore`) 14 15 _ = rand.Intn(2) 16 }