Repository navigation
Go 1.22 patterns: also read a host and a trailing {$} - #1
Merged
ryoaonetsuki merged 1 commit intoNov 20, 2026
Conversation
A ServeMux pattern can name a host ("GET shop.example.com/api/orders",
"example.com:8080/"); those endpoints were missed. A host counts only when
it looks like a domain name and only on Handle/HandleFunc, so names like
"devices/+/status" or a host-like string on another router stay out.
A trailing {$} only marks an exact match, so "GET /{$}" is now GET /.
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.
Hi! Thanks for haydenschmitty#134. While trying it on a plain
net/httpserver I ran into two more Go 1.22 pattern shapes, so here is a small commit on top of your branch, in case it's useful:"GET shop.example.com/api/orders","example.com/","api.example.com:8080/stats"): these endpoints were missed. Now the host is left out of the path and the method still comes from the pattern. A host only counts when it looks like a domain name and only onHandle/HandleFunc, sobus.Handle("devices/+/status", …)orr.Get("cdn.example.com/logo.png", …)don't become endpoints.{$}(exact match):"GET /{$}"showed asGET /{$}; now it'sGET /.Example:
In a small sample (5 handlers like these, and a website calling
fetch(`/api/products/${id}`),fetch('/api/products', { method: 'POST' })andfetch('/api/reports/')), a scan found 2 routes (one of themGET /{$}) and 0 website links before, and 5 routes and 3 links after.Changes: 3 tests in
tests/go-groups.test.mjs(host and{$}cases, look-alikes, a website request reaching a host pattern), a few lines inextractGo, and half a sentence each in your CHANGELOG entry and thedocs/development.mdrow.Tests (
node --testinnode:<v>-alpine): Node 18, 20 and 22 each go from 498 tests / 496 pass / 0 fail on your branch to 501 / 499 / 0 with this. With theextract.mjschange taken out, the two new positive tests fail.claude plugin validate .passes.Feel free to squash it into your PR, reword anything, or just take the idea.