internal/godoc: refactor into internal/web [generated]

What's left of internal/godoc is mainly a simple web server
for static content (plus the package docs provided by internal/pkgdoc)
and bears little resemblance to the original godoc.

Revamp the API and retire the name, moving to internal/web.

CL generated by the script below.

cd internal/godoc
mv util.go istext.go
mv godoc_test.go template_test.go
mv server_test.go site_test.go

rf '
	mv TabWidth tabWidth
	mv IsText isText
	mv TabSpacer tabSpacer

	mv Presentation Site
	mv NewPresentation NewSite
	mv writerCapturesErr writeErrorSaver
	rm marshalJSON
	mv redirect maybeRedirect
	mv redirectFile maybeRedirectFile
	mv Site.serveText Site.serveRawText
	mv Site.serveTextFile Site.serveText
	mv Site.serveDirectory Site.serveDir
	mv Site.initFuncMap Site.initDocFuncs

	mv \
		toFS \
		Site \
		NewSite \
		Site.ServeError \
		Site.ServeHTTP \
		Site.ServePage \
		Page \
		Site.fullPage \
		Page.Invoke \
		writeErrorSaver \
		writeErrorSaver.Write \
		applyTemplateToResponseWriter \
		Site.serveFile \
		maybeRedirect \
		maybeRedirectFile \
		doctype \
		Site.serveHTML \
		Site.serveDir \
		Site.serveText \
		selRx \
		rangeSelection \
		Site.serveRawText \
		Site.googleCN \

	mv example_nameFunc example_name
	mv example_suffixFunc example_suffix
	mv srcPosLinkFunc srcPosLink

	mv \
		siteFuncs \
		example_name \
		example_suffix \
		srcToPkg \
		Page.SrcPkgLink \
		Page.SrcBreadcrumb \
		Page.SrcPosLink \
		srcPosLink \

	mv \
		docServer \
		docServer.ServeHTTP \
		Page.ModeQuery \

	mv metaJSON fileJSON
	mv extractMetadata parseFile
	mv \
		file \
		fileJSON \
		join \
		open \
		jsonStart \
		parseFile \

	mv \
		Site.initDocFuncs \
		Site.code \
		Site.contents \
		stringFor \
		Site.oneLine \
		Site.multipleLines \
		parseArg \
		match \

	mv Site.ServeError.p Site.ServeError.s
	mv Site.ServeHTTP.p Site.ServeHTTP.s
	mv Site.ServePage.p Site.ServePage.s
	mv Site.code.p Site.code.s
	mv Site.contents.p Site.contents.s
	mv Site.fullPage.p Site.fullPage.s
	mv Site.googleCN.p Site.googleCN.s
	mv Site.initDocFuncs.p Site.initDocFuncs.s
	mv Site.multipleLines.p Site.multipleLines.s
	mv Site.oneLine.p Site.oneLine.s
	mv Site.serveDir.p Site.serveDir.s
	mv Site.serveFile.p Site.serveFile.s
	mv Site.serveHTML.p Site.serveHTML.s
	mv Site.serveRawText.p Site.serveRawText.s
	mv Site.serveText.p Site.serveText.s
	mv Site.writeNode.p Site.writeNode.s

	mv Page.pres

	mv astfuncs.go docfuncs.go examplefuncs.go \
		file.go istext.go markdown.go pkgdoc.go \
		site.go site_test.go sitefuncs.go \
		tab.go template_test.go \
rm godoc.go meta.go page.go pres.go server.go template.go

cd ../../cmd/golangorg
rf '
	mv pres site

Change-Id: Ic03a2dbe14f74c60bd6a5a86ba4d3f36d8c5bea8
Trust: Russ Cox <>
Run-TryBot: Russ Cox <>
Reviewed-by: Dmitri Shuralyov <>
19 files changed
tree: 7db522dcd6d64fcb392c1cb283dad1655bc89e0e
  1. .gitattributes
  2. .prettierrc
  9. _content/
  10. blog/
  11. cmd/
  12. codereview.cfg
  13. content.go
  16. go.mod
  17. go.sum
  18. internal/
  19. tour/

Go website

Go Reference

This repo holds content and serving programs for the web site.

Content is in _content/. Server code is in cmd/ and internal/.

To run the server to preview local content changes, use:

go run ./cmd/golangorg

The supporting programs cmd/admingolangorg and cmd/googlegolangorg are the servers for and (They do not use the _content/ directory.)

Each command directory has its own explaining deployment.

JS/CSS Formatting

This repository uses prettier to format JS and CSS files.

The version of prettier used is 1.18.2.

It is encouraged that all JS and CSS code be run through this before submitting a change. However, it is not a strict requirement enforced by CI.

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see

The main issue tracker for the website repository is located at Prefix your issue with “x/website:” in the subject line, so it is easy to find.