diff --git a/cmd/golangorg/x.go b/cmd/golangorg/x.go index bde63098..1b3de3fe 100644 --- a/cmd/golangorg/x.go +++ b/cmd/golangorg/x.go @@ -26,7 +26,7 @@ func init() { func xHandler(w http.ResponseWriter, r *http.Request) { if !strings.HasPrefix(r.URL.Path, xPrefix) { // Shouldn't happen if handler is registered correctly. - http.Redirect(w, r, "https://godoc.org/-/subrepo", http.StatusTemporaryRedirect) + http.Redirect(w, r, "https://pkg.go.dev/search?q=golang.org/x", http.StatusTemporaryRedirect) return } proj, suffix := strings.TrimPrefix(r.URL.Path, xPrefix), "" @@ -34,7 +34,7 @@ func xHandler(w http.ResponseWriter, r *http.Request) { proj, suffix = proj[:i], proj[i:] } if proj == "" { - http.Redirect(w, r, "https://godoc.org/-/subrepo", http.StatusTemporaryRedirect) + http.Redirect(w, r, "https://pkg.go.dev/search?q=golang.org/x", http.StatusTemporaryRedirect) return } repo, ok := repos.ByGerritProject[proj] @@ -42,15 +42,10 @@ func xHandler(w http.ResponseWriter, r *http.Request) { http.NotFound(w, r) return } - docSite := "godoc.org" - if repo.UsePkgGoDev() { - docSite = "pkg.go.dev" - } data := struct { - DocSite string // Website providing documentation, either "godoc.org" or "pkg.go.dev". - Proj string // Gerrit project ("net", "sys", etc) - Suffix string // optional "/path" for requests like /x/PROJ/path - }{docSite, proj, suffix} + Proj string // Gerrit project ("net", "sys", etc) + Suffix string // optional "/path" for requests like /x/PROJ/path + }{proj, suffix} if err := xTemplate.Execute(w, data); err != nil { log.Println("xHandler:", err) } @@ -62,10 +57,10 @@ var xTemplate = template.Must(template.New("x").Parse(` - + -Nothing to see here; move along. +Nothing to see here; move along. `)) diff --git a/cmd/golangorg/x_test.go b/cmd/golangorg/x_test.go index c304c67d..a97dda95 100644 --- a/cmd/golangorg/x_test.go +++ b/cmd/golangorg/x_test.go @@ -48,7 +48,7 @@ func TestXHandler(t *testing.T) { checks: []check{ status(200), substr(``), - substr(`http-equiv="refresh" content="0; url=https://godoc.org/golang.org/x/net">`), + substr(`http-equiv="refresh" content="0; url=https://pkg.go.dev/golang.org/x/net">`), }, }, { @@ -57,7 +57,7 @@ func TestXHandler(t *testing.T) { checks: []check{ status(200), substr(``), - substr(`http-equiv="refresh" content="0; url=https://godoc.org/golang.org/x/net/suffix">`), + substr(`http-equiv="refresh" content="0; url=https://pkg.go.dev/golang.org/x/net/suffix">`), }, }, { @@ -80,7 +80,7 @@ func TestXHandler(t *testing.T) { path: "/x/", checks: []check{ status(307), - hasHeader("Location", "https://godoc.org/-/subrepo"), + hasHeader("Location", "https://pkg.go.dev/search?q=golang.org/x"), }, }, { diff --git a/content/static/doc/gopath_code.html b/content/static/doc/gopath_code.html index f537522f..5495e477 100644 --- a/content/static/doc/gopath_code.html +++ b/content/static/doc/gopath_code.html @@ -100,7 +100,7 @@ The tree above shows a workspace containing two repositories The example repository contains two commands (hello and outyet) and one library (stringutil). The image repository contains the bmp package -and several others. +and several others.

@@ -595,8 +595,8 @@ import "github.com/golang/example/stringutil"

This convention is the easiest way to make your Go packages available for others to use. -The Go Wiki -and godoc.org +Pkg.go.dev +and the Go Wiki provide lists of external Go projects.

diff --git a/content/static/packageroot.html b/content/static/packageroot.html index b7edb6f9..c246c795 100644 --- a/content/static/packageroot.html +++ b/content/static/packageroot.html @@ -119,24 +119,24 @@ Install them with "go get".

Community

@@ -144,7 +144,7 @@ These services can help you find Open Source packages provided by the community.

{{end}} diff --git a/content/static/static.go b/content/static/static.go index 120fc0df..21572db4 100644 --- a/content/static/static.go +++ b/content/static/static.go @@ -63,7 +63,7 @@ var Files = map[string]string{ "doc/download.js": "class\x20DownloadsController\x20{\x0a\x20\x20constructor()\x20{\x0a\x20\x20\x20\x20//\x20Parts\x20of\x20tabbed\x20section.\x0a\x20\x20\x20\x20this.tablist\x20=\x20document.querySelector('.js-tabSection');\x0a\x20\x20\x20\x20this.tabs\x20=\x20this.tablist.querySelectorAll('[role=\"tab\"]');\x0a\x20\x20\x20\x20this.panels\x20=\x20document.querySelectorAll('[role=\"tabpanel\"]');\x0a\x0a\x20\x20\x20\x20//\x20OS\x20for\x20which\x20to\x20display\x20download\x20and\x20install\x20steps.\x0a\x20\x20\x20\x20this.osName\x20=\x20'Unknown\x20OS';\x0a\x0a\x20\x20\x20\x20//\x20URL\x20to\x20JSON\x20containing\x20list\x20of\x20installer\x20downloads.\x0a\x20\x20\x20\x20const\x20fileListUrl\x20=\x20'https://golang.org/dl/?mode=json';\x0a\x20\x20\x20\x20this.activeTabIndex\x20=\x200;\x0a\x0a\x20\x20\x20\x20//\x20Get\x20the\x20install\x20file\x20list,\x20then\x20get\x20names\x20and\x20sizes\x0a\x20\x20\x20\x20//\x20for\x20each\x20OS\x20supported\x20on\x20the\x20install\x20page.\x0a\x20\x20\x20\x20fetch(fileListUrl)\x0a\x20\x20\x20\x20\x20\x20.then((response)\x20=>\x20response.json())\x0a\x20\x20\x20\x20\x20\x20.then((data)\x20=>\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20const\x20files\x20=\x20data[0]['files'];\x0a\x20\x20\x20\x20\x20\x20\x20\x20for\x20(var\x20i\x20=\x200;\x20i\x20<\x20files.length;\x20i++)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20let\x20file\x20=\x20files[i].filename;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20let\x20fileSize\x20=\x20files[i].size;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(file.match('.linux-amd64.tar.gz$'))\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20this.linuxFileName\x20=\x20file;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20this.linuxFileSize\x20=\x20Math.round(fileSize\x20/\x20Math.pow(1024,\x202));\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(file.match('.darwin-amd64(-osx10.8)?.pkg$'))\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20this.macFileName\x20=\x20file;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20this.macFileSize\x20=\x20Math.round(fileSize\x20/\x20Math.pow(1024,\x202));\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(file.match('.windows-amd64.msi$'))\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20this.windowsFileName\x20=\x20file;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20this.windowsFileSize\x20=\x20Math.round(fileSize\x20/\x20Math.pow(1024,\x202));\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20this.detectOS();\x0a\x20\x20\x20\x20\x20\x20\x20\x20const\x20osTab\x20=\x20document.getElementById(this.osName);\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(osTab\x20!==\x20null)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20osTab.click();\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20this.setDownloadForOS(this.osName);\x0a\x20\x20\x20\x20\x20\x20})\x0a\x20\x20\x20\x20\x20\x20.catch(console.error);\x0a\x20\x20\x20\x20\x20\x20this.setEventListeners();\x0a\x20\x20}\x0a\x0a\x20\x20setEventListeners()\x20{\x0a\x20\x20\x20\x20this.tabs.forEach((tabEl)\x20=>\x20{\x0a\x20\x20\x20\x20\x20\x20tabEl.addEventListener('click',\x20e\x20=>\x20this.handleTabClick((e)));\x0a\x20\x20\x20\x20});\x0a\x20\x20}\x0a\x0a\x20\x20//\x20Set\x20the\x20download\x20button\x20UI\x20for\x20a\x20specific\x20OS.\x0a\x20\x20setDownloadForOS(osName)\x20{\x0a\x20\x20\x20\x20const\x20baseURL\x20=\x20'https://golang.org/dl/';\x0a\x20\x20\x20\x20let\x20download;\x0a\x0a\x20\x20\x20\x20switch(osName){\x0a\x20\x20\x20\x20\x20\x20case\x20'linux':\x0a\x20\x20\x20\x20\x20\x20\x20\x20document.querySelector('.js-downloadButton').textContent\x20=\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'Download\x20Go\x20for\x20Linux';\x0a\x20\x20\x20\x20\x20\x20\x20\x20document.querySelector('.js-downloadDescription').textContent\x20=\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20this.linuxFileName\x20+\x20'\x20('\x20+\x20this.linuxFileSize\x20+\x20'\x20MB)';\x0a\x20\x20\x20\x20\x20\x20\x20\x20document.querySelector('.js-download').href\x20=\x20baseURL\x20+\x20this.linuxFileName;\x0a\x20\x20\x20\x20\x20\x20\x20\x20break;\x0a\x20\x20\x20\x20\x20\x20case\x20'mac':\x0a\x20\x20\x20\x20\x20\x20\x20\x20document.querySelector('.js-downloadButton').textContent\x20=\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'Download\x20Go\x20for\x20Mac';\x0a\x20\x20\x20\x20\x20\x20\x20\x20document.querySelector('.js-downloadDescription').textContent\x20=\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20this.macFileName\x20+\x20'\x20('\x20+\x20this.macFileSize\x20+\x20'\x20MB)';\x0a\x20\x20\x20\x20\x20\x20\x20\x20document.querySelector('.js-download').href\x20=\x20baseURL\x20+\x20this.macFileName;\x0a\x20\x20\x20\x20\x20\x20\x20\x20break;\x0a\x20\x20\x20\x20\x20\x20case\x20'windows':\x0a\x20\x20\x20\x20\x20\x20\x20\x20document.querySelector('.js-downloadButton').textContent\x20=\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'Download\x20Go\x20for\x20Windows';\x0a\x20\x20\x20\x20\x20\x20\x20\x20document.querySelector('.js-downloadDescription').textContent\x20=\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20this.windowsFileName\x20+\x20'\x20('\x20+\x20this.windowsFileSize\x20+\x20'\x20MB)';\x0a\x20\x20\x20\x20\x20\x20\x20\x20document.querySelector('.js-download').href\x20=\x20baseURL\x20+\x20this.windowsFileName;\x0a\x20\x20\x20\x20\x20\x20\x20\x20break;\x0a\x20\x20\x20\x20\x20\x20default:\x0a\x20\x20\x20\x20\x20\x20\x20\x20document.querySelector('.js-downloadButton').textContent\x20=\x20'Download\x20Go';\x0a\x20\x20\x20\x20\x20\x20\x20\x20document.querySelector('.js-downloadDescription').textContent\x20=\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'Visit\x20the\x20downloads\x20page.';\x0a\x20\x20\x20\x20\x20\x20\x20\x20document.querySelector('.js-download').href\x20=\x20baseURL;\x0a\x20\x20\x20\x20\x20\x20\x20\x20break;\x0a\x20\x20\x20\x20}\x0a\x20\x20}\x0a\x0a\x20\x20//\x20Updates\x20install\x20tab\x20with\x20dynamic\x20data.\x0a\x20\x20setInstallTabData(osName)\x20{\x0a\x20\x20\x20\x20const\x20fnId\x20=\x20`#${osName}-filename`;\x0a\x20\x20\x20\x20const\x20el\x20=\x20document.querySelector(fnId);\x0a\x20\x20\x20\x20if\x20(!el)\x20{\x0a\x20\x20\x20\x20\x20\x20return;\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20switch(osName)\x20{\x0a\x20\x20\x20\x20\x20\x20case\x20'linux':\x0a\x20\x20\x20\x20\x20\x20\x20\x20//\x20Update\x20filename\x20for\x20linux\x20installation\x20step\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(this.linuxFileName)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20el.textContent\x20=\x20this.linuxFileName;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20break;\x0a\x20\x20\x20\x20}\x0a\x20\x20}\x0a\x0a\x20\x20//\x20Detect\x20the\x20users\x20OS\x20for\x20installation\x20default.\x0a\x20\x20detectOS()\x20{\x0a\x20\x20\x20\x20if\x20(navigator.userAgent.indexOf('Linux')\x20!==\x20-1)\x20{\x0a\x20\x20\x20\x20\x20\x20this.osName\x20=\x20'linux';\x0a\x20\x20\x20\x20}\x20else\x20if\x20(navigator.userAgent.indexOf('Mac')\x20!==\x20-1)\x20{\x0a\x20\x20\x20\x20\x20\x20this.osName\x20=\x20'mac';\x0a\x20\x20\x20\x20}\x20else\x20if\x20(navigator.userAgent.indexOf('X11')\x20!==\x20-1)\x20{\x0a\x20\x20\x20\x20\x20\x20this.osName\x20=\x20'unix';\x0a\x20\x20\x20\x20}\x20else\x20if\x20(navigator.userAgent.indexOf('Win')\x20!==\x20-1)\x20{\x0a\x20\x20\x20\x20\x20\x20this.osName\x20=\x20'windows';\x0a\x20\x20\x20\x20}\x0a\x20\x20}\x0a\x0a\x20\x20//\x20Activates\x20the\x20tab\x20at\x20the\x20given\x20index.\x0a\x20\x20activateTab(index)\x20{\x0a\x20\x20\x20\x20this.tabs[this.activeTabIndex].setAttribute('aria-selected',\x20'false');\x0a\x20\x20\x20\x20this.tabs[this.activeTabIndex].setAttribute('tabindex',\x20'-1');\x0a\x20\x20\x20\x20this.panels[this.activeTabIndex].setAttribute('hidden',\x20'');\x0a\x20\x20\x20\x20this.tabs[index].setAttribute('aria-selected',\x20'true');\x0a\x20\x20\x20\x20this.tabs[index].setAttribute('tabindex',\x20'0');\x0a\x20\x20\x20\x20this.panels[index].removeAttribute('hidden');\x0a\x20\x20\x20\x20this.tabs[index].focus();\x0a\x20\x20\x20\x20this.activeTabIndex\x20=\x20index;\x0a\x20\x20}\x0a\x0a\x20\x20//\x20Handles\x20clicks\x20on\x20tabs.\x0a\x20\x20handleTabClick(e)\x20{\x0a\x20\x20\x20\x20const\x20el\x20=\x20(e.target);\x0a\x20\x20\x20\x20this.activateTab(Array.prototype.indexOf.call(this.tabs,\x20el));\x0a\x20\x20\x20\x20this.setDownloadForOS(el.id);\x0a\x20\x20\x20\x20this.setInstallTabData(el.id);\x0a\x20\x20}\x0a\x0a}\x0a\x0a//\x20Instantiate\x20controller\x20for\x20page\x20event\x20handling.\x0anew\x20DownloadsController();\x0a", - "doc/gopath_code.html": "\x0a\x0aIntroduction\x0a\x0a

\x0aIf\x20you\x20are\x20new\x20to\x20Go,\x20please\x20see\x20the\x20more\x20recent\x0aHow\x20to\x20Write\x20Go\x20Code.\x0a

\x0a\x0a

\x0aThis\x20document\x20demonstrates\x20the\x20development\x20of\x20a\x20simple\x20Go\x20package\x20and\x0aintroduces\x20the\x20go\x20tool,\x20the\x20standard\x20way\x20to\x20fetch,\x0abuild,\x20and\x20install\x20Go\x20packages\x20and\x20commands.\x0a

\x0a\x0a

\x0aThe\x20go\x20tool\x20requires\x20you\x20to\x20organize\x20your\x20code\x20in\x20a\x20specific\x0away.\x20Please\x20read\x20this\x20document\x20carefully.\x0aIt\x20explains\x20the\x20simplest\x20way\x20to\x20get\x20up\x20and\x20running\x20with\x20your\x20Go\x20installation.\x0a

\x0a\x0a

\x0aA\x20similar\x20explanation\x20is\x20available\x20as\x20a\x0ascreencast.\x0a

\x0a\x0a\x0aCode\x20organization\x0a\x0aOverview\x0a\x0a
    \x0a\x09
  • Go\x20programmers\x20typically\x20keep\x20all\x20their\x20Go\x20code\x20in\x20a\x20single\x20workspace.
  • \x0a\x09
  • A\x20workspace\x20contains\x20many\x20version\x20control\x20repositories\x0a\x09\x20\x20\x20\x20(managed\x20by\x20Git,\x20for\x20example).
  • \x0a\x09
  • Each\x20repository\x20contains\x20one\x20or\x20more\x20packages.
  • \x0a\x09
  • Each\x20package\x20consists\x20of\x20one\x20or\x20more\x20Go\x20source\x20files\x20in\x20a\x20single\x20directory.
  • \x0a\x09
  • The\x20path\x20to\x20a\x20package's\x20directory\x20determines\x20its\x20import\x20path.
  • \x0a
\x0a\x0a

\x0aNote\x20that\x20this\x20differs\x20from\x20other\x20programming\x20environments\x20in\x20which\x20every\x0aproject\x20has\x20a\x20separate\x20workspace\x20and\x20workspaces\x20are\x20closely\x20tied\x20to\x20version\x0acontrol\x20repositories.\x0a

\x0a\x0aWorkspaces\x0a\x0a

\x0aA\x20workspace\x20is\x20a\x20directory\x20hierarchy\x20with\x20two\x20directories\x20at\x20its\x20root:\x0a

\x0a\x0a
    \x0a
  • src\x20contains\x20Go\x20source\x20files,\x20and\x0a
  • bin\x20contains\x20executable\x20commands.\x0a
\x0a\x0a

\x0aThe\x20go\x20tool\x20builds\x20and\x20installs\x20binaries\x20to\x20the\x20bin\x20directory.\x0a

\x0a\x0a

\x0aThe\x20src\x20subdirectory\x20typically\x20contains\x20multiple\x20version\x20control\x0arepositories\x20(such\x20as\x20for\x20Git\x20or\x20Mercurial)\x20that\x20track\x20the\x20development\x20of\x20one\x0aor\x20more\x20source\x20packages.\x0a

\x0a\x0a

\x0aTo\x20give\x20you\x20an\x20idea\x20of\x20how\x20a\x20workspace\x20looks\x20in\x20practice,\x20here's\x20an\x20example:\x0a

\x0a\x0a
\x0abin/\x0a\x20\x20\x20\x20hello\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20command\x20executable\x0a\x20\x20\x20\x20outyet\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20command\x20executable\x0asrc/\x0a\x20\x20\x20\x20github.com/golang/example/\x0a\x20\x20\x20\x20\x20\x20\x20\x20.git/\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20Git\x20repository\x20metadata\x0a\x09hello/\x0a\x09\x20\x20\x20\x20hello.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20command\x20source\x0a\x09outyet/\x0a\x09\x20\x20\x20\x20main.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20command\x20source\x0a\x09\x20\x20\x20\x20main_test.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20test\x20source\x0a\x09stringutil/\x0a\x09\x20\x20\x20\x20reverse.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20package\x20source\x0a\x09\x20\x20\x20\x20reverse_test.go\x20\x20\x20\x20\x20\x20\x20\x20#\x20test\x20source\x0a\x20\x20\x20\x20golang.org/x/image/\x0a\x20\x20\x20\x20\x20\x20\x20\x20.git/\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20Git\x20repository\x20metadata\x0a\x09bmp/\x0a\x09\x20\x20\x20\x20reader.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20package\x20source\x0a\x09\x20\x20\x20\x20writer.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20package\x20source\x0a\x20\x20\x20\x20...\x20(many\x20more\x20repositories\x20and\x20packages\x20omitted)\x20...\x0a
\x0a\x0a

\x0aThe\x20tree\x20above\x20shows\x20a\x20workspace\x20containing\x20two\x20repositories\x0a(example\x20and\x20image).\x0aThe\x20example\x20repository\x20contains\x20two\x20commands\x20(hello\x0aand\x20outyet)\x20and\x20one\x20library\x20(stringutil).\x0aThe\x20image\x20repository\x20contains\x20the\x20bmp\x20package\x0aand\x20several\x20others.\x0a

\x0a\x0a

\x0aA\x20typical\x20workspace\x20contains\x20many\x20source\x20repositories\x20containing\x20many\x0apackages\x20and\x20commands.\x20Most\x20Go\x20programmers\x20keep\x20all\x20their\x20Go\x20source\x20code\x0aand\x20dependencies\x20in\x20a\x20single\x20workspace.\x0a

\x0a\x0a

\x0aNote\x20that\x20symbolic\x20links\x20should\x20not\x20be\x20used\x20to\x20link\x20files\x20or\x20directories\x20into\x20your\x20workspace.\x0a

\x0a\x0a

\x0aCommands\x20and\x20libraries\x20are\x20built\x20from\x20different\x20kinds\x20of\x20source\x20packages.\x0aWe\x20will\x20discuss\x20the\x20distinction\x20later.\x0a

\x0a\x0a\x0aThe\x20GOPATH\x20environment\x20variable\x0a\x0a

\x0aThe\x20GOPATH\x20environment\x20variable\x20specifies\x20the\x20location\x20of\x20your\x0aworkspace.\x20It\x20defaults\x20to\x20a\x20directory\x20named\x20go\x20inside\x20your\x20home\x20directory,\x0aso\x20$HOME/go\x20on\x20Unix,\x0a$home/go\x20on\x20Plan\x209,\x0aand\x20%USERPROFILE%\\go\x20(usually\x20C:\\Users\\YourName\\go)\x20on\x20Windows.\x0a

\x0a\x0a

\x0aIf\x20you\x20would\x20like\x20to\x20work\x20in\x20a\x20different\x20location,\x20you\x20will\x20need\x20to\x0aset\x20GOPATH\x0ato\x20the\x20path\x20to\x20that\x20directory.\x0a(Another\x20common\x20setup\x20is\x20to\x20set\x20GOPATH=$HOME.)\x0aNote\x20that\x20GOPATH\x20must\x20not\x20be\x20the\x0asame\x20path\x20as\x20your\x20Go\x20installation.\x0a

\x0a\x0a

\x0aThe\x20command\x20go\x20env\x20GOPATH\x0aprints\x20the\x20effective\x20current\x20GOPATH;\x0ait\x20prints\x20the\x20default\x20location\x20if\x20the\x20environment\x20variable\x20is\x20unset.\x0a

\x0a\x0a

\x0aFor\x20convenience,\x20add\x20the\x20workspace's\x20bin\x20subdirectory\x0ato\x20your\x20PATH:\x0a

\x0a\x0a
\x0a$\x20export\x20PATH=$PATH:$(go\x20env\x20GOPATH)/bin\x0a
\x0a\x0a

\x0aThe\x20scripts\x20in\x20the\x20rest\x20of\x20this\x20document\x20use\x20$GOPATH\x0ainstead\x20of\x20$(go\x20env\x20GOPATH)\x20for\x20brevity.\x0aTo\x20make\x20the\x20scripts\x20run\x20as\x20written\x0aif\x20you\x20have\x20not\x20set\x20GOPATH,\x0ayou\x20can\x20substitute\x20$HOME/go\x20in\x20those\x20commands\x0aor\x20else\x20run:\x0a

\x0a\x0a
\x0a$\x20export\x20GOPATH=$(go\x20env\x20GOPATH)\x0a
\x0a\x0a

\x0aTo\x20learn\x20more\x20about\x20the\x20GOPATH\x20environment\x20variable,\x20see\x0a'go\x20help\x20gopath'.\x0a

\x0a\x0aImport\x20paths\x0a\x0a

\x0aAn\x20import\x20path\x20is\x20a\x20string\x20that\x20uniquely\x20identifies\x20a\x20package.\x0aA\x20package's\x20import\x20path\x20corresponds\x20to\x20its\x20location\x20inside\x20a\x20workspace\x0aor\x20in\x20a\x20remote\x20repository\x20(explained\x20below).\x0a

\x0a\x0a

\x0aThe\x20packages\x20from\x20the\x20standard\x20library\x20are\x20given\x20short\x20import\x20paths\x20such\x20as\x0a\"fmt\"\x20and\x20\"net/http\".\x0aFor\x20your\x20own\x20packages,\x20you\x20must\x20choose\x20a\x20base\x20path\x20that\x20is\x20unlikely\x20to\x0acollide\x20with\x20future\x20additions\x20to\x20the\x20standard\x20library\x20or\x20other\x20external\x0alibraries.\x0a

\x0a\x0a

\x0aIf\x20you\x20keep\x20your\x20code\x20in\x20a\x20source\x20repository\x20somewhere,\x20then\x20you\x20should\x20use\x20the\x0aroot\x20of\x20that\x20source\x20repository\x20as\x20your\x20base\x20path.\x0aFor\x20instance,\x20if\x20you\x20have\x20a\x20GitHub\x20account\x20at\x0agithub.com/user,\x20that\x20should\x20be\x20your\x20base\x20path.\x0a

\x0a\x0a

\x0aNote\x20that\x20you\x20don't\x20need\x20to\x20publish\x20your\x20code\x20to\x20a\x20remote\x20repository\x20before\x20you\x0acan\x20build\x20it.\x20It's\x20just\x20a\x20good\x20habit\x20to\x20organize\x20your\x20code\x20as\x20if\x20you\x20will\x0apublish\x20it\x20someday.\x20In\x20practice\x20you\x20can\x20choose\x20any\x20arbitrary\x20path\x20name,\x0aas\x20long\x20as\x20it\x20is\x20unique\x20to\x20the\x20standard\x20library\x20and\x20greater\x20Go\x20ecosystem.\x0a

\x0a\x0a

\x0aWe'll\x20use\x20github.com/user\x20as\x20our\x20base\x20path.\x20Create\x20a\x20directory\x0ainside\x20your\x20workspace\x20in\x20which\x20to\x20keep\x20source\x20code:\x0a

\x0a\x0a
\x0a$\x20mkdir\x20-p\x20$GOPATH/src/github.com/user\x0a
\x0a\x0a\x0aYour\x20first\x20program\x0a\x0a

\x0aTo\x20compile\x20and\x20run\x20a\x20simple\x20program,\x20first\x20choose\x20a\x20package\x20path\x20(we'll\x20use\x0agithub.com/user/hello)\x20and\x20create\x20a\x20corresponding\x20package\x20directory\x0ainside\x20your\x20workspace:\x0a

\x0a\x0a
\x0a$\x20mkdir\x20$GOPATH/src/github.com/user/hello\x0a
\x0a\x0a

\x0aNext,\x20create\x20a\x20file\x20named\x20hello.go\x20inside\x20that\x20directory,\x0acontaining\x20the\x20following\x20Go\x20code.\x0a

\x0a\x0a
\x0apackage\x20main\x0a\x0aimport\x20\"fmt\"\x0a\x0afunc\x20main()\x20{\x0a\x09fmt.Println(\"Hello,\x20world.\")\x0a}\x0a
\x0a\x0a

\x0aNow\x20you\x20can\x20build\x20and\x20install\x20that\x20program\x20with\x20the\x20go\x20tool:\x0a

\x0a\x0a
\x0a$\x20go\x20install\x20github.com/user/hello\x0a
\x0a\x0a

\x0aNote\x20that\x20you\x20can\x20run\x20this\x20command\x20from\x20anywhere\x20on\x20your\x20system.\x20The\x0ago\x20tool\x20finds\x20the\x20source\x20code\x20by\x20looking\x20for\x20the\x0agithub.com/user/hello\x20package\x20inside\x20the\x20workspace\x20specified\x20by\x0aGOPATH.\x0a

\x0a\x0a

\x0aYou\x20can\x20also\x20omit\x20the\x20package\x20path\x20if\x20you\x20run\x20go\x20install\x20from\x20the\x0apackage\x20directory:\x0a

\x0a\x0a
\x0a$\x20cd\x20$GOPATH/src/github.com/user/hello\x0a$\x20go\x20install\x0a
\x0a\x0a

\x0aThis\x20command\x20builds\x20the\x20hello\x20command,\x20producing\x20an\x20executable\x0abinary.\x20It\x20then\x20installs\x20that\x20binary\x20to\x20the\x20workspace's\x20bin\x0adirectory\x20as\x20hello\x20(or,\x20under\x20Windows,\x20hello.exe).\x0aIn\x20our\x20example,\x20that\x20will\x20be\x20$GOPATH/bin/hello,\x20which\x20is\x0a$HOME/go/bin/hello.\x0a

\x0a\x0a

\x0aThe\x20go\x20tool\x20will\x20only\x20print\x20output\x20when\x20an\x20error\x20occurs,\x20so\x20if\x0athese\x20commands\x20produce\x20no\x20output\x20they\x20have\x20executed\x20successfully.\x0a

\x0a\x0a

\x0aYou\x20can\x20now\x20run\x20the\x20program\x20by\x20typing\x20its\x20full\x20path\x20at\x20the\x20command\x20line:\x0a

\x0a\x0a
\x0a$\x20$GOPATH/bin/hello\x0aHello,\x20world.\x0a
\x0a\x0a

\x0aOr,\x20as\x20you\x20have\x20added\x20$GOPATH/bin\x20to\x20your\x20PATH,\x0ajust\x20type\x20the\x20binary\x20name:\x0a

\x0a\x0a
\x0a$\x20hello\x0aHello,\x20world.\x0a
\x0a\x0a

\x0aIf\x20you're\x20using\x20a\x20source\x20control\x20system,\x20now\x20would\x20be\x20a\x20good\x20time\x20to\x20initialize\x0aa\x20repository,\x20add\x20the\x20files,\x20and\x20commit\x20your\x20first\x20change.\x20Again,\x20this\x20step\x20is\x0aoptional:\x20you\x20do\x20not\x20need\x20to\x20use\x20source\x20control\x20to\x20write\x20Go\x20code.\x0a

\x0a\x0a
\x0a$\x20cd\x20$GOPATH/src/github.com/user/hello\x0a$\x20git\x20init\x0aInitialized\x20empty\x20Git\x20repository\x20in\x20/home/user/go/src/github.com/user/hello/.git/\x0a$\x20git\x20add\x20hello.go\x0a$\x20git\x20commit\x20-m\x20\"initial\x20commit\"\x0a[master\x20(root-commit)\x200b4507d]\x20initial\x20commit\x0a\x201\x20file\x20changed,\x207\x20insertion(+)\x0a\x20create\x20mode\x20100644\x20hello.go\x0a
\x0a\x0a

\x0aPushing\x20the\x20code\x20to\x20a\x20remote\x20repository\x20is\x20left\x20as\x20an\x20exercise\x20for\x20the\x20reader.\x0a

\x0a\x0a\x0aYour\x20first\x20library\x0a\x0a

\x0aLet's\x20write\x20a\x20library\x20and\x20use\x20it\x20from\x20the\x20hello\x20program.\x0a

\x0a\x0a

\x0aAgain,\x20the\x20first\x20step\x20is\x20to\x20choose\x20a\x20package\x20path\x20(we'll\x20use\x0agithub.com/user/stringutil)\x20and\x20create\x20the\x20package\x20directory:\x0a

\x0a\x0a
\x0a$\x20mkdir\x20$GOPATH/src/github.com/user/stringutil\x0a
\x0a\x0a

\x0aNext,\x20create\x20a\x20file\x20named\x20reverse.go\x20in\x20that\x20directory\x20with\x20the\x0afollowing\x20contents.\x0a

\x0a\x0a
\x0a//\x20Package\x20stringutil\x20contains\x20utility\x20functions\x20for\x20working\x20with\x20strings.\x0apackage\x20stringutil\x0a\x0a//\x20Reverse\x20returns\x20its\x20argument\x20string\x20reversed\x20rune-wise\x20left\x20to\x20right.\x0afunc\x20Reverse(s\x20string)\x20string\x20{\x0a\x09r\x20:=\x20[]rune(s)\x0a\x09for\x20i,\x20j\x20:=\x200,\x20len(r)-1;\x20i\x20<\x20len(r)/2;\x20i,\x20j\x20=\x20i+1,\x20j-1\x20{\x0a\x09\x09r[i],\x20r[j]\x20=\x20r[j],\x20r[i]\x0a\x09}\x0a\x09return\x20string(r)\x0a}\x0a
\x0a\x0a

\x0aNow,\x20test\x20that\x20the\x20package\x20compiles\x20with\x20go\x20build:\x0a

\x0a\x0a
\x0a$\x20go\x20build\x20github.com/user/stringutil\x0a
\x0a\x0a

\x0aOr,\x20if\x20you\x20are\x20working\x20in\x20the\x20package's\x20source\x20directory,\x20just:\x0a

\x0a\x0a
\x0a$\x20go\x20build\x0a
\x0a\x0a

\x0aThis\x20won't\x20produce\x20an\x20output\x20file.\x0aInstead\x20it\x20saves\x20the\x20compiled\x20package\x20in\x20the\x20local\x20build\x20cache.\x0a

\x0a\x0a

\x0aAfter\x20confirming\x20that\x20the\x20stringutil\x20package\x20builds,\x0amodify\x20your\x20original\x20hello.go\x20(which\x20is\x20in\x0a$GOPATH/src/github.com/user/hello)\x20to\x20use\x20it:\x0a

\x0a\x0a
\x0apackage\x20main\x0a\x0aimport\x20(\x0a\x09\"fmt\"\x0a\x0a\x09\"github.com/user/stringutil\"\x0a)\x0a\x0afunc\x20main()\x20{\x0a\x09fmt.Println(stringutil.Reverse(\"!oG\x20,olleH\"))\x0a}\x0a
\x0a\x0a

\x0aInstall\x20the\x20hello\x20program:\x0a

\x0a\x0a
\x0a$\x20go\x20install\x20github.com/user/hello\x0a
\x0a\x0a

\x0aRunning\x20the\x20new\x20version\x20of\x20the\x20program,\x20you\x20should\x20see\x20a\x20new,\x20reversed\x20message:\x0a

\x0a\x0a
\x0a$\x20hello\x0aHello,\x20Go!\x0a
\x0a\x0a

\x0aAfter\x20the\x20steps\x20above,\x20your\x20workspace\x20should\x20look\x20like\x20this:\x0a

\x0a\x0a
\x0abin/\x0a\x20\x20\x20\x20hello\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20command\x20executable\x0asrc/\x0a\x20\x20\x20\x20github.com/user/\x0a\x20\x20\x20\x20\x20\x20\x20\x20hello/\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20hello.go\x20\x20\x20\x20\x20\x20#\x20command\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20stringutil/\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20reverse.go\x20\x20\x20\x20#\x20package\x20source\x0a
\x0a\x0aPackage\x20names\x0a\x0a

\x0aThe\x20first\x20statement\x20in\x20a\x20Go\x20source\x20file\x20must\x20be\x0a

\x0a\x0a
\x0apackage\x20name\x0a
\x0a\x0a

\x0awhere\x20name\x20is\x20the\x20package's\x20default\x20name\x20for\x20imports.\x0a(All\x20files\x20in\x20a\x20package\x20must\x20use\x20the\x20same\x20name.)\x0a

\x0a\x0a

\x0aGo's\x20convention\x20is\x20that\x20the\x20package\x20name\x20is\x20the\x20last\x20element\x20of\x20the\x0aimport\x20path:\x20the\x20package\x20imported\x20as\x20\"crypto/rot13\"\x0ashould\x20be\x20named\x20rot13.\x0a

\x0a\x0a

\x0aExecutable\x20commands\x20must\x20always\x20use\x20package\x20main.\x0a

\x0a\x0a

\x0aThere\x20is\x20no\x20requirement\x20that\x20package\x20names\x20be\x20unique\x0aacross\x20all\x20packages\x20linked\x20into\x20a\x20single\x20binary,\x0aonly\x20that\x20the\x20import\x20paths\x20(their\x20full\x20file\x20names)\x20be\x20unique.\x0a

\x0a\x0a

\x0aSee\x20Effective\x20Go\x20to\x20learn\x20more\x20about\x0aGo's\x20naming\x20conventions.\x0a

\x0a\x0a\x0aTesting\x0a\x0a

\x0aGo\x20has\x20a\x20lightweight\x20test\x20framework\x20composed\x20of\x20the\x20go\x20test\x0acommand\x20and\x20the\x20testing\x20package.\x0a

\x0a\x0a

\x0aYou\x20write\x20a\x20test\x20by\x20creating\x20a\x20file\x20with\x20a\x20name\x20ending\x20in\x20_test.go\x0athat\x20contains\x20functions\x20named\x20TestXXX\x20with\x20signature\x0afunc\x20(t\x20*testing.T).\x0aThe\x20test\x20framework\x20runs\x20each\x20such\x20function;\x0aif\x20the\x20function\x20calls\x20a\x20failure\x20function\x20such\x20as\x20t.Error\x20or\x0at.Fail,\x20the\x20test\x20is\x20considered\x20to\x20have\x20failed.\x0a

\x0a\x0a

\x0aAdd\x20a\x20test\x20to\x20the\x20stringutil\x20package\x20by\x20creating\x20the\x20file\x0a$GOPATH/src/github.com/user/stringutil/reverse_test.go\x20containing\x0athe\x20following\x20Go\x20code.\x0a

\x0a\x0a
\x0apackage\x20stringutil\x0a\x0aimport\x20\"testing\"\x0a\x0afunc\x20TestReverse(t\x20*testing.T)\x20{\x0a\x09cases\x20:=\x20[]struct\x20{\x0a\x09\x09in,\x20want\x20string\x0a\x09}{\x0a\x09\x09{\"Hello,\x20world\",\x20\"dlrow\x20,olleH\"},\x0a\x09\x09{\"Hello,\x20\xe4\xb8\x96\xe7\x95\x8c\",\x20\"\xe7\x95\x8c\xe4\xb8\x96\x20,olleH\"},\x0a\x09\x09{\"\",\x20\"\"},\x0a\x09}\x0a\x09for\x20_,\x20c\x20:=\x20range\x20cases\x20{\x0a\x09\x09got\x20:=\x20Reverse(c.in)\x0a\x09\x09if\x20got\x20!=\x20c.want\x20{\x0a\x09\x09\x09t.Errorf(\"Reverse(%q)\x20==\x20%q,\x20want\x20%q\",\x20c.in,\x20got,\x20c.want)\x0a\x09\x09}\x0a\x09}\x0a}\x0a
\x0a\x0a

\x0aThen\x20run\x20the\x20test\x20with\x20go\x20test:\x0a

\x0a\x0a
\x0a$\x20go\x20test\x20github.com/user/stringutil\x0aok\x20\x20\x09github.com/user/stringutil\x200.165s\x0a
\x0a\x0a

\x0aAs\x20always,\x20if\x20you\x20are\x20running\x20the\x20go\x20tool\x20from\x20the\x20package\x0adirectory,\x20you\x20can\x20omit\x20the\x20package\x20path:\x0a

\x0a\x0a
\x0a$\x20go\x20test\x0aok\x20\x20\x09github.com/user/stringutil\x200.165s\x0a
\x0a\x0a

\x0aRun\x20go\x20help\x20test\x20and\x20see\x20the\x0atesting\x20package\x20documentation\x20for\x20more\x20detail.\x0a

\x0a\x0a\x0aRemote\x20packages\x0a\x0a

\x0aAn\x20import\x20path\x20can\x20describe\x20how\x20to\x20obtain\x20the\x20package\x20source\x20code\x20using\x20a\x0arevision\x20control\x20system\x20such\x20as\x20Git\x20or\x20Mercurial.\x20The\x20go\x20tool\x20uses\x0athis\x20property\x20to\x20automatically\x20fetch\x20packages\x20from\x20remote\x20repositories.\x0aFor\x20instance,\x20the\x20examples\x20described\x20in\x20this\x20document\x20are\x20also\x20kept\x20in\x20a\x0aGit\x20repository\x20hosted\x20at\x20GitHub\x0agithub.com/golang/example.\x0aIf\x20you\x20include\x20the\x20repository\x20URL\x20in\x20the\x20package's\x20import\x20path,\x0ago\x20get\x20will\x20fetch,\x20build,\x20and\x20install\x20it\x20automatically:\x0a

\x0a\x0a
\x0a$\x20go\x20get\x20github.com/golang/example/hello\x0a$\x20$GOPATH/bin/hello\x0aHello,\x20Go\x20examples!\x0a
\x0a\x0a

\x0aIf\x20the\x20specified\x20package\x20is\x20not\x20present\x20in\x20a\x20workspace,\x20go\x20get\x0awill\x20place\x20it\x20inside\x20the\x20first\x20workspace\x20specified\x20by\x20GOPATH.\x0a(If\x20the\x20package\x20does\x20already\x20exist,\x20go\x20get\x20skips\x20the\x20remote\x0afetch\x20and\x20behaves\x20the\x20same\x20as\x20go\x20install.)\x0a

\x0a\x0a

\x0aAfter\x20issuing\x20the\x20above\x20go\x20get\x20command,\x20the\x20workspace\x20directory\x0atree\x20should\x20now\x20look\x20like\x20this:\x0a

\x0a\x0a
\x0abin/\x0a\x20\x20\x20\x20hello\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20command\x20executable\x0asrc/\x0a\x20\x20\x20\x20github.com/golang/example/\x0a\x09.git/\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20Git\x20repository\x20metadata\x0a\x20\x20\x20\x20\x20\x20\x20\x20hello/\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20hello.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20command\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20stringutil/\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20reverse.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20package\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20reverse_test.go\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20test\x20source\x0a\x20\x20\x20\x20github.com/user/\x0a\x20\x20\x20\x20\x20\x20\x20\x20hello/\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20hello.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20command\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20stringutil/\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20reverse.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20package\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20reverse_test.go\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20test\x20source\x0a
\x0a\x0a

\x0aThe\x20hello\x20command\x20hosted\x20at\x20GitHub\x20depends\x20on\x20the\x0astringutil\x20package\x20within\x20the\x20same\x20repository.\x20The\x20imports\x20in\x0ahello.go\x20file\x20use\x20the\x20same\x20import\x20path\x20convention,\x20so\x20the\x0ago\x20get\x20command\x20is\x20able\x20to\x20locate\x20and\x20install\x20the\x20dependent\x0apackage,\x20too.\x0a

\x0a\x0a
\x0aimport\x20\"github.com/golang/example/stringutil\"\x0a
\x0a\x0a

\x0aThis\x20convention\x20is\x20the\x20easiest\x20way\x20to\x20make\x20your\x20Go\x20packages\x20available\x20for\x0aothers\x20to\x20use.\x0aThe\x20Go\x20Wiki\x0aand\x20godoc.org\x0aprovide\x20lists\x20of\x20external\x20Go\x20projects.\x0a

\x0a\x0a

\x0aFor\x20more\x20information\x20on\x20using\x20remote\x20repositories\x20with\x20the\x20go\x20tool,\x20see\x0ago\x20help\x20importpath.\x0a

\x0a\x0a\x0aWhat's\x20next\x0a\x0a

\x0aSubscribe\x20to\x20the\x0agolang-announce\x0amailing\x20list\x20to\x20be\x20notified\x20when\x20a\x20new\x20stable\x20version\x20of\x20Go\x20is\x20released.\x0a

\x0a\x0a

\x0aSee\x20Effective\x20Go\x20for\x20tips\x20on\x20writing\x0aclear,\x20idiomatic\x20Go\x20code.\x0a

\x0a\x0a

\x0aTake\x20A\x20Tour\x20of\x20Go\x20to\x20learn\x20the\x20language\x0aproper.\x0a

\x0a\x0a

\x0aVisit\x20the\x20documentation\x20page\x20for\x20a\x20set\x20of\x20in-depth\x0aarticles\x20about\x20the\x20Go\x20language\x20and\x20its\x20libraries\x20and\x20tools.\x0a

\x0a\x0a\x0aGetting\x20help\x0a\x0a

\x0aFor\x20real-time\x20help,\x20ask\x20the\x20helpful\x20gophers\x20in\x20#go-nuts\x20on\x20the\x0aFreenode\x20IRC\x20server.\x0a

\x0a\x0a

\x0aThe\x20official\x20mailing\x20list\x20for\x20discussion\x20of\x20the\x20Go\x20language\x20is\x0aGo\x20Nuts.\x0a

\x0a\x0a

\x0aReport\x20bugs\x20using\x20the\x0aGo\x20issue\x20tracker.\x0a

\x0a", + "doc/gopath_code.html": "\x0a\x0aIntroduction\x0a\x0a

\x0aIf\x20you\x20are\x20new\x20to\x20Go,\x20please\x20see\x20the\x20more\x20recent\x0aHow\x20to\x20Write\x20Go\x20Code.\x0a

\x0a\x0a

\x0aThis\x20document\x20demonstrates\x20the\x20development\x20of\x20a\x20simple\x20Go\x20package\x20and\x0aintroduces\x20the\x20go\x20tool,\x20the\x20standard\x20way\x20to\x20fetch,\x0abuild,\x20and\x20install\x20Go\x20packages\x20and\x20commands.\x0a

\x0a\x0a

\x0aThe\x20go\x20tool\x20requires\x20you\x20to\x20organize\x20your\x20code\x20in\x20a\x20specific\x0away.\x20Please\x20read\x20this\x20document\x20carefully.\x0aIt\x20explains\x20the\x20simplest\x20way\x20to\x20get\x20up\x20and\x20running\x20with\x20your\x20Go\x20installation.\x0a

\x0a\x0a

\x0aA\x20similar\x20explanation\x20is\x20available\x20as\x20a\x0ascreencast.\x0a

\x0a\x0a\x0aCode\x20organization\x0a\x0aOverview\x0a\x0a
    \x0a\x09
  • Go\x20programmers\x20typically\x20keep\x20all\x20their\x20Go\x20code\x20in\x20a\x20single\x20workspace.
  • \x0a\x09
  • A\x20workspace\x20contains\x20many\x20version\x20control\x20repositories\x0a\x09\x20\x20\x20\x20(managed\x20by\x20Git,\x20for\x20example).
  • \x0a\x09
  • Each\x20repository\x20contains\x20one\x20or\x20more\x20packages.
  • \x0a\x09
  • Each\x20package\x20consists\x20of\x20one\x20or\x20more\x20Go\x20source\x20files\x20in\x20a\x20single\x20directory.
  • \x0a\x09
  • The\x20path\x20to\x20a\x20package's\x20directory\x20determines\x20its\x20import\x20path.
  • \x0a
\x0a\x0a

\x0aNote\x20that\x20this\x20differs\x20from\x20other\x20programming\x20environments\x20in\x20which\x20every\x0aproject\x20has\x20a\x20separate\x20workspace\x20and\x20workspaces\x20are\x20closely\x20tied\x20to\x20version\x0acontrol\x20repositories.\x0a

\x0a\x0aWorkspaces\x0a\x0a

\x0aA\x20workspace\x20is\x20a\x20directory\x20hierarchy\x20with\x20two\x20directories\x20at\x20its\x20root:\x0a

\x0a\x0a
    \x0a
  • src\x20contains\x20Go\x20source\x20files,\x20and\x0a
  • bin\x20contains\x20executable\x20commands.\x0a
\x0a\x0a

\x0aThe\x20go\x20tool\x20builds\x20and\x20installs\x20binaries\x20to\x20the\x20bin\x20directory.\x0a

\x0a\x0a

\x0aThe\x20src\x20subdirectory\x20typically\x20contains\x20multiple\x20version\x20control\x0arepositories\x20(such\x20as\x20for\x20Git\x20or\x20Mercurial)\x20that\x20track\x20the\x20development\x20of\x20one\x0aor\x20more\x20source\x20packages.\x0a

\x0a\x0a

\x0aTo\x20give\x20you\x20an\x20idea\x20of\x20how\x20a\x20workspace\x20looks\x20in\x20practice,\x20here's\x20an\x20example:\x0a

\x0a\x0a
\x0abin/\x0a\x20\x20\x20\x20hello\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20command\x20executable\x0a\x20\x20\x20\x20outyet\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20command\x20executable\x0asrc/\x0a\x20\x20\x20\x20github.com/golang/example/\x0a\x20\x20\x20\x20\x20\x20\x20\x20.git/\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20Git\x20repository\x20metadata\x0a\x09hello/\x0a\x09\x20\x20\x20\x20hello.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20command\x20source\x0a\x09outyet/\x0a\x09\x20\x20\x20\x20main.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20command\x20source\x0a\x09\x20\x20\x20\x20main_test.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20test\x20source\x0a\x09stringutil/\x0a\x09\x20\x20\x20\x20reverse.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20package\x20source\x0a\x09\x20\x20\x20\x20reverse_test.go\x20\x20\x20\x20\x20\x20\x20\x20#\x20test\x20source\x0a\x20\x20\x20\x20golang.org/x/image/\x0a\x20\x20\x20\x20\x20\x20\x20\x20.git/\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20Git\x20repository\x20metadata\x0a\x09bmp/\x0a\x09\x20\x20\x20\x20reader.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20package\x20source\x0a\x09\x20\x20\x20\x20writer.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20package\x20source\x0a\x20\x20\x20\x20...\x20(many\x20more\x20repositories\x20and\x20packages\x20omitted)\x20...\x0a
\x0a\x0a

\x0aThe\x20tree\x20above\x20shows\x20a\x20workspace\x20containing\x20two\x20repositories\x0a(example\x20and\x20image).\x0aThe\x20example\x20repository\x20contains\x20two\x20commands\x20(hello\x0aand\x20outyet)\x20and\x20one\x20library\x20(stringutil).\x0aThe\x20image\x20repository\x20contains\x20the\x20bmp\x20package\x0aand\x20several\x20others.\x0a

\x0a\x0a

\x0aA\x20typical\x20workspace\x20contains\x20many\x20source\x20repositories\x20containing\x20many\x0apackages\x20and\x20commands.\x20Most\x20Go\x20programmers\x20keep\x20all\x20their\x20Go\x20source\x20code\x0aand\x20dependencies\x20in\x20a\x20single\x20workspace.\x0a

\x0a\x0a

\x0aNote\x20that\x20symbolic\x20links\x20should\x20not\x20be\x20used\x20to\x20link\x20files\x20or\x20directories\x20into\x20your\x20workspace.\x0a

\x0a\x0a

\x0aCommands\x20and\x20libraries\x20are\x20built\x20from\x20different\x20kinds\x20of\x20source\x20packages.\x0aWe\x20will\x20discuss\x20the\x20distinction\x20later.\x0a

\x0a\x0a\x0aThe\x20GOPATH\x20environment\x20variable\x0a\x0a

\x0aThe\x20GOPATH\x20environment\x20variable\x20specifies\x20the\x20location\x20of\x20your\x0aworkspace.\x20It\x20defaults\x20to\x20a\x20directory\x20named\x20go\x20inside\x20your\x20home\x20directory,\x0aso\x20$HOME/go\x20on\x20Unix,\x0a$home/go\x20on\x20Plan\x209,\x0aand\x20%USERPROFILE%\\go\x20(usually\x20C:\\Users\\YourName\\go)\x20on\x20Windows.\x0a

\x0a\x0a

\x0aIf\x20you\x20would\x20like\x20to\x20work\x20in\x20a\x20different\x20location,\x20you\x20will\x20need\x20to\x0aset\x20GOPATH\x0ato\x20the\x20path\x20to\x20that\x20directory.\x0a(Another\x20common\x20setup\x20is\x20to\x20set\x20GOPATH=$HOME.)\x0aNote\x20that\x20GOPATH\x20must\x20not\x20be\x20the\x0asame\x20path\x20as\x20your\x20Go\x20installation.\x0a

\x0a\x0a

\x0aThe\x20command\x20go\x20env\x20GOPATH\x0aprints\x20the\x20effective\x20current\x20GOPATH;\x0ait\x20prints\x20the\x20default\x20location\x20if\x20the\x20environment\x20variable\x20is\x20unset.\x0a

\x0a\x0a

\x0aFor\x20convenience,\x20add\x20the\x20workspace's\x20bin\x20subdirectory\x0ato\x20your\x20PATH:\x0a

\x0a\x0a
\x0a$\x20export\x20PATH=$PATH:$(go\x20env\x20GOPATH)/bin\x0a
\x0a\x0a

\x0aThe\x20scripts\x20in\x20the\x20rest\x20of\x20this\x20document\x20use\x20$GOPATH\x0ainstead\x20of\x20$(go\x20env\x20GOPATH)\x20for\x20brevity.\x0aTo\x20make\x20the\x20scripts\x20run\x20as\x20written\x0aif\x20you\x20have\x20not\x20set\x20GOPATH,\x0ayou\x20can\x20substitute\x20$HOME/go\x20in\x20those\x20commands\x0aor\x20else\x20run:\x0a

\x0a\x0a
\x0a$\x20export\x20GOPATH=$(go\x20env\x20GOPATH)\x0a
\x0a\x0a

\x0aTo\x20learn\x20more\x20about\x20the\x20GOPATH\x20environment\x20variable,\x20see\x0a'go\x20help\x20gopath'.\x0a

\x0a\x0aImport\x20paths\x0a\x0a

\x0aAn\x20import\x20path\x20is\x20a\x20string\x20that\x20uniquely\x20identifies\x20a\x20package.\x0aA\x20package's\x20import\x20path\x20corresponds\x20to\x20its\x20location\x20inside\x20a\x20workspace\x0aor\x20in\x20a\x20remote\x20repository\x20(explained\x20below).\x0a

\x0a\x0a

\x0aThe\x20packages\x20from\x20the\x20standard\x20library\x20are\x20given\x20short\x20import\x20paths\x20such\x20as\x0a\"fmt\"\x20and\x20\"net/http\".\x0aFor\x20your\x20own\x20packages,\x20you\x20must\x20choose\x20a\x20base\x20path\x20that\x20is\x20unlikely\x20to\x0acollide\x20with\x20future\x20additions\x20to\x20the\x20standard\x20library\x20or\x20other\x20external\x0alibraries.\x0a

\x0a\x0a

\x0aIf\x20you\x20keep\x20your\x20code\x20in\x20a\x20source\x20repository\x20somewhere,\x20then\x20you\x20should\x20use\x20the\x0aroot\x20of\x20that\x20source\x20repository\x20as\x20your\x20base\x20path.\x0aFor\x20instance,\x20if\x20you\x20have\x20a\x20GitHub\x20account\x20at\x0agithub.com/user,\x20that\x20should\x20be\x20your\x20base\x20path.\x0a

\x0a\x0a

\x0aNote\x20that\x20you\x20don't\x20need\x20to\x20publish\x20your\x20code\x20to\x20a\x20remote\x20repository\x20before\x20you\x0acan\x20build\x20it.\x20It's\x20just\x20a\x20good\x20habit\x20to\x20organize\x20your\x20code\x20as\x20if\x20you\x20will\x0apublish\x20it\x20someday.\x20In\x20practice\x20you\x20can\x20choose\x20any\x20arbitrary\x20path\x20name,\x0aas\x20long\x20as\x20it\x20is\x20unique\x20to\x20the\x20standard\x20library\x20and\x20greater\x20Go\x20ecosystem.\x0a

\x0a\x0a

\x0aWe'll\x20use\x20github.com/user\x20as\x20our\x20base\x20path.\x20Create\x20a\x20directory\x0ainside\x20your\x20workspace\x20in\x20which\x20to\x20keep\x20source\x20code:\x0a

\x0a\x0a
\x0a$\x20mkdir\x20-p\x20$GOPATH/src/github.com/user\x0a
\x0a\x0a\x0aYour\x20first\x20program\x0a\x0a

\x0aTo\x20compile\x20and\x20run\x20a\x20simple\x20program,\x20first\x20choose\x20a\x20package\x20path\x20(we'll\x20use\x0agithub.com/user/hello)\x20and\x20create\x20a\x20corresponding\x20package\x20directory\x0ainside\x20your\x20workspace:\x0a

\x0a\x0a
\x0a$\x20mkdir\x20$GOPATH/src/github.com/user/hello\x0a
\x0a\x0a

\x0aNext,\x20create\x20a\x20file\x20named\x20hello.go\x20inside\x20that\x20directory,\x0acontaining\x20the\x20following\x20Go\x20code.\x0a

\x0a\x0a
\x0apackage\x20main\x0a\x0aimport\x20\"fmt\"\x0a\x0afunc\x20main()\x20{\x0a\x09fmt.Println(\"Hello,\x20world.\")\x0a}\x0a
\x0a\x0a

\x0aNow\x20you\x20can\x20build\x20and\x20install\x20that\x20program\x20with\x20the\x20go\x20tool:\x0a

\x0a\x0a
\x0a$\x20go\x20install\x20github.com/user/hello\x0a
\x0a\x0a

\x0aNote\x20that\x20you\x20can\x20run\x20this\x20command\x20from\x20anywhere\x20on\x20your\x20system.\x20The\x0ago\x20tool\x20finds\x20the\x20source\x20code\x20by\x20looking\x20for\x20the\x0agithub.com/user/hello\x20package\x20inside\x20the\x20workspace\x20specified\x20by\x0aGOPATH.\x0a

\x0a\x0a

\x0aYou\x20can\x20also\x20omit\x20the\x20package\x20path\x20if\x20you\x20run\x20go\x20install\x20from\x20the\x0apackage\x20directory:\x0a

\x0a\x0a
\x0a$\x20cd\x20$GOPATH/src/github.com/user/hello\x0a$\x20go\x20install\x0a
\x0a\x0a

\x0aThis\x20command\x20builds\x20the\x20hello\x20command,\x20producing\x20an\x20executable\x0abinary.\x20It\x20then\x20installs\x20that\x20binary\x20to\x20the\x20workspace's\x20bin\x0adirectory\x20as\x20hello\x20(or,\x20under\x20Windows,\x20hello.exe).\x0aIn\x20our\x20example,\x20that\x20will\x20be\x20$GOPATH/bin/hello,\x20which\x20is\x0a$HOME/go/bin/hello.\x0a

\x0a\x0a

\x0aThe\x20go\x20tool\x20will\x20only\x20print\x20output\x20when\x20an\x20error\x20occurs,\x20so\x20if\x0athese\x20commands\x20produce\x20no\x20output\x20they\x20have\x20executed\x20successfully.\x0a

\x0a\x0a

\x0aYou\x20can\x20now\x20run\x20the\x20program\x20by\x20typing\x20its\x20full\x20path\x20at\x20the\x20command\x20line:\x0a

\x0a\x0a
\x0a$\x20$GOPATH/bin/hello\x0aHello,\x20world.\x0a
\x0a\x0a

\x0aOr,\x20as\x20you\x20have\x20added\x20$GOPATH/bin\x20to\x20your\x20PATH,\x0ajust\x20type\x20the\x20binary\x20name:\x0a

\x0a\x0a
\x0a$\x20hello\x0aHello,\x20world.\x0a
\x0a\x0a

\x0aIf\x20you're\x20using\x20a\x20source\x20control\x20system,\x20now\x20would\x20be\x20a\x20good\x20time\x20to\x20initialize\x0aa\x20repository,\x20add\x20the\x20files,\x20and\x20commit\x20your\x20first\x20change.\x20Again,\x20this\x20step\x20is\x0aoptional:\x20you\x20do\x20not\x20need\x20to\x20use\x20source\x20control\x20to\x20write\x20Go\x20code.\x0a

\x0a\x0a
\x0a$\x20cd\x20$GOPATH/src/github.com/user/hello\x0a$\x20git\x20init\x0aInitialized\x20empty\x20Git\x20repository\x20in\x20/home/user/go/src/github.com/user/hello/.git/\x0a$\x20git\x20add\x20hello.go\x0a$\x20git\x20commit\x20-m\x20\"initial\x20commit\"\x0a[master\x20(root-commit)\x200b4507d]\x20initial\x20commit\x0a\x201\x20file\x20changed,\x207\x20insertion(+)\x0a\x20create\x20mode\x20100644\x20hello.go\x0a
\x0a\x0a

\x0aPushing\x20the\x20code\x20to\x20a\x20remote\x20repository\x20is\x20left\x20as\x20an\x20exercise\x20for\x20the\x20reader.\x0a

\x0a\x0a\x0aYour\x20first\x20library\x0a\x0a

\x0aLet's\x20write\x20a\x20library\x20and\x20use\x20it\x20from\x20the\x20hello\x20program.\x0a

\x0a\x0a

\x0aAgain,\x20the\x20first\x20step\x20is\x20to\x20choose\x20a\x20package\x20path\x20(we'll\x20use\x0agithub.com/user/stringutil)\x20and\x20create\x20the\x20package\x20directory:\x0a

\x0a\x0a
\x0a$\x20mkdir\x20$GOPATH/src/github.com/user/stringutil\x0a
\x0a\x0a

\x0aNext,\x20create\x20a\x20file\x20named\x20reverse.go\x20in\x20that\x20directory\x20with\x20the\x0afollowing\x20contents.\x0a

\x0a\x0a
\x0a//\x20Package\x20stringutil\x20contains\x20utility\x20functions\x20for\x20working\x20with\x20strings.\x0apackage\x20stringutil\x0a\x0a//\x20Reverse\x20returns\x20its\x20argument\x20string\x20reversed\x20rune-wise\x20left\x20to\x20right.\x0afunc\x20Reverse(s\x20string)\x20string\x20{\x0a\x09r\x20:=\x20[]rune(s)\x0a\x09for\x20i,\x20j\x20:=\x200,\x20len(r)-1;\x20i\x20<\x20len(r)/2;\x20i,\x20j\x20=\x20i+1,\x20j-1\x20{\x0a\x09\x09r[i],\x20r[j]\x20=\x20r[j],\x20r[i]\x0a\x09}\x0a\x09return\x20string(r)\x0a}\x0a
\x0a\x0a

\x0aNow,\x20test\x20that\x20the\x20package\x20compiles\x20with\x20go\x20build:\x0a

\x0a\x0a
\x0a$\x20go\x20build\x20github.com/user/stringutil\x0a
\x0a\x0a

\x0aOr,\x20if\x20you\x20are\x20working\x20in\x20the\x20package's\x20source\x20directory,\x20just:\x0a

\x0a\x0a
\x0a$\x20go\x20build\x0a
\x0a\x0a

\x0aThis\x20won't\x20produce\x20an\x20output\x20file.\x0aInstead\x20it\x20saves\x20the\x20compiled\x20package\x20in\x20the\x20local\x20build\x20cache.\x0a

\x0a\x0a

\x0aAfter\x20confirming\x20that\x20the\x20stringutil\x20package\x20builds,\x0amodify\x20your\x20original\x20hello.go\x20(which\x20is\x20in\x0a$GOPATH/src/github.com/user/hello)\x20to\x20use\x20it:\x0a

\x0a\x0a
\x0apackage\x20main\x0a\x0aimport\x20(\x0a\x09\"fmt\"\x0a\x0a\x09\"github.com/user/stringutil\"\x0a)\x0a\x0afunc\x20main()\x20{\x0a\x09fmt.Println(stringutil.Reverse(\"!oG\x20,olleH\"))\x0a}\x0a
\x0a\x0a

\x0aInstall\x20the\x20hello\x20program:\x0a

\x0a\x0a
\x0a$\x20go\x20install\x20github.com/user/hello\x0a
\x0a\x0a

\x0aRunning\x20the\x20new\x20version\x20of\x20the\x20program,\x20you\x20should\x20see\x20a\x20new,\x20reversed\x20message:\x0a

\x0a\x0a
\x0a$\x20hello\x0aHello,\x20Go!\x0a
\x0a\x0a

\x0aAfter\x20the\x20steps\x20above,\x20your\x20workspace\x20should\x20look\x20like\x20this:\x0a

\x0a\x0a
\x0abin/\x0a\x20\x20\x20\x20hello\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20command\x20executable\x0asrc/\x0a\x20\x20\x20\x20github.com/user/\x0a\x20\x20\x20\x20\x20\x20\x20\x20hello/\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20hello.go\x20\x20\x20\x20\x20\x20#\x20command\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20stringutil/\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20reverse.go\x20\x20\x20\x20#\x20package\x20source\x0a
\x0a\x0aPackage\x20names\x0a\x0a

\x0aThe\x20first\x20statement\x20in\x20a\x20Go\x20source\x20file\x20must\x20be\x0a

\x0a\x0a
\x0apackage\x20name\x0a
\x0a\x0a

\x0awhere\x20name\x20is\x20the\x20package's\x20default\x20name\x20for\x20imports.\x0a(All\x20files\x20in\x20a\x20package\x20must\x20use\x20the\x20same\x20name.)\x0a

\x0a\x0a

\x0aGo's\x20convention\x20is\x20that\x20the\x20package\x20name\x20is\x20the\x20last\x20element\x20of\x20the\x0aimport\x20path:\x20the\x20package\x20imported\x20as\x20\"crypto/rot13\"\x0ashould\x20be\x20named\x20rot13.\x0a

\x0a\x0a

\x0aExecutable\x20commands\x20must\x20always\x20use\x20package\x20main.\x0a

\x0a\x0a

\x0aThere\x20is\x20no\x20requirement\x20that\x20package\x20names\x20be\x20unique\x0aacross\x20all\x20packages\x20linked\x20into\x20a\x20single\x20binary,\x0aonly\x20that\x20the\x20import\x20paths\x20(their\x20full\x20file\x20names)\x20be\x20unique.\x0a

\x0a\x0a

\x0aSee\x20Effective\x20Go\x20to\x20learn\x20more\x20about\x0aGo's\x20naming\x20conventions.\x0a

\x0a\x0a\x0aTesting\x0a\x0a

\x0aGo\x20has\x20a\x20lightweight\x20test\x20framework\x20composed\x20of\x20the\x20go\x20test\x0acommand\x20and\x20the\x20testing\x20package.\x0a

\x0a\x0a

\x0aYou\x20write\x20a\x20test\x20by\x20creating\x20a\x20file\x20with\x20a\x20name\x20ending\x20in\x20_test.go\x0athat\x20contains\x20functions\x20named\x20TestXXX\x20with\x20signature\x0afunc\x20(t\x20*testing.T).\x0aThe\x20test\x20framework\x20runs\x20each\x20such\x20function;\x0aif\x20the\x20function\x20calls\x20a\x20failure\x20function\x20such\x20as\x20t.Error\x20or\x0at.Fail,\x20the\x20test\x20is\x20considered\x20to\x20have\x20failed.\x0a

\x0a\x0a

\x0aAdd\x20a\x20test\x20to\x20the\x20stringutil\x20package\x20by\x20creating\x20the\x20file\x0a$GOPATH/src/github.com/user/stringutil/reverse_test.go\x20containing\x0athe\x20following\x20Go\x20code.\x0a

\x0a\x0a
\x0apackage\x20stringutil\x0a\x0aimport\x20\"testing\"\x0a\x0afunc\x20TestReverse(t\x20*testing.T)\x20{\x0a\x09cases\x20:=\x20[]struct\x20{\x0a\x09\x09in,\x20want\x20string\x0a\x09}{\x0a\x09\x09{\"Hello,\x20world\",\x20\"dlrow\x20,olleH\"},\x0a\x09\x09{\"Hello,\x20\xe4\xb8\x96\xe7\x95\x8c\",\x20\"\xe7\x95\x8c\xe4\xb8\x96\x20,olleH\"},\x0a\x09\x09{\"\",\x20\"\"},\x0a\x09}\x0a\x09for\x20_,\x20c\x20:=\x20range\x20cases\x20{\x0a\x09\x09got\x20:=\x20Reverse(c.in)\x0a\x09\x09if\x20got\x20!=\x20c.want\x20{\x0a\x09\x09\x09t.Errorf(\"Reverse(%q)\x20==\x20%q,\x20want\x20%q\",\x20c.in,\x20got,\x20c.want)\x0a\x09\x09}\x0a\x09}\x0a}\x0a
\x0a\x0a

\x0aThen\x20run\x20the\x20test\x20with\x20go\x20test:\x0a

\x0a\x0a
\x0a$\x20go\x20test\x20github.com/user/stringutil\x0aok\x20\x20\x09github.com/user/stringutil\x200.165s\x0a
\x0a\x0a

\x0aAs\x20always,\x20if\x20you\x20are\x20running\x20the\x20go\x20tool\x20from\x20the\x20package\x0adirectory,\x20you\x20can\x20omit\x20the\x20package\x20path:\x0a

\x0a\x0a
\x0a$\x20go\x20test\x0aok\x20\x20\x09github.com/user/stringutil\x200.165s\x0a
\x0a\x0a

\x0aRun\x20go\x20help\x20test\x20and\x20see\x20the\x0atesting\x20package\x20documentation\x20for\x20more\x20detail.\x0a

\x0a\x0a\x0aRemote\x20packages\x0a\x0a

\x0aAn\x20import\x20path\x20can\x20describe\x20how\x20to\x20obtain\x20the\x20package\x20source\x20code\x20using\x20a\x0arevision\x20control\x20system\x20such\x20as\x20Git\x20or\x20Mercurial.\x20The\x20go\x20tool\x20uses\x0athis\x20property\x20to\x20automatically\x20fetch\x20packages\x20from\x20remote\x20repositories.\x0aFor\x20instance,\x20the\x20examples\x20described\x20in\x20this\x20document\x20are\x20also\x20kept\x20in\x20a\x0aGit\x20repository\x20hosted\x20at\x20GitHub\x0agithub.com/golang/example.\x0aIf\x20you\x20include\x20the\x20repository\x20URL\x20in\x20the\x20package's\x20import\x20path,\x0ago\x20get\x20will\x20fetch,\x20build,\x20and\x20install\x20it\x20automatically:\x0a

\x0a\x0a
\x0a$\x20go\x20get\x20github.com/golang/example/hello\x0a$\x20$GOPATH/bin/hello\x0aHello,\x20Go\x20examples!\x0a
\x0a\x0a

\x0aIf\x20the\x20specified\x20package\x20is\x20not\x20present\x20in\x20a\x20workspace,\x20go\x20get\x0awill\x20place\x20it\x20inside\x20the\x20first\x20workspace\x20specified\x20by\x20GOPATH.\x0a(If\x20the\x20package\x20does\x20already\x20exist,\x20go\x20get\x20skips\x20the\x20remote\x0afetch\x20and\x20behaves\x20the\x20same\x20as\x20go\x20install.)\x0a

\x0a\x0a

\x0aAfter\x20issuing\x20the\x20above\x20go\x20get\x20command,\x20the\x20workspace\x20directory\x0atree\x20should\x20now\x20look\x20like\x20this:\x0a

\x0a\x0a
\x0abin/\x0a\x20\x20\x20\x20hello\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20command\x20executable\x0asrc/\x0a\x20\x20\x20\x20github.com/golang/example/\x0a\x09.git/\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20Git\x20repository\x20metadata\x0a\x20\x20\x20\x20\x20\x20\x20\x20hello/\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20hello.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20command\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20stringutil/\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20reverse.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20package\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20reverse_test.go\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20test\x20source\x0a\x20\x20\x20\x20github.com/user/\x0a\x20\x20\x20\x20\x20\x20\x20\x20hello/\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20hello.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20command\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20stringutil/\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20reverse.go\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20package\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20reverse_test.go\x20\x20\x20\x20\x20\x20\x20\x20\x20#\x20test\x20source\x0a
\x0a\x0a

\x0aThe\x20hello\x20command\x20hosted\x20at\x20GitHub\x20depends\x20on\x20the\x0astringutil\x20package\x20within\x20the\x20same\x20repository.\x20The\x20imports\x20in\x0ahello.go\x20file\x20use\x20the\x20same\x20import\x20path\x20convention,\x20so\x20the\x0ago\x20get\x20command\x20is\x20able\x20to\x20locate\x20and\x20install\x20the\x20dependent\x0apackage,\x20too.\x0a

\x0a\x0a
\x0aimport\x20\"github.com/golang/example/stringutil\"\x0a
\x0a\x0a

\x0aThis\x20convention\x20is\x20the\x20easiest\x20way\x20to\x20make\x20your\x20Go\x20packages\x20available\x20for\x0aothers\x20to\x20use.\x0aPkg.go.dev\x0aand\x20the\x20Go\x20Wiki\x0aprovide\x20lists\x20of\x20external\x20Go\x20projects.\x0a

\x0a\x0a

\x0aFor\x20more\x20information\x20on\x20using\x20remote\x20repositories\x20with\x20the\x20go\x20tool,\x20see\x0ago\x20help\x20importpath.\x0a

\x0a\x0a\x0aWhat's\x20next\x0a\x0a

\x0aSubscribe\x20to\x20the\x0agolang-announce\x0amailing\x20list\x20to\x20be\x20notified\x20when\x20a\x20new\x20stable\x20version\x20of\x20Go\x20is\x20released.\x0a

\x0a\x0a

\x0aSee\x20Effective\x20Go\x20for\x20tips\x20on\x20writing\x0aclear,\x20idiomatic\x20Go\x20code.\x0a

\x0a\x0a

\x0aTake\x20A\x20Tour\x20of\x20Go\x20to\x20learn\x20the\x20language\x0aproper.\x0a

\x0a\x0a

\x0aVisit\x20the\x20documentation\x20page\x20for\x20a\x20set\x20of\x20in-depth\x0aarticles\x20about\x20the\x20Go\x20language\x20and\x20its\x20libraries\x20and\x20tools.\x0a

\x0a\x0a\x0aGetting\x20help\x0a\x0a

\x0aFor\x20real-time\x20help,\x20ask\x20the\x20helpful\x20gophers\x20in\x20#go-nuts\x20on\x20the\x0aFreenode\x20IRC\x20server.\x0a

\x0a\x0a

\x0aThe\x20official\x20mailing\x20list\x20for\x20discussion\x20of\x20the\x20Go\x20language\x20is\x0aGo\x20Nuts.\x0a

\x0a\x0a

\x0aReport\x20bugs\x20using\x20the\x0aGo\x20issue\x20tracker.\x0a

\x0a", "doc/install.html": "\x0a

\x0a\x20\x20Download\x20and\x20install\x20Go\x20quickly\x20with\x20the\x20steps\x20described\x20here.\x0a

\x0a

For\x20other\x20content\x20on\x20installing,\x20you\x20might\x20be\x20interested\x20in:

\x0a
    \x0a\x20\x20
  • \x0a\x20\x20\x20\x20Managing\x20Go\x20installations\x20--\x20How\x20to\x0a\x20\x20\x20\x20install\x20multiple\x20versions\x20and\x20uninstall.\x0a\x20\x20
  • \x0a\x20\x20
  • \x0a\x20\x20\x20\x20Installing\x20Go\x20from\x20source\x20--\x20How\x20to\x0a\x20\x20\x20\x20check\x20out\x20the\x20sources,\x20build\x20them\x20on\x20your\x20own\x20machine,\x20and\x20run\x20them.\x0a\x20\x20
  • \x0a
\x0a1.\x20Go\x20download.\x0a

\x0a\x20\x20Click\x20the\x20button\x20below\x20to\x20download\x20the\x20Go\x20installer.\x0a

\x0a

\x0a\x20\x20\x0a\x20\x20\x20\x20Download\x20Go\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a

\x0a

\x0a\x20\x20Don't\x20see\x20your\x20operating\x20system\x20here?\x20Try\x20one\x20of\x20the\x0a\x20\x20other\x20downloads.\x0a

\x0a\x0a\x20\x20Note:\x20By\x20default,\x20the\x20go\x20command\x20downloads\x20and\x0a\x20\x20authenticates\x20modules\x20using\x20the\x20Go\x20module\x20mirror\x20and\x20Go\x20checksum\x20database\x0a\x20\x20run\x20by\x20Google.\x20Learn\x20more.\x0a\x0a2.\x20Go\x20install.\x0a

\x0a\x20\x20Select\x20the\x20tab\x20for\x20your\x20computer's\x20operating\x20system\x20below,\x20then\x20follow\x20its\x0a\x20\x20installation\x20instructions.\x0a

\x0a\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20Linux\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20Mac\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20Windows\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x20\x20\x0a\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20If\x20you\x20have\x20a\x20previous\x20version\x20of\x20Go\x20installed,\x20be\x20sure\x20to\x0a\x20\x20\x20\x20\x20\x20remove\x20it\x20before\x20installing\x20another.\x0a\x20\x20\x20\x20

\x0a\x20\x20\x20\x20
    \x0a\x20\x20\x20\x20\x20\x20
  1. \x0a\x20\x20\x20\x20\x20\x20\x20\x20Download\x20the\x20archive\x20and\x20extract\x20it\x20into\x20/usr/local,\x20creating\x20a\x20Go\x20tree\x0a\x20\x20\x20\x20\x20\x20\x20\x20in\x20/usr/local/go.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20For\x20example,\x20run\x20the\x20following\x20as\x20root\x20or\x20through\x20sudo:\x0a\x20\x20\x20\x20\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\x20\x20
    \x0atar\x20-C\x20/usr/local\x20-xzf\x20go1.14.3.linux-amd64.tar.gz\x0a\x0a\x20\x20\x20\x20\x20\x20
  2. \x0a\x20\x20\x20\x20\x20\x20
  3. \x0a\x20\x20\x20\x20\x20\x20\x20\x20Add\x20/usr/local/go/bin\x20to\x20the\x20PATH\x20environment\x20variable.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20You\x20can\x20do\x20this\x20by\x20adding\x20the\x20following\x20line\x20to\x20your\x20$HOME/.profile\x20or\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20/etc/profile\x20(for\x20a\x20system-wide\x20installation):\x0a\x20\x20\x20\x20\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\x20\x20
    \x0aexport\x20PATH=$PATH:/usr/local/go/bin\x0a\x0a\x20\x20\x20\x20\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Note:\x20Changes\x20made\x20to\x20a\x20profile\x20file\x20may\x20not\x20apply\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20until\x20the\x20next\x20time\x20you\x20log\x20into\x20your\x20computer.\x20To\x20apply\x20the\x20changes\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20immediately,\x20just\x20run\x20the\x20shell\x20commands\x20directly\x20or\x20execute\x20them\x20from\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20the\x20profile\x20using\x20a\x20command\x20such\x20as\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20source\x20$HOME/.profile.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20
  4. \x0a\x20\x20\x20\x20\x20\x20
  5. \x0a\x20\x20\x20\x20\x20\x20\x20\x20Verify\x20that\x20you've\x20installed\x20Go\x20by\x20opening\x20a\x20command\x20prompt\x20and\x20typing\x0a\x20\x20\x20\x20\x20\x20\x20\x20the\x20following\x20command:\x0a\x20\x20\x20\x20\x20\x20\x20\x20
    \x0a$\x20go\x20version\x0a\x0a\x20\x20\x20\x20\x20\x20
  6. \x0a\x20\x20\x20\x20\x20\x20
  7. Confirm\x20that\x20the\x20command\x20prints\x20the\x20installed\x20version\x20of\x20Go.
  8. \x0a\x20\x20\x20\x20
\x0a\x20\x20\x0a\x20\x20\x0a\x20\x20\x20\x20
    \x0a\x20\x20\x20\x20\x20\x20
  1. \x0a\x20\x20\x20\x20\x20\x20\x20\x20Open\x20the\x20package\x20file\x20you\x20downloaded\x20and\x20follow\x20the\x20prompts\x20to\x20install\x0a\x20\x20\x20\x20\x20\x20\x20\x20Go.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20The\x20package\x20installs\x20the\x20Go\x20distribution\x20to\x20/usr/local/go.\x20The\x20package\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20should\x20put\x20the\x20/usr/local/go/bin\x20directory\x20in\x20your\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20PATH\x20environment\x20variable.\x20You\x20may\x20need\x20to\x20restart\x20any\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20open\x20Terminal\x20sessions\x20for\x20the\x20change\x20to\x20take\x20effect.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20
  2. \x0a\x20\x20\x20\x20\x20\x20
  3. \x0a\x20\x20\x20\x20\x20\x20\x20\x20Verify\x20that\x20you've\x20installed\x20Go\x20by\x20opening\x20a\x20command\x20prompt\x20and\x20typing\x0a\x20\x20\x20\x20\x20\x20\x20\x20the\x20following\x20command:\x0a\x20\x20\x20\x20\x20\x20\x20\x20
    \x0a$\x20go\x20version\x0a\x0a\x20\x20\x20\x20\x20\x20
  4. \x0a\x20\x20\x20\x20\x20\x20
  5. Confirm\x20that\x20the\x20command\x20prints\x20the\x20installed\x20version\x20of\x20Go.
  6. \x0a\x20\x20\x20\x20
\x0a\x20\x20\x0a\x20\x20\x0a\x20\x20\x20\x20
    \x0a\x20\x20\x20\x20\x20\x20
  1. \x0a\x20\x20\x20\x20\x20\x20\x20\x20Open\x20the\x20MSI\x20file\x20you\x20downloaded\x20and\x20follow\x20the\x20prompts\x20to\x20install\x20Go.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20By\x20default,\x20the\x20installer\x20will\x20install\x20Go\x20to\x20C:\\Go.\x20You\x20can\x20change\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20location\x20as\x20needed.\x20After\x20installing,\x20you\x20will\x20need\x20to\x20close\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20reopen\x20any\x20open\x20command\x20prompts\x20so\x20that\x20changes\x20to\x20the\x20environment\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20made\x20by\x20the\x20installer\x20are\x20reflected\x20at\x20the\x20command\x20prompt.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20
  2. \x0a\x20\x20\x20\x20\x20\x20
  3. \x0a\x20\x20\x20\x20\x20\x20\x20\x20Verify\x20that\x20you've\x20installed\x20Go.\x0a\x20\x20\x20\x20\x20\x20\x20\x20
      \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
    1. \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20In\x20Windows,\x20click\x20the\x20Start\x20menu.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
    2. \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
    3. \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20In\x20the\x20menu's\x20search\x20box,\x20type\x20cmd,\x20then\x20press\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Enter\x20key.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
    4. \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
    5. \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20In\x20the\x20Command\x20Prompt\x20window\x20that\x20appears,\x20type\x20the\x20following\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20command:\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
      \x0a$\x20go\x20version\x0a\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
    6. \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
    7. Confirm\x20that\x20the\x20command\x20prints\x20the\x20installed\x20version\x20of\x20Go.
    8. \x0a\x20\x20\x20\x20\x20\x20\x20\x20
    \x0a\x20\x20\x20\x20\x20\x20
  4. \x0a\x20\x20\x20\x20
\x0a\x20\x20\x0a\x0a3.\x20Go\x20code.\x0a

\x0a\x20\x20You're\x20set\x20up!\x20Visit\x20the\x0a\x20\x20Getting\x20Started\x20tutorial\x20to\x20write\x0a\x20\x20some\x20simple\x20Go\x20code.\x20It\x20takes\x20about\x2010\x20minutes\x20to\x20complete.\x0a

\x0a\x0a\x0a", @@ -137,7 +137,7 @@ var Files = map[string]string{ "package.html": "\x0a\x0a{{with\x20.PDoc}}\x0a\x09{{if\x20$.IsMain}}\x0a\x09\x09{{/*\x20command\x20documentation\x20*/}}\x0a\x09\x09{{comment_html\x20.Doc}}\x0a\x09{{else}}\x0a\x09\x09{{/*\x20package\x20documentation\x20*/}}\x0a\x09\x09\x0a\x09\x09\x09
\x0a\x09\x09\x09
import\x20\"{{html\x20.ImportPath}}\"
\x0a\x09\x09\x09
\x0a\x09\x09\x09
\x0a\x09\x09\x09
Overview
\x0a\x09\x09\x09
Index
\x0a\x09\x09\x09{{if\x20$.Examples}}\x0a\x09\x09\x09\x09
Examples
\x0a\x09\x09\x09{{end}}\x0a\x09\x09\x09{{if\x20$.Dirs}}\x0a\x09\x09\x09\x09
Subdirectories
\x0a\x09\x09\x09{{end}}\x0a\x09\x09\x09
\x0a\x09\x09\x0a\x09\x09\x0a\x09\x09\x0a\x09\x09\x09\x0a\x09\x09\x09\x09Overview\x20\xe2\x96\xb9\x0a\x09\x09\x09\x0a\x09\x09\x09\x0a\x09\x09\x09\x09Overview\x20\xe2\x96\xbe\x0a\x09\x09\x09\x09{{comment_html\x20.Doc}}\x0a\x09\x09\x09\x09{{example_html\x20$\x20\"\"}}\x0a\x09\x09\x09\x0a\x09\x09\x0a\x0a\x09\x09\x0a\x09\x09\x0a\x09\x09\x09Index\x20\xe2\x96\xb9\x0a\x09\x09\x0a\x09\x09\x0a\x09\x09\x09Index\x20\xe2\x96\xbe\x0a\x0a\x09\x09\x0a\x09\x09\x09\x0a\x09\x09\x09
\x0a\x09\x09\x09{{if\x20.Consts}}\x0a\x09\x09\x09\x09
Constants
\x0a\x09\x09\x09{{end}}\x0a\x09\x09\x09{{if\x20.Vars}}\x0a\x09\x09\x09\x09
Variables
\x0a\x09\x09\x09{{end}}\x0a\x09\x09\x09{{range\x20.Funcs}}\x0a\x09\x09\x09\x09{{$name_html\x20:=\x20html\x20.Name}}\x0a\x09\x09\x09\x09
{{node_html\x20$\x20.Decl\x20false\x20|\x20sanitize}}
\x0a\x09\x09\x09{{end}}\x0a\x09\x09\x09{{range\x20.Types}}\x0a\x09\x09\x09\x09{{$tname_html\x20:=\x20html\x20.Name}}\x0a\x09\x09\x09\x09
type\x20{{$tname_html}}
\x0a\x09\x09\x09\x09{{range\x20.Funcs}}\x0a\x09\x09\x09\x09\x09{{$name_html\x20:=\x20html\x20.Name}}\x0a\x09\x09\x09\x09\x09
 \x20 \x20{{node_html\x20$\x20.Decl\x20false\x20|\x20sanitize}}
\x0a\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09{{range\x20.Methods}}\x0a\x09\x09\x09\x09\x09{{$name_html\x20:=\x20html\x20.Name}}\x0a\x09\x09\x09\x09\x09
 \x20 \x20{{node_html\x20$\x20.Decl\x20false\x20|\x20sanitize}}
\x0a\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09{{end}}\x0a\x09\x09\x09{{if\x20$.Notes}}\x0a\x09\x09\x09\x09{{range\x20$marker,\x20$item\x20:=\x20$.Notes}}\x0a\x09\x09\x09\x09
{{noteTitle\x20$marker\x20|\x20html}}s
\x0a\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09{{end}}\x0a\x09\x09\x09
\x0a\x09\x09\x09\x0a\x0a\x09\x09{{if\x20$.Examples}}\x0a\x09\x09\x0a\x09\x09\x09

Examples

\x0a\x09\x09\x09(Expand\x20All)\x0a\x09\x09\x09
\x0a\x09\x09\x09{{range\x20$.Examples}}\x0a\x09\x09\x09
{{example_name\x20.Name}}
\x0a\x09\x09\x09{{end}}\x0a\x09\x09\x09
\x0a\x09\x09\x0a\x09\x09{{end}}\x0a\x0a\x09\x09{{with\x20.Filenames}}\x0a\x09\x09\x09

Package\x20files

\x0a\x09\x09\x09

\x0a\x09\x09\x09\x0a\x09\x09\x09{{range\x20.}}\x0a\x09\x09\x09\x09{{.|filename|html}}\x0a\x09\x09\x09{{end}}\x0a\x09\x09\x09\x0a\x09\x09\x09

\x0a\x09\x09{{end}}\x0a\x09\x09\x0a\x09\x09\x0a\x0a\x09\x09{{with\x20.Consts}}\x0a\x09\x09\x09Constants\x0a\x09\x09\x09{{range\x20.}}\x0a\x09\x09\x09\x09{{comment_html\x20.Doc}}\x0a\x09\x09\x09\x09
{{node_html\x20$\x20.Decl\x20true}}
\x0a\x09\x09\x09{{end}}\x0a\x09\x09{{end}}\x0a\x09\x09{{with\x20.Vars}}\x0a\x09\x09\x09Variables\x0a\x09\x09\x09{{range\x20.}}\x0a\x09\x09\x09\x09{{comment_html\x20.Doc}}\x0a\x09\x09\x09\x09
{{node_html\x20$\x20.Decl\x20true}}
\x0a\x09\x09\x09{{end}}\x0a\x09\x09{{end}}\x0a\x09\x09{{range\x20.Funcs}}\x0a\x09\x09\x09{{/*\x20Name\x20is\x20a\x20string\x20-\x20no\x20need\x20for\x20FSet\x20*/}}\x0a\x09\x09\x09{{$name_html\x20:=\x20html\x20.Name}}\x0a\x09\x09\x09func\x20{{$name_html}}\x0a\x09\x09\x09\x09¶\x0a\x09\x09\x09\x09{{$since\x20:=\x20since\x20\"func\"\x20\"\"\x20.Name\x20$.PDoc.ImportPath}}\x0a\x09\x09\x09\x09{{if\x20$since}}{{$since}}{{end}}\x0a\x09\x09\x09\x0a\x09\x09\x09
{{node_html\x20$\x20.Decl\x20true}}
\x0a\x09\x09\x09{{comment_html\x20.Doc}}\x0a\x09\x09\x09{{example_html\x20$\x20.Name}}\x0a\x0a\x09\x09{{end}}\x0a\x09\x09{{range\x20.Types}}\x0a\x09\x09\x09{{$tname\x20:=\x20.Name}}\x0a\x09\x09\x09{{$tname_html\x20:=\x20html\x20.Name}}\x0a\x09\x09\x09type\x20{{$tname_html}}\x0a\x09\x09\x09\x09¶\x0a\x09\x09\x09\x09{{$since\x20:=\x20since\x20\"type\"\x20\"\"\x20.Name\x20$.PDoc.ImportPath}}\x0a\x09\x09\x09\x09{{if\x20$since}}{{$since}}{{end}}\x0a\x09\x09\x09\x0a\x09\x09\x09{{comment_html\x20.Doc}}\x0a\x09\x09\x09
{{node_html\x20$\x20.Decl\x20true}}
\x0a\x0a\x09\x09\x09{{range\x20.Consts}}\x0a\x09\x09\x09\x09{{comment_html\x20.Doc}}\x0a\x09\x09\x09\x09
{{node_html\x20$\x20.Decl\x20true}}
\x0a\x09\x09\x09{{end}}\x0a\x0a\x09\x09\x09{{range\x20.Vars}}\x0a\x09\x09\x09\x09{{comment_html\x20.Doc}}\x0a\x09\x09\x09\x09
{{node_html\x20$\x20.Decl\x20true}}
\x0a\x09\x09\x09{{end}}\x0a\x0a\x09\x09\x09{{example_html\x20$\x20$tname}}\x0a\x0a\x09\x09\x09{{range\x20.Funcs}}\x0a\x09\x09\x09\x09{{$name_html\x20:=\x20html\x20.Name}}\x0a\x09\x09\x09\x09func\x20{{$name_html}}\x0a\x09\x09\x09\x09\x09¶\x0a\x09\x09\x09\x09\x09{{$since\x20:=\x20since\x20\"func\"\x20\"\"\x20.Name\x20$.PDoc.ImportPath}}\x0a\x09\x09\x09\x09\x09{{if\x20$since}}{{$since}}{{end}}\x0a\x09\x09\x09\x09\x0a\x09\x09\x09\x09
{{node_html\x20$\x20.Decl\x20true}}
\x0a\x09\x09\x09\x09{{comment_html\x20.Doc}}\x0a\x09\x09\x09\x09{{example_html\x20$\x20.Name}}\x0a\x09\x09\x09{{end}}\x0a\x0a\x09\x09\x09{{range\x20.Methods}}\x0a\x09\x09\x09\x09{{$name_html\x20:=\x20html\x20.Name}}\x0a\x09\x09\x09\x09func\x20({{html\x20.Recv}})\x20{{$name_html}}\x0a\x09\x09\x09\x09\x09¶\x0a\x09\x09\x09\x09\x09{{$since\x20:=\x20since\x20\"method\"\x20.Recv\x20.Name\x20$.PDoc.ImportPath}}\x0a\x09\x09\x09\x09\x09{{if\x20$since}}{{$since}}{{end}}\x0a\x09\x09\x09\x09\x0a\x09\x09\x09\x09
{{node_html\x20$\x20.Decl\x20true}}
\x0a\x09\x09\x09\x09{{comment_html\x20.Doc}}\x0a\x09\x09\x09\x09{{$name\x20:=\x20printf\x20\"%s_%s\"\x20$tname\x20.Name}}\x0a\x09\x09\x09\x09{{example_html\x20$\x20$name}}\x0a\x09\x09\x09{{end}}\x0a\x09\x09{{end}}\x0a\x09{{end}}\x0a\x0a\x09{{with\x20$.Notes}}\x0a\x09\x09{{range\x20$marker,\x20$content\x20:=\x20.}}\x0a\x09\x09\x09{{noteTitle\x20$marker\x20|\x20html}}s\x0a\x09\x09\x09\x0a\x09\x09\x09{{range\x20.}}\x0a\x09\x09\x09
  • ☞\x20{{comment_html\x20.Body}}
  • \x0a\x09\x09\x09{{end}}\x0a\x09\x09\x09\x0a\x09\x09{{end}}\x0a\x09{{end}}\x0a{{end}}\x0a\x0a{{with\x20.PAst}}\x0a\x09{{range\x20$filename,\x20$ast\x20:=\x20.}}\x0a\x09\x09{{$filename|filename|html}}:
    {{node_html\x20$\x20$ast\x20false}}
    \x0a\x09{{end}}\x0a{{end}}\x0a\x0a{{with\x20.Dirs}}\x0a\x09{{/*\x20DirList\x20entries\x20are\x20numbers\x20and\x20strings\x20-\x20no\x20need\x20for\x20FSet\x20*/}}\x0a\x09{{if\x20$.PDoc}}\x0a\x09\x09Subdirectories\x0a\x09{{end}}\x0a\x09\x0a\x09\x09\x0a\x09\x09\x09\x0a\x09\x09\x09\x09Name\x0a\x09\x09\x09\x09Synopsis\x0a\x09\x09\x09\x0a\x0a\x09\x09\x09{{if\x20not\x20(or\x20(eq\x20$.Dirname\x20\"/src/cmd\")\x20$.DirFlat)}}\x0a\x09\x09\x09\x0a\x09\x09\x09\x09..\x0a\x09\x09\x09\x0a\x09\x09\x09{{end}}\x0a\x0a\x09\x09\x09{{range\x20.List}}\x0a\x09\x09\x09\x09\x0a\x09\x09\x09\x09{{if\x20$.DirFlat}}\x0a\x09\x09\x09\x09\x09{{if\x20.HasPkg}}\x0a\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09{{html\x20.Path}}\x0a\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09{{else}}\x0a\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09{{html\x20.Name}}\x0a\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09{{html\x20.Synopsis}}\x0a\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x0a\x09\x09\x09{{end}}\x0a\x09\x09
    \x0a\x09\x0a{{end}}\x0a", - "packageroot.html": "\x0a\x0a{{with\x20.PAst}}\x0a\x09{{range\x20$filename,\x20$ast\x20:=\x20.}}\x0a\x09\x09{{$filename|filename|html}}:
    {{node_html\x20$\x20$ast\x20false}}
    \x0a\x09{{end}}\x0a{{end}}\x0a\x0a{{with\x20.Dirs}}\x0a\x09{{/*\x20DirList\x20entries\x20are\x20numbers\x20and\x20strings\x20-\x20no\x20need\x20for\x20FSet\x20*/}}\x0a\x09{{if\x20$.PDoc}}\x0a\x09\x09Subdirectories\x0a\x09{{end}}\x0a\x09\x09\x0a\x09\x09\x09
    \x0a\x09\x09\x09\x09
    Standard\x20library
    \x0a\x09\x09\x09\x09{{if\x20hasThirdParty\x20.List\x20}}\x0a\x09\x09\x09\x09\x09
    Third\x20party
    \x0a\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09
    Other\x20packages
    \x0a\x09\x09\x09\x09
    Sub-repositories
    \x0a\x09\x09\x09\x09
    Community
    \x0a\x09\x09\x09
    \x0a\x09\x09\x0a\x0a\x09\x09\x0a\x09\x09\x09\x0a\x09\x09\x09\x09Standard\x20library\x20\xe2\x96\xb9\x0a\x09\x09\x09\x0a\x09\x09\x09\x0a\x09\x09\x09\x09Standard\x20library\x20\xe2\x96\xbe\x0a\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09Name\x0a\x09\x09\x09\x09\x09\x09\x09Synopsis\x0a\x09\x09\x09\x09\x09\x09\x0a\x0a\x09\x09\x09\x09\x09\x09{{range\x20.List}}\x0a\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09{{if\x20eq\x20.RootType\x20\"GOROOT\"}}\x0a\x09\x09\x09\x09\x09\x09\x09{{if\x20$.DirFlat}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{if\x20.HasPkg}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09{{html\x20.Path}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09{{else}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09{{html\x20.Name}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09{{html\x20.Synopsis}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09
    \x0a\x09\x09\x09\x09\x20\x0a\x09\x09\x09\x20\x0a\x09\x09\x20\x0a\x0a\x09{{if\x20hasThirdParty\x20.List\x20}}\x0a\x09\x09\x0a\x09\x09\x09\x0a\x09\x09\x09\x09Third\x20party\x20\xe2\x96\xb9\x0a\x09\x09\x09\x0a\x09\x09\x09\x0a\x09\x09\x09\x09Third\x20party\x20\xe2\x96\xbe\x0a\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09Name\x0a\x09\x09\x09\x09\x09\x09\x09Synopsis\x0a\x09\x09\x09\x09\x09\x09\x0a\x0a\x09\x09\x09\x09\x09\x09{{range\x20.List}}\x0a\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{if\x20eq\x20.RootType\x20\"GOPATH\"}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{if\x20$.DirFlat}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09{{if\x20.HasPkg}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09{{html\x20.Path}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{else}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09{{html\x20.Name}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09{{html\x20.Synopsis}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09
    \x0a\x09\x09\x09\x09\x20\x0a\x09\x09\x09\x20\x0a\x09\x09\x20\x0a\x09{{end}}\x0a\x0a\x09Other\x20packages\x0a\x09Sub-repositories\x0a\x09

    \x0a\x09These\x20packages\x20are\x20part\x20of\x20the\x20Go\x20Project\x20but\x20outside\x20the\x20main\x20Go\x20tree.\x0a\x09They\x20are\x20developed\x20under\x20looser\x20compatibility\x20requirements\x20than\x20the\x20Go\x20core.\x0a\x09Install\x20them\x20with\x20\"go\x20get\".\x0a\x09

    \x0a\x09
      \x0a\x09\x09
    • benchmarks\x20\xe2\x80\x94\x20benchmarks\x20to\x20measure\x20Go\x20as\x20it\x20is\x20developed.
    • \x0a\x09\x09
    • blog\x20\xe2\x80\x94\x20blog.golang.org's\x20implementation.
    • \x0a\x09\x09
    • build\x20\xe2\x80\x94\x20build.golang.org's\x20implementation.
    • \x0a\x09\x09
    • crypto\x20\xe2\x80\x94\x20additional\x20cryptography\x20packages.
    • \x0a\x09\x09
    • debug\x20\xe2\x80\x94\x20an\x20experimental\x20debugger\x20for\x20Go.
    • \x0a\x09\x09
    • image\x20\xe2\x80\x94\x20additional\x20imaging\x20packages.
    • \x0a\x09\x09
    • mobile\x20\xe2\x80\x94\x20experimental\x20support\x20for\x20Go\x20on\x20mobile\x20platforms.
    • \x0a\x09\x09
    • net\x20\xe2\x80\x94\x20additional\x20networking\x20packages.
    • \x0a\x09\x09
    • perf\x20\xe2\x80\x94\x20packages\x20and\x20tools\x20for\x20performance\x20measurement,\x20storage,\x20and\x20analysis.
    • \x0a\x09\x09
    • pkgsite\x20\xe2\x80\x94\x20home\x20of\x20the\x20pkg.go.dev\x20website.
    • \x0a\x09\x09
    • review\x20\xe2\x80\x94\x20a\x20tool\x20for\x20working\x20with\x20Gerrit\x20code\x20reviews.
    • \x0a\x09\x09
    • sync\x20\xe2\x80\x94\x20additional\x20concurrency\x20primitives.
    • \x0a\x09\x09
    • sys\x20\xe2\x80\x94\x20packages\x20for\x20making\x20system\x20calls.
    • \x0a\x09\x09
    • text\x20\xe2\x80\x94\x20packages\x20for\x20working\x20with\x20text.
    • \x0a\x09\x09
    • time\x20\xe2\x80\x94\x20additional\x20time\x20packages.
    • \x0a\x09\x09
    • tools\x20\xe2\x80\x94\x20godoc,\x20goimports,\x20gorename,\x20and\x20other\x20tools.
    • \x0a\x09\x09
    • tour\x20\xe2\x80\x94\x20tour.golang.org's\x20implementation.
    • \x0a\x09\x09
    • exp\x20\xe2\x80\x94\x20experimental\x20and\x20deprecated\x20packages\x20(handle\x20with\x20care;\x20may\x20change\x20without\x20warning).
    • \x0a\x09
    \x0a\x0a\x09Community\x0a\x09

    \x0a\x09These\x20services\x20can\x20help\x20you\x20find\x20Open\x20Source\x20packages\x20provided\x20by\x20the\x20community.\x0a\x09

    \x0a\x09
      \x0a\x09\x09
    • GoDoc\x20-\x20a\x20package\x20index\x20and\x20search\x20engine.
    • \x0a\x09\x09
    • Projects\x20at\x20the\x20Go\x20Wiki\x20-\x20a\x20curated\x20list\x20of\x20Go\x20projects.
    • \x0a\x09
    \x0a{{end}}\x0a", + "packageroot.html": "\x0a\x0a{{with\x20.PAst}}\x0a\x09{{range\x20$filename,\x20$ast\x20:=\x20.}}\x0a\x09\x09{{$filename|filename|html}}:
    {{node_html\x20$\x20$ast\x20false}}
    \x0a\x09{{end}}\x0a{{end}}\x0a\x0a{{with\x20.Dirs}}\x0a\x09{{/*\x20DirList\x20entries\x20are\x20numbers\x20and\x20strings\x20-\x20no\x20need\x20for\x20FSet\x20*/}}\x0a\x09{{if\x20$.PDoc}}\x0a\x09\x09Subdirectories\x0a\x09{{end}}\x0a\x09\x09\x0a\x09\x09\x09
    \x0a\x09\x09\x09\x09
    Standard\x20library
    \x0a\x09\x09\x09\x09{{if\x20hasThirdParty\x20.List\x20}}\x0a\x09\x09\x09\x09\x09
    Third\x20party
    \x0a\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09
    Other\x20packages
    \x0a\x09\x09\x09\x09
    Sub-repositories
    \x0a\x09\x09\x09\x09
    Community
    \x0a\x09\x09\x09
    \x0a\x09\x09\x0a\x0a\x09\x09\x0a\x09\x09\x09\x0a\x09\x09\x09\x09Standard\x20library\x20\xe2\x96\xb9\x0a\x09\x09\x09\x0a\x09\x09\x09\x0a\x09\x09\x09\x09Standard\x20library\x20\xe2\x96\xbe\x0a\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09Name\x0a\x09\x09\x09\x09\x09\x09\x09Synopsis\x0a\x09\x09\x09\x09\x09\x09\x0a\x0a\x09\x09\x09\x09\x09\x09{{range\x20.List}}\x0a\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09{{if\x20eq\x20.RootType\x20\"GOROOT\"}}\x0a\x09\x09\x09\x09\x09\x09\x09{{if\x20$.DirFlat}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{if\x20.HasPkg}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09{{html\x20.Path}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09{{else}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09{{html\x20.Name}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09{{html\x20.Synopsis}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09
    \x0a\x09\x09\x09\x09\x20\x0a\x09\x09\x09\x20\x0a\x09\x09\x20\x0a\x0a\x09{{if\x20hasThirdParty\x20.List\x20}}\x0a\x09\x09\x0a\x09\x09\x09\x0a\x09\x09\x09\x09Third\x20party\x20\xe2\x96\xb9\x0a\x09\x09\x09\x0a\x09\x09\x09\x0a\x09\x09\x09\x09Third\x20party\x20\xe2\x96\xbe\x0a\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09Name\x0a\x09\x09\x09\x09\x09\x09\x09Synopsis\x0a\x09\x09\x09\x09\x09\x09\x0a\x0a\x09\x09\x09\x09\x09\x09{{range\x20.List}}\x0a\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{if\x20eq\x20.RootType\x20\"GOPATH\"}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{if\x20$.DirFlat}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09{{if\x20.HasPkg}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09{{html\x20.Path}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{else}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09{{html\x20.Name}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09{{html\x20.Synopsis}}\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09\x09{{end}}\x0a\x09\x09\x09\x09\x09
    \x0a\x09\x09\x09\x09\x20\x0a\x09\x09\x09\x20\x0a\x09\x09\x20\x0a\x09{{end}}\x0a\x0a\x09Other\x20packages\x0a\x09Sub-repositories\x0a\x09

    \x0a\x09These\x20packages\x20are\x20part\x20of\x20the\x20Go\x20Project\x20but\x20outside\x20the\x20main\x20Go\x20tree.\x0a\x09They\x20are\x20developed\x20under\x20looser\x20compatibility\x20requirements\x20than\x20the\x20Go\x20core.\x0a\x09Install\x20them\x20with\x20\"go\x20get\".\x0a\x09

    \x0a\x09
      \x0a\x09\x09
    • benchmarks\x20\xe2\x80\x94\x20benchmarks\x20to\x20measure\x20Go\x20as\x20it\x20is\x20developed.
    • \x0a\x09\x09
    • blog\x20\xe2\x80\x94\x20blog.golang.org's\x20implementation.
    • \x0a\x09\x09
    • build\x20\xe2\x80\x94\x20build.golang.org's\x20implementation.
    • \x0a\x09\x09
    • crypto\x20\xe2\x80\x94\x20additional\x20cryptography\x20packages.
    • \x0a\x09\x09
    • debug\x20\xe2\x80\x94\x20an\x20experimental\x20debugger\x20for\x20Go.
    • \x0a\x09\x09
    • image\x20\xe2\x80\x94\x20additional\x20imaging\x20packages.
    • \x0a\x09\x09
    • mobile\x20\xe2\x80\x94\x20experimental\x20support\x20for\x20Go\x20on\x20mobile\x20platforms.
    • \x0a\x09\x09
    • net\x20\xe2\x80\x94\x20additional\x20networking\x20packages.
    • \x0a\x09\x09
    • perf\x20\xe2\x80\x94\x20packages\x20and\x20tools\x20for\x20performance\x20measurement,\x20storage,\x20and\x20analysis.
    • \x0a\x09\x09
    • pkgsite\x20\xe2\x80\x94\x20home\x20of\x20the\x20pkg.go.dev\x20website.
    • \x0a\x09\x09
    • review\x20\xe2\x80\x94\x20a\x20tool\x20for\x20working\x20with\x20Gerrit\x20code\x20reviews.
    • \x0a\x09\x09
    • sync\x20\xe2\x80\x94\x20additional\x20concurrency\x20primitives.
    • \x0a\x09\x09
    • sys\x20\xe2\x80\x94\x20packages\x20for\x20making\x20system\x20calls.
    • \x0a\x09\x09
    • text\x20\xe2\x80\x94\x20packages\x20for\x20working\x20with\x20text.
    • \x0a\x09\x09
    • time\x20\xe2\x80\x94\x20additional\x20time\x20packages.
    • \x0a\x09\x09
    • tools\x20\xe2\x80\x94\x20godoc,\x20goimports,\x20gorename,\x20and\x20other\x20tools.
    • \x0a\x09\x09
    • tour\x20\xe2\x80\x94\x20tour.golang.org's\x20implementation.
    • \x0a\x09\x09
    • exp\x20\xe2\x80\x94\x20experimental\x20and\x20deprecated\x20packages\x20(handle\x20with\x20care;\x20may\x20change\x20without\x20warning).
    • \x0a\x09
    \x0a\x0a\x09Community\x0a\x09

    \x0a\x09These\x20services\x20can\x20help\x20you\x20find\x20Open\x20Source\x20packages\x20provided\x20by\x20the\x20community.\x0a\x09

    \x0a\x09
      \x0a\x20\x20\x20\x20
    • Pkg.go.dev\x20-\x20the\x20Go\x20package\x20discovery\x20site.
    • \x0a\x09\x09
    • Projects\x20at\x20the\x20Go\x20Wiki\x20-\x20a\x20curated\x20list\x20of\x20Go\x20projects.
    • \x0a\x09
    \x0a{{end}}\x0a", "play.js": "//\x20Copyright\x202012\x20The\x20Go\x20Authors.\x20All\x20rights\x20reserved.\x0a//\x20Use\x20of\x20this\x20source\x20code\x20is\x20governed\x20by\x20a\x20BSD-style\x0a//\x20license\x20that\x20can\x20be\x20found\x20in\x20the\x20LICENSE\x20file.\x0a\x0afunction\x20initPlayground(transport)\x20{\x0a\x20\x20'use\x20strict';\x0a\x0a\x20\x20function\x20text(node)\x20{\x0a\x20\x20\x20\x20var\x20s\x20=\x20'';\x0a\x20\x20\x20\x20for\x20(var\x20i\x20=\x200;\x20i\x20<\x20node.childNodes.length;\x20i++)\x20{\x0a\x20\x20\x20\x20\x20\x20var\x20n\x20=\x20node.childNodes[i];\x0a\x20\x20\x20\x20\x20\x20if\x20(n.nodeType\x20===\x201)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(n.tagName\x20===\x20'BUTTON')\x20continue;\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(n.tagName\x20===\x20'SPAN'\x20&&\x20n.className\x20===\x20'number')\x20continue;\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(n.tagName\x20===\x20'DIV'\x20||\x20n.tagName\x20==\x20'BR')\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20s\x20+=\x20'\\n';\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20s\x20+=\x20text(n);\x0a\x20\x20\x20\x20\x20\x20\x20\x20continue;\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20if\x20(n.nodeType\x20===\x203)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20s\x20+=\x20n.nodeValue;\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20return\x20s.replace('\\xA0',\x20'\x20');\x20//\x20replace\x20non-breaking\x20spaces\x0a\x20\x20}\x0a\x0a\x20\x20//\x20When\x20presenter\x20notes\x20are\x20enabled,\x20the\x20index\x20passed\x0a\x20\x20//\x20here\x20will\x20identify\x20the\x20playground\x20to\x20be\x20synced\x0a\x20\x20function\x20init(code,\x20index)\x20{\x0a\x20\x20\x20\x20var\x20output\x20=\x20document.createElement('div');\x0a\x20\x20\x20\x20var\x20outpre\x20=\x20document.createElement('pre');\x0a\x20\x20\x20\x20var\x20running;\x0a\x0a\x20\x20\x20\x20if\x20($\x20&&\x20$(output).resizable)\x20{\x0a\x20\x20\x20\x20\x20\x20$(output).resizable({\x0a\x20\x20\x20\x20\x20\x20\x20\x20handles:\x20'n,w,nw',\x0a\x20\x20\x20\x20\x20\x20\x20\x20minHeight:\x2027,\x0a\x20\x20\x20\x20\x20\x20\x20\x20minWidth:\x20135,\x0a\x20\x20\x20\x20\x20\x20\x20\x20maxHeight:\x20608,\x0a\x20\x20\x20\x20\x20\x20\x20\x20maxWidth:\x20990,\x0a\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20function\x20onKill()\x20{\x0a\x20\x20\x20\x20\x20\x20if\x20(running)\x20running.Kill();\x0a\x20\x20\x20\x20\x20\x20if\x20(window.notesEnabled)\x20updatePlayStorage('onKill',\x20index);\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20function\x20onRun(e)\x20{\x0a\x20\x20\x20\x20\x20\x20var\x20sk\x20=\x20e.shiftKey\x20||\x20localStorage.getItem('play-shiftKey')\x20===\x20'true';\x0a\x20\x20\x20\x20\x20\x20if\x20(running)\x20running.Kill();\x0a\x20\x20\x20\x20\x20\x20output.style.display\x20=\x20'block';\x0a\x20\x20\x20\x20\x20\x20outpre.innerHTML\x20=\x20'';\x0a\x20\x20\x20\x20\x20\x20run1.style.display\x20=\x20'none';\x0a\x20\x20\x20\x20\x20\x20var\x20options\x20=\x20{\x20Race:\x20sk\x20};\x0a\x20\x20\x20\x20\x20\x20running\x20=\x20transport.Run(text(code),\x20PlaygroundOutput(outpre),\x20options);\x0a\x20\x20\x20\x20\x20\x20if\x20(window.notesEnabled)\x20updatePlayStorage('onRun',\x20index,\x20e);\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20function\x20onClose()\x20{\x0a\x20\x20\x20\x20\x20\x20if\x20(running)\x20running.Kill();\x0a\x20\x20\x20\x20\x20\x20output.style.display\x20=\x20'none';\x0a\x20\x20\x20\x20\x20\x20run1.style.display\x20=\x20'inline-block';\x0a\x20\x20\x20\x20\x20\x20if\x20(window.notesEnabled)\x20updatePlayStorage('onClose',\x20index);\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20if\x20(window.notesEnabled)\x20{\x0a\x20\x20\x20\x20\x20\x20playgroundHandlers.onRun.push(onRun);\x0a\x20\x20\x20\x20\x20\x20playgroundHandlers.onClose.push(onClose);\x0a\x20\x20\x20\x20\x20\x20playgroundHandlers.onKill.push(onKill);\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20var\x20run1\x20=\x20document.createElement('button');\x0a\x20\x20\x20\x20run1.innerHTML\x20=\x20'Run';\x0a\x20\x20\x20\x20run1.className\x20=\x20'run';\x0a\x20\x20\x20\x20run1.addEventListener('click',\x20onRun,\x20false);\x0a\x20\x20\x20\x20var\x20run2\x20=\x20document.createElement('button');\x0a\x20\x20\x20\x20run2.className\x20=\x20'run';\x0a\x20\x20\x20\x20run2.innerHTML\x20=\x20'Run';\x0a\x20\x20\x20\x20run2.addEventListener('click',\x20onRun,\x20false);\x0a\x20\x20\x20\x20var\x20kill\x20=\x20document.createElement('button');\x0a\x20\x20\x20\x20kill.className\x20=\x20'kill';\x0a\x20\x20\x20\x20kill.innerHTML\x20=\x20'Kill';\x0a\x20\x20\x20\x20kill.addEventListener('click',\x20onKill,\x20false);\x0a\x20\x20\x20\x20var\x20close\x20=\x20document.createElement('button');\x0a\x20\x20\x20\x20close.className\x20=\x20'close';\x0a\x20\x20\x20\x20close.innerHTML\x20=\x20'Close';\x0a\x20\x20\x20\x20close.addEventListener('click',\x20onClose,\x20false);\x0a\x0a\x20\x20\x20\x20var\x20button\x20=\x20document.createElement('div');\x0a\x20\x20\x20\x20button.classList.add('buttons');\x0a\x20\x20\x20\x20button.appendChild(run1);\x0a\x20\x20\x20\x20//\x20Hack\x20to\x20simulate\x20insertAfter\x0a\x20\x20\x20\x20code.parentNode.insertBefore(button,\x20code.nextSibling);\x0a\x0a\x20\x20\x20\x20var\x20buttons\x20=\x20document.createElement('div');\x0a\x20\x20\x20\x20buttons.classList.add('buttons');\x0a\x20\x20\x20\x20buttons.appendChild(run2);\x0a\x20\x20\x20\x20buttons.appendChild(kill);\x0a\x20\x20\x20\x20buttons.appendChild(close);\x0a\x0a\x20\x20\x20\x20output.classList.add('output');\x0a\x20\x20\x20\x20output.appendChild(buttons);\x0a\x20\x20\x20\x20output.appendChild(outpre);\x0a\x20\x20\x20\x20output.style.display\x20=\x20'none';\x0a\x20\x20\x20\x20code.parentNode.insertBefore(output,\x20button.nextSibling);\x0a\x20\x20}\x0a\x0a\x20\x20var\x20play\x20=\x20document.querySelectorAll('div.playground');\x0a\x20\x20for\x20(var\x20i\x20=\x200;\x20i\x20<\x20play.length;\x20i++)\x20{\x0a\x20\x20\x20\x20init(play[i],\x20i);\x0a\x20\x20}\x0a}\x0a", diff --git a/internal/dl/server.go b/internal/dl/server.go index c837584b..7ec45a60 100644 --- a/internal/dl/server.go +++ b/internal/dl/server.go @@ -209,7 +209,7 @@ func (h server) getHandler(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, downloadBaseURL+name, http.StatusFound) return case name == "gotip": - redirectURL = "https://godoc.org/golang.org/dl/gotip" + redirectURL = "https://pkg.go.dev/golang.org/dl/gotip" case goGetRe.MatchString(name): redirectURL = "https://golang.org/dl/#" + name default: diff --git a/internal/redirect/redirect.go b/internal/redirect/redirect.go index 439a3572..8ae61cb6 100644 --- a/internal/redirect/redirect.go +++ b/internal/redirect/redirect.go @@ -99,7 +99,7 @@ var redirects = map[string]string{ "/build": "http://build.golang.org", "/change": "https://go.googlesource.com/go", "/cl": "https://go-review.googlesource.com", - "/cmd/godoc/": "http://godoc.org/golang.org/x/tools/cmd/godoc/", + "/cmd/godoc/": "https://pkg.go.dev/golang.org/x/tools/cmd/godoc", "/issue": "https://github.com/golang/go/issues", "/issue/new": "https://github.com/golang/go/issues/new", "/issues": "https://github.com/golang/go/issues",