Skip to content

var MatchedRoutePathParam = "$matchedRoutePath" changed declaration to const MatchedRoutePathParam#379

Open
LeoDiKadyrov wants to merge 1 commit into
julienschmidt:masterfrom
LeoDiKadyrov:router-matchedroutepathparam-refactor
Open

var MatchedRoutePathParam = "$matchedRoutePath" changed declaration to const MatchedRoutePathParam#379
LeoDiKadyrov wants to merge 1 commit into
julienschmidt:masterfrom
LeoDiKadyrov:router-matchedroutepathparam-refactor

Conversation

@LeoDiKadyrov

@LeoDiKadyrov LeoDiKadyrov commented Feb 19, 2024

Copy link
Copy Markdown

I only suggested it due to following reasons:

  • John Carmack once said: "I am a full const nazi nowadays, and I chide any programmer that doesn’t const every variable and parameter that can be."
  • I'm a newbie into development, trying to learn staff and while studying source code of this library, I saw an opportunity for small change and my first PR into open source ever

All tests that are originally in master repo passed green. When I was going through the code it just confused me a bit, that a variable only used in router.go and not really mutated anywhere declared as var. Sorry if it's too small to have anyone attention and a whole PR open for it.


UPD 23.03.2026
Breaking Change: Switching MatchedRoutePathParam from var to const. Any downstream code that previously reassigned httprouter.MatchedRoutePathParam will no longer compile.

@themavik themavik left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching MatchedRoutePathParam from var to const is the right default for an immutable sentinel. nit: any code that reassigned httprouter.MatchedRoutePathParam will no longer compile—call that out in the PR body for downstream grep.

@LeoDiKadyrov

Copy link
Copy Markdown
Author

Oh wow, unexpected monday surprise. Appreciate that you directed your attention to my PR. Will call it out in the PR body

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants