Bump minimum Go to 1.22 and use new features#1017
Merged
VojtechVitek merged 1 commit intogo-chi:masterfrom Sep 17, 2025
Merged
Conversation
Go 1.21 brings us the builtin min func and slices.Contains. Go 1.22 brings us range over int and fixed for loop scoping. We were also able to drop the build tags from the path value code and inline the three-line function directly. This should still work on tinygo as they claim to support Go 1.24.
VojtechVitek
approved these changes
Aug 26, 2025
Contributor
VojtechVitek
left a comment
There was a problem hiding this comment.
LGTM. Thank you!
I'll wait for more 👀 to review and then we can merge. 👍
| // longestPrefix finds the length of the shared prefix | ||
| // of two strings | ||
| func longestPrefix(k1, k2 string) int { | ||
| max := len(k1) |
Contributor
There was a problem hiding this comment.
interesting .. so this variable was named incorrectly - it meant "min" instead?
Contributor
Author
There was a problem hiding this comment.
Yeah I think the original naming was meant to imply max iterations as opposed to min string length. But I agree it was a little confusing.
Comment on lines
+773
to
+780
| // longestPrefix finds the length of the shared prefix of two strings | ||
| func longestPrefix(k1, k2 string) (i int) { | ||
| for i = 0; i < min(len(k1), len(k2)); i++ { | ||
| if k1[i] != k2[i] { | ||
| break | ||
| } | ||
| } | ||
| return i | ||
| return |
Contributor
There was a problem hiding this comment.
One thing I noticed -- (unrelated to this PR) -- this function might not work well with unicode characters, as it works on bytes and not on runes.
The question is -- are we ever passing unicode strings into this function (e.g. "/café", "/café/1"). Can this happen?
|
LGTM |
JRaspass
added a commit
to JRaspass/chi
that referenced
this pull request
Oct 9, 2025
This wasn't updated in either go-chi#969 or go-chi#1017 and is the first thing people read on pkg.go.dev.
JRaspass
added a commit
to JRaspass/chi
that referenced
this pull request
Oct 9, 2025
This wasn't updated in either go-chi#969 or go-chi#1017 and is the first thing people read on pkg.go.dev.
VojtechVitek
pushed a commit
that referenced
this pull request
Oct 9, 2025
wwqgtxx
added a commit
to MetaCubeX/chi
that referenced
this pull request
Dec 17, 2025
This reverts commit a52c582.
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.
Go 1.21 brings us the builtin min func and slices.Contains.
Go 1.22 brings us range over int and fixed for loop scoping.
We were also able to drop the build tags from the path value code and inline the three-line function directly. This should still work on tinygo as they claim to support Go 1.24.