Rule G115 warns if an integer overflow is not correctly checked before conversion. The check currently depends on the comparison order in the if statement:
This works:
if a < 0 || a > math.MaxUint8 {
return nil, err
}
b := uint8(a)
This does not work (i.e. the rule will warn of a potential overflow):
if 0 > a || a > math.MaxUint8 {
return nil, err
}
b := uint8(a)