flag icon indicating copy to clipboard operation
flag copied to clipboard

Support for fixed-size integer types

Open safety-tom opened this issue 7 years ago • 0 comments

Hi there, would you accept a PR that adds support for fixed-size integer types?

Motivation

When using smaller types (e.g. int8, uint16) users need to manually cast int/uint and perform bounds checking.

Proposal

It would look like this:

flag.Uint16Var(&HTTPPort, "port", 8080, "A port")

This code would induce a panic (as opposed to a silent wrap-around):

f := 65536  // doesn't fit in a uint16
flag.Uint16Var(&HTTPPort, "port", 8080, "A port")

safety-tom avatar Apr 01 '19 05:04 safety-tom