go-protoparser icon indicating copy to clipboard operation
go-protoparser copied to clipboard

Is possible that FieldNumber is not number?

Open wirekang opened this issue 3 years ago • 1 comments

Why FieldNumber has string type? Can I expect strconv.AtoI always return nil error for FieldNumber?

wirekang avatar Feb 25 '22 09:02 wirekang

@wirekang No, FieldNumber must be a number, according to the spec.

Practically, Go's int type can cover the sensible FieldNumber value.

However, each size limit is different. Let's say users give 170141183460469231731687303715884105727 as FieldNumber. strconv.Atoi returns an error, but it's legit in Protocol Buffer.

  • ref. https://go.dev/play/p/4d4ybhrwbRk

yoheimuta avatar Feb 26 '22 02:02 yoheimuta