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/website/cmd/golangorg: GoogleCN does not work #35065

Closed
jeanbza opened this issue Oct 22, 2019 · 3 comments
Closed

x/website/cmd/golangorg: GoogleCN does not work #35065

jeanbza opened this issue Oct 22, 2019 · 3 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@jeanbza
Copy link
Member

jeanbza commented Oct 22, 2019

$ curl -X POST -F 'googlecn=yes' -H "X-Appengine-Country: CN" localhost:6060/doc/code.html | grep Tour
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 20369    0 20223  100   146  3327k  24599 --:--:-- --:--:-- --:--:-- 3949k
Take <a href="//tour.golang.org/">A Tour of Go</a> to learn the language

Here's a test that repros this: https://gist.github.com/jadekler/33cb8fc1f96cebaf35c46269be045bc2.

I got as far as writing the test but couldn't figure out the solution. Seems like godoc.org + filesystem is serving all the .html files, instead of x/website? Is that right? If so, I have no idea where to do the template execution. Would love some tips.

cc @dmitshur @andybons @jayconrod

@dmitshur dmitshur self-assigned this Oct 22, 2019
@dmitshur dmitshur changed the title cmd/golangorg: GoogleCN does not work x/website/cmd/golangorg: GoogleCN does not work Oct 22, 2019
@gopherbot gopherbot added this to the Unreleased milestone Oct 22, 2019
@dmitshur dmitshur added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 22, 2019
@dmitshur
Copy link
Contributor

I'm a little confused by the curl example in this issue report. It makes a POST request instead of GET. It targets the /doc/code.html page, but the current /doc/code.html page doesn't have any {{if .GoogleCN}} use. Did you mean to use /doc/docs.html instead?

Would love some tips.

For development purposes, you can force the GoogleCN value to be set to true by setting the googlecn query parameter to a non-empty value. For example, https://golang.org/?googlecn=1.

See here for the relevant logic.

For production purposes, you need to set the GOLANGORG_CHECK_COUNTRY environment variable to true in order to enable country restrictions. See here and here.

@jeanbza
Copy link
Member Author

jeanbza commented Oct 22, 2019

Sorry!! The perils of filing bugs late at night. Looks like things somehow do work, after all:

$ curl -X POST -F 'googlecn=yes' -H "X-Appengine-Country: CN" https://golang.org/doc/ | grep Tour
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  9095    0  8949  100   146  90803   1481 --:--:-- --:--:-- --:--:-- 91316
	  A Tour of Go

Closing this.


For production purposes, you need to set the GOLANGORG_CHECK_COUNTRY environment variable to true in order to enable country restrictions. See here and here.

Ahh. Thank you!

@jeanbza jeanbza closed this as completed Oct 22, 2019
@jeanbza
Copy link
Member Author

jeanbza commented Dec 11, 2019

FYI for future: you also need,

"Template": true

At the top of the file.

@golang golang locked and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants