Whenever I cast an int to a uint to use it to shift bits it'll give me a false positive. As an example I used the following code.
package main
import (
"time"
"fmt"
)
func main() {
test := []string{"1", "2", "3"}
for i, s := range test {
time.Sleep(time.Duration(1 << uint(i) * time.Second))
fmt.Printf("%d %s\n", (1 << uint(i)), s)
}
}
unconvert will simply tell me that this conversion is useless
.../unconvert/unconvert.go:11:27: unnecessary conversion
While if I remove the uint() around the variable the compiler refuses to compile it
.../unconvert/unconvert.go:12:33: invalid operation: shift count i (variable of type int) must be unsigned integer
Whenever I cast an int to a uint to use it to shift bits it'll give me a false positive. As an example I used the following code.
unconvert will simply tell me that this conversion is useless
.../unconvert/unconvert.go:11:27: unnecessary conversion
While if I remove the uint() around the variable the compiler refuses to compile it.../unconvert/unconvert.go:12:33: invalid operation: shift count i (variable of type int) must be unsigned integer