From 97c28b551692cd8fe3c49f5bde265efdd75cd93c Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Sun, 23 Aug 2026 14:39:47 +0200 Subject: [PATCH] test(router): update route-name snapshot for Go 1.27, drop redundant special case Go 1.27 changed how runtime.FuncForPC reports the symbol for HandleWeb()'s returned closure: it now correctly attributes it to its defining function (handlers.(*Server).HandleWeb) instead of leaking the inlining call site's enclosing function name (setupRouter) the way older Go versions did. The registered route itself is unchanged -- this is purely a difference in the introspected debug name. The test's cleanup logic had a dedicated special case for stripping a leading "setupRouter" prefix, added to work around exactly that inlining artifact. Verified empirically (temporarily instrumented with the raw runtime.FuncForPC output, then diffed the full 299-route table with the special case removed) that the general prefix-stripping loop already produces an identical result for the remaining legitimate cases (closures actually defined inline in setupRouter, e.g. /favicon.ico) -- so the dedicated case was already redundant before this Go bump and can be dropped. Co-Authored-By: Claude Sonnet 5 --- cmd/soundtouch-service/router_test.go | 7 ++----- cmd/soundtouch-service/testdata/router_routes.txt | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cmd/soundtouch-service/router_test.go b/cmd/soundtouch-service/router_test.go index 1d6f82bd..be672b5d 100644 --- a/cmd/soundtouch-service/router_test.go +++ b/cmd/soundtouch-service/router_test.go @@ -39,11 +39,8 @@ func TestPrintRoutes(t *testing.T) { // Now we might have "soundtouch-service.setupRouter.func1" // or "command-line-arguments.setupRouter.func1" // or "main.setupRouter.func1" - // Let's remove the first part if it's a known varying package name - if idx := strings.Index(handlerName, "setupRouter"); idx != -1 { - handlerName = handlerName[idx:] - } - // In case it's not setupRouter but still has a package prefix + // Remove the leading package/binary-name segment(s), whatever form + // they take. for { dotIdx := strings.Index(handlerName, ".") if dotIdx == -1 { diff --git a/cmd/soundtouch-service/testdata/router_routes.txt b/cmd/soundtouch-service/testdata/router_routes.txt index 8c3b2ce4..57306b7c 100644 --- a/cmd/soundtouch-service/testdata/router_routes.txt +++ b/cmd/soundtouch-service/testdata/router_routes.txt @@ -169,7 +169,7 @@ GET /streaming/sourceproviders handlers.( GET /updates/soundtouch handlers.(*Server).HandleMargeSoftwareUpdate-fm GET /v1/auth handlers.(*Server).HandleSpeakerAuth-fm GET /v1/blacklist/{deviceId} setupRouter -GET /web/* setupRouter.(*Server).HandleWeb +GET /web/* handlers.(*Server).HandleWeb HEAD /core02/svc-bmx-adapter-siriusxm-everest-eco1/prod/live-adapter handlers.(*Server).HandleSiriusXMLiveAdapter-fm HEAD /core02/svc-bmx-adapter-siriusxm-everest-eco1/prod/live-adapter/* handlers.(*Server).HandleSiriusXMLiveAdapterSubpath-fm OPTIONS /core02/svc-bmx-adapter-siriusxm-everest-eco1/prod/live-adapter handlers.(*Server).HandleSiriusXMLiveAdapter-fm