Repository navigation
Conversation
Modernize the library for Go 1.26 idioms: errors.AsType for wrapped OKError/ProtocolError, reflect.TypeFor for handler injection, IsVariadic for grpc options, SplitSeq, and range-over-int.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Raise the module floor to Go 1.26 and modernize the library to current Go idioms.
Toolchain
go.modand CI matrix:1.23→1.26actions/checkout@v5,actions/setup-go@v6,codecov/codecov-action@v5Modern Go
errors.AsTypefor OKError /*ProtocolErrorclassificationreflect.TypeForinstead of comparingType.String()for handler injectionType.IsVariadic()instead of “last arg is a slice”strings.SplitSeqfor SSE data lines,for i := range n,any,reflect.Pointeram.Handler(the oldam.Handledid not exist) and a method-aware ServeMux patternBehavior changes (v2)
These are intentional, tested, and should be treated as runtime contract updates, not style-only:
EncodeErrorwalks the unwrap tree.fmt.Errorf("%w", NewError(...))is now 200 with the inner JSON; wrappedErrNotFoundis now 400. Previously both were 500{}.OKErrorembedserror. Required forerrors.AsType[OKError]. Existing implementers already haveError()because they are returned aserror.WrapErrordoes not re-wrap a value that already unwraps toOKErroror*ProtocolError(including custom OKError fromUnmarshalForm).[]Tis a real request parameter. Only a variadic last arg is skipped as grpc options.func(items []int)now decodes JSON instead of panicking onCall.errors.Joinstill prefers the firstOKErrorin the tree (AsType order).