-
Notifications
You must be signed in to change notification settings - Fork 17.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: flag: add support for int32 and uint32 options #26545
Comments
I've opened #26465 with the necessary implementation to add this to |
I'm not sure that the presence of |
@mvdan the reason for adding The main reason behinf all of this is to allow core libraries users to be able to produce homogeneous code that is less error prone in basic implementations. I do agree with the thought of having added |
You can already use So what's special about the |
Re the boilerplate conversions being less secure, it seems like #19624 would address the same security concerns much more generally. If you have specific examples of security bugs caused by conversions missing range checks, please mention them there! |
int/uint and int64/uint64 should be enough. We don't need the entire set. Note that if uint32 is a very important type (such as in this particular package) it's easy to build a uint32-accepting flag.Var, as @bcmills pointed out above. |
Currently many core libraries like
grpc
have configurable flags and options that are eitherint32
oruint32
, e.g.This forces the userland code for any configurable system to look something like this:
Such casting (and any other workaround) results in error prone implementations sometimes, since the error handling has to be done by the developer, which I'm not particulary against, but it's better if we could trust Go's core flag parsing library to support and validate this.
In this manner, we could allow the implementations to simply look like this:
I know it may look simple but
flag
already supports int, int64 and float64, so imho, adding this makes sense and allows for better looking and more secure code.The text was updated successfully, but these errors were encountered: