yoheimuta / go-protoparser

Yet another Go package which parses a Protocol Buffer file (proto2+proto3)
MIT License
166 stars 20 forks source link

Is possible that FieldNumber is not number? #70

Open wirekang opened 2 years ago

wirekang commented 2 years ago

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

yoheimuta commented 2 years ago

@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.