Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/text/language: possible error in the handler example of the package documentation #36928

Closed
palmamartin opened this issue Jan 31, 2020 · 2 comments
Labels
Documentation FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@palmamartin
Copy link

On line 36 of the documentation the cookie value is passed using lang.String() to language.MatchStrings . I assume it should be lang.Value instead.

Current documentation:

lang, _ := r.Cookie("lang")
...
tag, _ := language.MatchStrings(matcher, lang.String(), accept)

Proposed fix:

lang, _ := r.Cookie("lang")
...
tag, _ := language.MatchStrings(matcher, lang.Value, accept)

If my proposed solution is right I can provide CL to fix the documentation.

@gopherbot gopherbot added this to the Unreleased milestone Jan 31, 2020
@ianlancetaylor
Copy link
Contributor

CC @mpvl

@palmamartin
Copy link
Author

I might understand why lang.String() is used in the example - due to the fact that there is no error checking when retrieving the cookie. If the cookie does not exists a call to lang.Value would result in a runtime error. Sorry for the noise.

@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 7, 2020
@golang golang locked and limited conversation to collaborators Jul 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants