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
Is your feature request related to a problem? Please describe.
In Golang UTF8 strings are not enforced. Thus, very often some kind of byte sequence is passed through all layers of an application until it finally fails because protobuf eventually checks for UTF-8. This library then returns errInvalidUTF8.
There seem to be 2 solutions to this problem:
Checking for UTF-8 on upper layers before passing string down.
This would degrade the happy-path unnecessarily and as a consequence is rarely done.
React upon the error.
Currently, this requires matching the error string. Which is neither idiomatic nor is there any test in this repo to ensure that the string stays the same.
Describe the solution you'd like
To enable errors.Is(err, encoding.ErrInvalidUTF8) I would propose to simply export the error type as well as an error instance while also introducing tests to ensure that said Is works.
Exporting might look like this: var ErrInvalidUTF8 = impl.ErrInvalidUTF8{}.
Describe alternatives you've considered
There would be a way to introduce a UTF8String - but this would make the library more non-idiomatic.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
In Golang UTF8 strings are not enforced. Thus, very often some kind of byte sequence is passed through all layers of an application until it finally fails because protobuf eventually checks for UTF-8. This library then returns
errInvalidUTF8
.There seem to be 2 solutions to this problem:
Checking for UTF-8 on upper layers before passing string down.
This would degrade the happy-path unnecessarily and as a consequence is rarely done.
React upon the error.
Currently, this requires matching the error string. Which is neither idiomatic nor is there any test in this repo to ensure that the string stays the same.
Describe the solution you'd like
To enable
errors.Is(err, encoding.ErrInvalidUTF8)
I would propose to simply export the error type as well as an error instance while also introducing tests to ensure that saidIs
works.Exporting might look like this:
var ErrInvalidUTF8 = impl.ErrInvalidUTF8{}
.Describe alternatives you've considered
There would be a way to introduce a UTF8String - but this would make the library more non-idiomatic.
The text was updated successfully, but these errors were encountered: