Modernize for Go 1.26 - #1357
Merged
Merged
Conversation
Follows up #1356 to bring back in some modernizers that I'd disabled to not make the diff for that original PR gigantic. In particular: * `errorsastype`: Requires the use of the new `errors.AsType` helper. This is a really nice one and turns this old code: var pgErr *pgconn.PgError if errors.As(err, &pgErr) { Into this much nicer generics variant: if pgErr, ok := errors.AsType[*pgconn.PgError](err); ok { * `newexpr`: Converts pointer helpers like `ptrutil.Ptr(...)` to `new`. I remove all uses of `ptrutil.Ptr(...)`, but left its definition in `rivershared` for now because I think it'll allow a little more flexibility in what version of River a River Pro installation can use. For example, an older version of River Pro could potentially point to a newer version of River and still have compilation work (it has however been marked as deprecated). I doubt too many people are in this situation though so we can probably remove it soon. * `stditerators`: Replaces some manual iteration patterns with newer standard library iterator APIs. For example this: for i := range typ.NumField() { field := typ.Field(i) Goes to this: for field := range typ.Fields() {�[27;5;106~
bgentry
approved these changes
Aug 22, 2026
Contributor
Author
|
thx! |
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.
Follows up #1356 to bring back in some modernizers that I'd disabled to
not make the diff for that original PR gigantic.
In particular:
errorsastype: Requires the use of the newerrors.AsTypehelper.This is a really nice one and turns this old code:
Into this much nicer generics variant:
newexpr: Converts pointer helpers likeptrutil.Ptr(...)tonew.I remove all uses of
ptrutil.Ptr(...), but left its definition inriversharedfor now because I think it'll allow a little moreflexibility in what version of River a River Pro installation can use.
For example, an older version of River Pro could potentially point to
a newer version of River and still have compilation work (it has
however been marked as deprecated). I doubt too many people are in
this situation though so we can probably remove it soon.
stditerators: Replaces some manual iteration patterns with newerstandard library iterator APIs. For example this:
Goes to this: