Day 36: Wifi Woes and Language Matching
🐍 Mood: Having extremely unstable wifi and using a ridiculously long ethernet cable across my entire house aka a giant trip cord.
🎵 Soundtrack: Songs from the Arc of Life
🔌 Wifi Woes
Initially my wifi would work for 5 minutes before needing to be restarted. Only my work computer was having issues. Then it needed to be restarted every 3 minutes. Then 30 seconds. Restarting my computer multiple times did not fix it. Restarting the router did not fix it. Nothing fixed it. Eventually I got the reeeeeeeeeeeally long ethernet cable out.
🩺 Gopls Tests
It turns out my mega code actions feature breaks some existing tests. I starred at them for awhile and I was going to dig deeper into it, but then I got distracted by a github issue.
🇫🇷🇬🇧 Language Matching
Someone opened an issue where go is matching the wrong language. This piqued my interest because back on day 10 I had done a little digging into language matching.
I had fun digging into this bug and this is what I found out so far. I also added the following to the issue as a comment.
Some background Context
- Match calls
getBest. getBestloops through all of the provided tags. It keeps track of abestoption. It callsbest.updatefor each provided tag. If the tag is a better match than the current best, then it updatesbest.
For the working as expected case with desired, _, err := language.ParseAcceptLanguage("en-GB;q=1.0, fr-DE;q=0.9, fr-CA;q=0.8")
- Because English is only in the list of tags once, pin for
en-GBis true. - This sets
m.LanguagePinto true here. en-GBis initially made the best option because it is first andbeatenis set to true here.- Then the loop continues and
best.updateis called for the next tags one at a time. - Because
m.LanguagePinis true, every tag afteren-GBreturns fromupdatehere and does not replaceen-GBasbest. - Thus
en-GBis returned as the best match.
For the buggy case with desired, _, err := language.ParseAcceptLanguage("en-GB;q=1.0, fr;q=0.9, fr-CA;q=0.8, en-DE;q=0.7")
- Because English is only in the list of tags twice, pin for
en-GBis false. - This sets
m.LanguagePinto false here. en-GBis initially made the best option because it is first andbeatenis set to true here.- Then the loop continues and
best.updateis called for the next tagfr-DE. - Since
m.LanguagePinis false, it does NOT return fromupdatehere like in the example above. - This tag makes it into a tie breaker with
en-GB.fr-DEends up winning the tie-breaker here. - Thus
fr-DEis returned as the best match.
❓ My main open question is: Where do the weights come into play? And why didn’t the weights prevent French from beating English?
🎉😱 I’m listed as a contributor!
After submitting my comment mentioned above I saw a tag I never saw before. I am listed as a contributor! :D :D :D :D :D
