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

Comments

@palmamartin
Copy link

@palmamartin palmamartin commented Jan 31, 2020

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

@ianlancetaylor ianlancetaylor commented Jan 31, 2020

CC @mpvl

@palmamartin
Copy link
Author

@palmamartin palmamartin commented Jan 31, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.