You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/vet: warn about string(int) type conversions #32479
#3939 proposes removing the explicit type conversion string(i) where i has an integer type other than rune. That is a backward incompatible change, so we cannot make it until we can count on having modules everywhere, with the support modules provide for determining the version of the language to use to compile code.
There is a step we can take today, which is to change go vet to report conversions of integer types other than rune to string. If we think that removing this feature from the language is a good idea, then a vet check for it is a good idea, and it is one that we can implement today.
Well string(rune(b)) would be a better alternative because you wouldn't then have to allocate a byte slice but it would still be a nuisance to have to update all my code to use this workaround :(
Reacted by Liam Breck, Simon Law, Saeed Rasooli, Filippo Valsorda and Victor Manuel Lagunas Franco
Activity
agnivade commentedon Jun 8, 2019
@alandonovan @mvdan
networkimprov commentedon Jun 8, 2019
Pls also permit
string(b)where b is abyteoruint8.mvdan commentedon Jun 24, 2019
This seems fine to me. The warning should probably point the user in the right direction.
alanfo commentedon Jun 27, 2019
I think this is essential if this proposal (and eventually #3939) is to be adopted.
The
string(byte)conversion, when you're dealing with ASCII characters only, is probably used at least as often asstring(rune)in my experience.dolmen commentedon Jul 2, 2019
@networkimprov @alanfo You will still be able to use
string([]byte{b}).networkimprov commentedon Jul 2, 2019
That would be a surprising requirement. And allocates a byte slice for a single statement?
alanfo commentedon Jul 2, 2019
@dolmen
Well
string(rune(b))would be a better alternative because you wouldn't then have to allocate a byte slice but it would still be a nuisance to have to update all my code to use this workaround :(144 remaining items
Change string cast of int value to rune cast
Convert id to string using strconv.Itoa (duosecurity#22)
eliminate genblocks compile warning
eliminate genblocks compile warning
Convert int to string using rune()
Convert int to string using rune()
Convert int to string using rune()
using Itoa(int) rather than string(int) to compatible with new golang… (
Fix string conversion error
fix: go vet 1.15 warnings (#385)