From 33c1e377c565cecd59e0eaefe6799870980f30ce Mon Sep 17 00:00:00 2001 From: wangkekai Date: Tue, 24 Nov 2020 18:05:44 +0800 Subject: [PATCH 01/12] transaction install --- content/static/doc/install.html | 29 ++++++++++++++++------------- content/static/static.go | 2 +- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/content/static/doc/install.html b/content/static/doc/install.html index b759457040..09366631f9 100644 --- a/content/static/doc/install.html +++ b/content/static/doc/install.html @@ -3,37 +3,40 @@ "Path": "/doc/install" }-->

- Download and install Go quickly with the steps described here. + 按照下面的步骤快速下载和安装 Go.

-

For other content on installing, you might be interested in:

+

关于安装的另一个内容,你肯定感兴趣:

-

1. Go download.

+

1. 下载 Go

- Click the button below to download the Go installer. + 点击下面的按钮进行下载 Go 安装包。

- Download Go + 下载 Go

- Don't see your operating system here? Try one of the - other downloads. + 没有找到你系统的安装包?选择 + 其他下载.

2. Go install.

diff --git a/content/static/static.go b/content/static/static.go index 20408f39f6..97d3b72da7 100644 --- a/content/static/static.go +++ b/content/static/static.go @@ -65,7 +65,7 @@ var Files = map[string]string{ "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/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", + "doc/install.html": "\x0a

\x0a\x20\x20\xe6\x8c\x89\xe7\x85\xa7\xe4\xb8\x8b\xe9\x9d\xa2\xe7\x9a\x84\xe6\xad\xa5\xe9\xaa\xa4\xe5\xbf\xab\xe9\x80\x9f\xe4\xb8\x8b\xe8\xbd\xbd\xe5\x92\x8c\xe5\xae\x89\xe8\xa3\x85\x20Go.\x0a

\x0a

\xe5\x85\xb3\xe4\xba\x8e\xe5\xae\x89\xe8\xa3\x85\xe7\x9a\x84\xe5\x8f\xa6\xe4\xb8\x80\xe4\xb8\xaa\xe5\x86\x85\xe5\xae\xb9\xef\xbc\x8c\xe4\xbd\xa0\xe8\x82\xaf\xe5\xae\x9a\xe6\x84\x9f\xe5\x85\xb4\xe8\xb6\xa3\xef\xbc\x9a

\x0a
    \x0a\x20\x20
  • \x0a\x20\x20\x20\x20\xe7\xae\xa1\xe7\x90\x86\x20Go\x20\xe7\x9a\x84\xe5\xae\x89\xe8\xa3\x85\x20--\x20\x0a\x20\x20\x20\x20\xe6\x80\x8e\xe4\xb9\x88\xe5\xae\x89\xe8\xa3\x85\xe5\xa4\x9a\xe4\xb8\xaa\xe7\x89\x88\xe6\x9c\xac\xe5\x92\x8c\xe5\x8d\xb8\xe8\xbd\xbd\xe3\x80\x82\x0a\x20\x20
  • \x0a\x20\x20
  • \x0a\x20\x20\x20\x20\xe9\x80\x9a\xe8\xbf\x87\xe6\xba\x90\xe7\xa0\x81\xe5\xae\x89\xe8\xa3\x85\x20Go\x20--\x20\xe6\x80\x8e\xe4\xb9\x88\xe8\x8e\xb7\xe5\xbe\x97\xe6\xba\x90\xe7\xa0\x81\xef\xbc\x8c\xe5\x9c\xa8\xe8\x87\xaa\xe5\xb7\xb1\xe7\x9a\x84\xe7\x94\xb5\xe8\x84\x91\xe4\xb8\x8a\xe7\xbc\x96\xe8\xaf\x91\xe5\xb9\xb6\xe8\xbf\x90\xe8\xa1\x8c\xe5\xa5\xb9\xe4\xbb\xac\xe3\x80\x82\x0a\x20\x20
  • \x0a
\x0a1.\x20\xe4\xb8\x8b\xe8\xbd\xbd\x20Go\x20\x0a

\x0a\x20\x20\xe7\x82\xb9\xe5\x87\xbb\xe4\xb8\x8b\xe9\x9d\xa2\xe7\x9a\x84\xe6\x8c\x89\xe9\x92\xae\xe8\xbf\x9b\xe8\xa1\x8c\xe4\xb8\x8b\xe8\xbd\xbd\x20Go\x20\xe5\xae\x89\xe8\xa3\x85\xe5\x8c\x85\xe3\x80\x82\x0a

\x0a

\x0a\x20\x20\x0a\x20\x20\x20\x20\xe4\xb8\x8b\xe8\xbd\xbd\x20Go\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a

\x0a

\x0a\x20\x20\xe6\xb2\xa1\xe6\x9c\x89\xe6\x89\xbe\xe5\x88\xb0\xe4\xbd\xa0\xe7\xb3\xbb\xe7\xbb\x9f\xe7\x9a\x84\xe5\xae\x89\xe8\xa3\x85\xe5\x8c\x85\xef\xbc\x9f\xe9\x80\x89\xe6\x8b\xa9\x0a\x20\x20\xe5\x85\xb6\xe4\xbb\x96\xe4\xb8\x8b\xe8\xbd\xbd.\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", "doc/install-source.html": "\x0a\x0a

This\x20topic\x20describes\x20how\x20to\x20build\x20and\x20run\x20Go\x20from\x20source\x20code.\x20To\x20install\x20with\x20an\x20installer,\x20see\x20Download\x20and\x20install.

\x0a\x0aIntroduction\x0a\x0a

\x0aGo\x20is\x20an\x20open\x20source\x20project,\x20distributed\x20under\x20a\x0aBSD-style\x20license.\x0aThis\x20document\x20explains\x20how\x20to\x20check\x20out\x20the\x20sources,\x0abuild\x20them\x20on\x20your\x20own\x20machine,\x20and\x20run\x20them.\x0a

\x0a\x0a

\x0aMost\x20users\x20don't\x20need\x20to\x20do\x20this,\x20and\x20will\x20instead\x20install\x0afrom\x20precompiled\x20binary\x20packages\x20as\x20described\x20in\x0aDownload\x20and\x20install,\x0aa\x20much\x20simpler\x20process.\x0aIf\x20you\x20want\x20to\x20help\x20develop\x20what\x20goes\x20into\x20those\x20precompiled\x0apackages,\x20though,\x20read\x20on.\x0a

\x0a\x0a\x0a\x0a

\x0aThere\x20are\x20two\x20official\x20Go\x20compiler\x20toolchains.\x0aThis\x20document\x20focuses\x20on\x20the\x20gc\x20Go\x0acompiler\x20and\x20tools.\x0aFor\x20information\x20on\x20how\x20to\x20work\x20on\x20gccgo,\x20a\x20more\x20traditional\x0acompiler\x20using\x20the\x20GCC\x20back\x20end,\x20see\x0aSetting\x20up\x20and\x20using\x20gccgo.\x0a

\x0a\x0a

\x0aThe\x20Go\x20compilers\x20support\x20the\x20following\x20instruction\x20sets:\x0a\x0a

\x0a
\x0a\x20\x20amd64,\x20386\x0a
\x0a
\x0a\x20\x20The\x20x86\x20instruction\x20set,\x2064-\x20and\x2032-bit.\x0a
\x0a
\x0a\x20\x20arm64,\x20arm\x0a
\x0a
\x0a\x20\x20The\x20ARM\x20instruction\x20set,\x2064-bit\x20(AArch64)\x20and\x2032-bit.\x0a
\x0a
\x0a\x20\x20mips64,\x20mips64le,\x20mips,\x20\x20mipsle\x0a
\x0a
\x0a\x20\x20The\x20MIPS\x20instruction\x20set,\x20big-\x20and\x20little-endian,\x2064-\x20and\x2032-bit.\x0a
\x0a
\x0a\x20\x20ppc64,\x20ppc64le\x0a
\x0a
\x0a\x20\x20The\x2064-bit\x20PowerPC\x20instruction\x20set,\x20big-\x20and\x20little-endian.\x0a
\x0a
\x0a\x20\x20riscv64\x0a
\x0a
\x0a\x20\x20The\x2064-bit\x20RISC-V\x20instruction\x20set.\x0a
\x0a
\x0a\x20\x20s390x\x0a
\x0a
\x0a\x20\x20The\x20IBM\x20z/Architecture.\x0a
\x0a
\x0a\x20\x20wasm\x0a
\x0a
\x0a\x20\x20WebAssembly.\x0a
\x0a
\x0a

\x0a\x0a

\x0aThe\x20compilers\x20can\x20target\x20the\x20AIX,\x20Android,\x20DragonFly\x20BSD,\x20FreeBSD,\x0aIllumos,\x20Linux,\x20macOS/iOS\x20(Darwin),\x20NetBSD,\x20OpenBSD,\x20Plan\x209,\x20Solaris,\x0aand\x20Windows\x20operating\x20systems\x20(although\x20not\x20all\x20operating\x20systems\x0asupport\x20all\x20architectures).\x0a

\x0a\x0a

\x0aA\x20list\x20of\x20ports\x20which\x20are\x20considered\x20\"first\x20class\"\x20is\x20available\x20at\x20the\x0afirst\x20class\x20ports\x0awiki\x20page.\x0a

\x0a\x0a

\x0aThe\x20full\x20set\x20of\x20supported\x20combinations\x20is\x20listed\x20in\x20the\x0adiscussion\x20of\x20environment\x20variables\x20below.\x0a

\x0a\x0a

\x0aSee\x20the\x20main\x20installation\x20page\x20for\x20the\x20overall\x20system\x20requirements.\x0aThe\x20following\x20additional\x20constraints\x20apply\x20to\x20systems\x20that\x20can\x20be\x20built\x20only\x20from\x20source:\x0a

\x0a\x0a
    \x0a
  • For\x20Linux\x20on\x20PowerPC\x2064-bit,\x20the\x20minimum\x20supported\x20kernel\x20version\x20is\x202.6.37,\x20meaning\x20that\x0aGo\x20does\x20not\x20support\x20CentOS\x206\x20on\x20these\x20systems.\x0a
  • \x0a
\x0a\x20\x0a\x0a\x0aInstall\x20Go\x20compiler\x20binaries\x20for\x20bootstrap\x0a\x0a

\x0aThe\x20Go\x20toolchain\x20is\x20written\x20in\x20Go.\x20To\x20build\x20it,\x20you\x20need\x20a\x20Go\x20compiler\x20installed.\x0aThe\x20scripts\x20that\x20do\x20the\x20initial\x20build\x20of\x20the\x20tools\x20look\x20for\x20a\x20\"go\"\x20command\x0ain\x20$PATH,\x20so\x20as\x20long\x20as\x20you\x20have\x20Go\x20installed\x20in\x20your\x0asystem\x20and\x20configured\x20in\x20your\x20$PATH,\x20you\x20are\x20ready\x20to\x20build\x20Go\x0afrom\x20source.\x20\x0aOr\x20if\x20you\x20prefer\x20you\x20can\x20set\x20$GOROOT_BOOTSTRAP\x20to\x20the\x0aroot\x20of\x20a\x20Go\x20installation\x20to\x20use\x20to\x20build\x20the\x20new\x20Go\x20toolchain;\x0a$GOROOT_BOOTSTRAP/bin/go\x20should\x20be\x20the\x20go\x20command\x20to\x20use.

\x0a\x0aBootstrap\x20toolchain\x20from\x20binary\x20release\x0a\x0a

\x0aTo\x20use\x20a\x20binary\x20release\x20as\x20a\x20bootstrap\x20toolchain,\x20see\x0athe\x20downloads\x20page\x20or\x20use\x20any\x20other\x0apackaged\x20Go\x20distribution.\x0a

\x0a\x0aBootstrap\x20toolchain\x20from\x20source\x0a\x0a

\x0aTo\x20build\x20a\x20bootstrap\x20toolchain\x20from\x20source,\x20use\x0aeither\x20the\x20git\x20branch\x20release-branch.go1.4\x20or\x0ago1.4-bootstrap-20171003.tar.gz,\x0awhich\x20contains\x20the\x20Go\x201.4\x20source\x20code\x20plus\x20accumulated\x20fixes\x0ato\x20keep\x20the\x20tools\x20running\x20on\x20newer\x20operating\x20systems.\x0a(Go\x201.4\x20was\x20the\x20last\x20distribution\x20in\x20which\x20the\x20toolchain\x20was\x20written\x20in\x20C.)\x0aAfter\x20unpacking\x20the\x20Go\x201.4\x20source,\x20cd\x20to\x0athe\x20src\x20subdirectory,\x20set\x20CGO_ENABLED=0\x20in\x0athe\x20environment,\x20and\x20run\x20make.bash\x20(or,\x0aon\x20Windows,\x20make.bat).\x0a

\x0a\x0a

\x0aOnce\x20the\x20Go\x201.4\x20source\x20has\x20been\x20unpacked\x20into\x20your\x20GOROOT_BOOTSTRAP\x20directory,\x0ayou\x20must\x20keep\x20this\x20git\x20clone\x20instance\x20checked\x20out\x20to\x20branch\x0arelease-branch.go1.4.\x20\x20Specifically,\x20do\x20not\x20attempt\x20to\x20reuse\x0athis\x20git\x20clone\x20in\x20the\x20later\x20step\x20named\x20\"Fetch\x20the\x20repository.\"\x20\x20The\x20go1.4\x0abootstrap\x20toolchain\x20must\x20be\x20able\x20to\x20properly\x20traverse\x20the\x20go1.4\x20sources\x0athat\x20it\x20assumes\x20are\x20present\x20under\x20this\x20repository\x20root.\x0a

\x0a\x0aBootstrap\x20toolchain\x20from\x20cross-compiled\x20source\x0a\x0a

\x0aTo\x20cross-compile\x20a\x20bootstrap\x20toolchain\x20from\x20source,\x20which\x20is\x0anecessary\x20on\x20systems\x20Go\x201.4\x20did\x20not\x20target\x20(for\x0aexample,\x20linux/ppc64le),\x20install\x20Go\x20on\x20a\x20different\x20system\x0aand\x20run\x20bootstrap.bash.\x0a

\x0a\x0a

\x0aWhen\x20run\x20as\x20(for\x20example)\x0a

\x0a\x0a
\x0a$\x20GOOS=linux\x20GOARCH=ppc64\x20./bootstrap.bash\x0a
\x0a\x0a

\x0abootstrap.bash\x20cross-compiles\x20a\x20toolchain\x20for\x20that\x20GOOS/GOARCH\x0acombination,\x20leaving\x20the\x20resulting\x20tree\x20in\x20../../go-${GOOS}-${GOARCH}-bootstrap.\x0aThat\x20tree\x20can\x20be\x20copied\x20to\x20a\x20machine\x20of\x20the\x20given\x20target\x20type\x0aand\x20used\x20as\x20GOROOT_BOOTSTRAP\x20to\x20bootstrap\x20a\x20local\x20build.\x0a

\x0a\x0aBootstrap\x20toolchain\x20using\x20gccgo\x0a\x0a

\x0aTo\x20use\x20gccgo\x20as\x20the\x20bootstrap\x20toolchain,\x20you\x20need\x20to\x20arrange\x0afor\x20$GOROOT_BOOTSTRAP/bin/go\x20to\x20be\x20the\x20go\x20tool\x20that\x20comes\x0aas\x20part\x20of\x20gccgo\x205.\x20For\x20example\x20on\x20Ubuntu\x20Vivid:\x0a

\x0a\x0a
\x0a$\x20sudo\x20apt-get\x20install\x20gccgo-5\x0a$\x20sudo\x20update-alternatives\x20--set\x20go\x20/usr/bin/go-5\x0a$\x20GOROOT_BOOTSTRAP=/usr\x20./make.bash\x0a
\x0a\x0aInstall\x20Git,\x20if\x20needed\x0a\x0a

\x0aTo\x20perform\x20the\x20next\x20step\x20you\x20must\x20have\x20Git\x20installed.\x20(Check\x20that\x20you\x0ahave\x20a\x20git\x20command\x20before\x20proceeding.)\x0a

\x0a\x0a

\x0aIf\x20you\x20do\x20not\x20have\x20a\x20working\x20Git\x20installation,\x0afollow\x20the\x20instructions\x20on\x20the\x0aGit\x20downloads\x20page.\x0a

\x0a\x0a(Optional)\x20Install\x20a\x20C\x20compiler\x0a\x0a

\x0aTo\x20build\x20a\x20Go\x20installation\x0awith\x20cgo\x20support,\x20which\x20permits\x20Go\x0aprograms\x20to\x20import\x20C\x20libraries,\x20a\x20C\x20compiler\x20such\x20as\x20gcc\x0aor\x20clang\x20must\x20be\x20installed\x20first.\x20Do\x20this\x20using\x20whatever\x0ainstallation\x20method\x20is\x20standard\x20on\x20the\x20system.\x0a

\x0a\x0a

\x0aTo\x20build\x20without\x20cgo,\x20set\x20the\x20environment\x20variable\x0aCGO_ENABLED=0\x20before\x20running\x20all.bash\x20or\x0amake.bash.\x0a

\x0a\x0aFetch\x20the\x20repository\x0a\x0a

Change\x20to\x20the\x20directory\x20where\x20you\x20intend\x20to\x20install\x20Go,\x20and\x20make\x20sure\x0athe\x20goroot\x20directory\x20does\x20not\x20exist.\x20Then\x20clone\x20the\x20repository\x0aand\x20check\x20out\x20the\x20latest\x20release\x20tag\x20(go1.12,\x0afor\x20example):

\x0a\x0a
\x0a$\x20git\x20clone\x20https://go.googlesource.com/go\x20goroot\x0a$\x20cd\x20goroot\x0a$\x20git\x20checkout\x20<tag>\x0a
\x0a\x0a\x0aWhere\x20<tag>\x20is\x20the\x20version\x20string\x20of\x20the\x20release.\x0a

\x0a\x0a

Go\x20will\x20be\x20installed\x20in\x20the\x20directory\x20where\x20it\x20is\x20checked\x20out.\x20For\x20example,\x0aif\x20Go\x20is\x20checked\x20out\x20in\x20$HOME/goroot,\x20executables\x20will\x20be\x20installed\x0ain\x20$HOME/goroot/bin.\x20The\x20directory\x20may\x20have\x20any\x20name,\x20but\x20note\x0athat\x20if\x20Go\x20is\x20checked\x20out\x20in\x20$HOME/go,\x20it\x20will\x20conflict\x20with\x0athe\x20default\x20location\x20of\x20$GOPATH.\x0aSee\x20GOPATH\x20below.

\x0a\x0a

\x0aReminder:\x20If\x20you\x20opted\x20to\x20also\x20compile\x20the\x20bootstrap\x20binaries\x20from\x20source\x20(in\x20an\x0aearlier\x20section),\x20you\x20still\x20need\x20to\x20git\x20clone\x20again\x20at\x20this\x20point\x0a(to\x20checkout\x20the\x20latest\x20<tag>),\x20because\x20you\x20must\x20keep\x20your\x0ago1.4\x20repository\x20distinct.\x0a

\x0a\x0a(Optional)\x20Switch\x20to\x20the\x20master\x20branch\x0a\x0a

If\x20you\x20intend\x20to\x20modify\x20the\x20go\x20source\x20code,\x20and\x0acontribute\x20your\x20changes\x0ato\x20the\x20project,\x20then\x20move\x20your\x20repository\x0aoff\x20the\x20release\x20branch,\x20and\x20onto\x20the\x20master\x20(development)\x20branch.\x0aOtherwise,\x20skip\x20this\x20step.

\x0a\x0a
\x0a$\x20git\x20checkout\x20master\x0a
\x0a\x0aInstall\x20Go\x0a\x0a

\x0aTo\x20build\x20the\x20Go\x20distribution,\x20run\x0a

\x0a\x0a
\x0a$\x20cd\x20src\x0a$\x20./all.bash\x0a
\x0a\x0a

\x0a(To\x20build\x20under\x20Windows\x20use\x20all.bat.)\x0a

\x0a\x0a

\x0aIf\x20all\x20goes\x20well,\x20it\x20will\x20finish\x20by\x20printing\x20output\x20like:\x0a

\x0a\x0a
\x0aALL\x20TESTS\x20PASSED\x0a\x0a---\x0aInstalled\x20Go\x20for\x20linux/amd64\x20in\x20/home/you/go.\x0aInstalled\x20commands\x20in\x20/home/you/go/bin.\x0a***\x20You\x20need\x20to\x20add\x20/home/you/go/bin\x20to\x20your\x20$PATH.\x20***\x0a
\x0a\x0a

\x0awhere\x20the\x20details\x20on\x20the\x20last\x20few\x20lines\x20reflect\x20the\x20operating\x20system,\x0aarchitecture,\x20and\x20root\x20directory\x20used\x20during\x20the\x20install.\x0a

\x0a\x0a\x0a

\x0aFor\x20more\x20information\x20about\x20ways\x20to\x20control\x20the\x20build,\x20see\x20the\x20discussion\x20of\x0aenvironment\x20variables\x20below.\x0aall.bash\x20(or\x20all.bat)\x20runs\x20important\x20tests\x20for\x20Go,\x0awhich\x20can\x20take\x20more\x20time\x20than\x20simply\x20building\x20Go.\x20If\x20you\x20do\x20not\x20want\x20to\x20run\x0athe\x20test\x20suite\x20use\x20make.bash\x20(or\x20make.bat)\x0ainstead.\x0a

\x0a\x0a\x0a\x0aTesting\x20your\x20installation\x0a\x0a

\x0aCheck\x20that\x20Go\x20is\x20installed\x20correctly\x20by\x20building\x20a\x20simple\x20program.\x0a

\x0a\x0a

\x0aCreate\x20a\x20file\x20named\x20hello.go\x20and\x20put\x20the\x20following\x20program\x20in\x20it:\x0a

\x0a\x0a
\x0apackage\x20main\x0a\x0aimport\x20\"fmt\"\x0a\x0afunc\x20main()\x20{\x0a\x09fmt.Printf(\"hello,\x20world\\n\")\x0a}\x0a
\x0a\x0a

\x0aThen\x20run\x20it\x20with\x20the\x20go\x20tool:\x0a

\x0a\x0a
\x0a$\x20go\x20run\x20hello.go\x0ahello,\x20world\x0a
\x0a\x0a

\x0aIf\x20you\x20see\x20the\x20\"hello,\x20world\"\x20message\x20then\x20Go\x20is\x20installed\x20correctly.\x0a

\x0a\x0aSet\x20up\x20your\x20work\x20environment\x0a\x0a

\x0aYou're\x20almost\x20done.\x0aYou\x20just\x20need\x20to\x20do\x20a\x20little\x20more\x20setup.\x0a

\x0a\x0a

\x0a\x0aHow\x20to\x20Write\x20Go\x20Code\x0aLearn\x20how\x20to\x20set\x20up\x20and\x20use\x20the\x20Go\x20tools\x0a\x0a

\x0a\x0a

\x0aThe\x20How\x20to\x20Write\x20Go\x20Code\x20document\x0aprovides\x20essential\x20setup\x20instructions\x20for\x20using\x20the\x20Go\x20tools.\x0a

\x0a\x0a\x0aInstall\x20additional\x20tools\x0a\x0a

\x0aThe\x20source\x20code\x20for\x20several\x20Go\x20tools\x20(including\x20godoc)\x0ais\x20kept\x20in\x20the\x20go.tools\x20repository.\x0aTo\x20install\x20one\x20of\x20the\x20tools\x20(godoc\x20in\x20this\x20case):\x0a

\x0a\x0a
\x0a$\x20go\x20get\x20golang.org/x/tools/cmd/godoc\x0a
\x0a\x0a

\x0aTo\x20install\x20these\x20tools,\x20the\x20go\x20get\x20command\x20requires\x0athat\x20Git\x20be\x20installed\x20locally.\x0a

\x0a\x0a

\x0aYou\x20must\x20also\x20have\x20a\x20workspace\x20(GOPATH)\x20set\x20up;\x0asee\x20How\x20to\x20Write\x20Go\x20Code\x20for\x20the\x20details.\x0a

\x0a\x0aCommunity\x20resources\x0a\x0a

\x0aThe\x20usual\x20community\x20resources\x20such\x20as\x0a#go-nuts\x20on\x20the\x20Freenode\x20IRC\x20server\x0aand\x20the\x0aGo\x20Nuts\x0amailing\x20list\x20have\x20active\x20developers\x20that\x20can\x20help\x20you\x20with\x20problems\x0awith\x20your\x20installation\x20or\x20your\x20development\x20work.\x0aFor\x20those\x20who\x20wish\x20to\x20keep\x20up\x20to\x20date,\x0athere\x20is\x20another\x20mailing\x20list,\x20golang-checkins,\x0athat\x20receives\x20a\x20message\x20summarizing\x20each\x20checkin\x20to\x20the\x20Go\x20repository.\x0a

\x0a\x0a

\x0aBugs\x20can\x20be\x20reported\x20using\x20the\x20Go\x20issue\x20tracker.\x0a

\x0a\x0a\x0aKeeping\x20up\x20with\x20releases\x0a\x0a

\x0aNew\x20releases\x20are\x20announced\x20on\x20the\x0agolang-announce\x0amailing\x20list.\x0aEach\x20announcement\x20mentions\x20the\x20latest\x20release\x20tag,\x20for\x20instance,\x0ago1.9.\x0a

\x0a\x0a

\x0aTo\x20update\x20an\x20existing\x20tree\x20to\x20the\x20latest\x20release,\x20you\x20can\x20run:\x0a

\x0a\x0a
\x0a$\x20cd\x20go/src\x0a$\x20git\x20fetch\x0a$\x20git\x20checkout\x20<tag>\x0a$\x20./all.bash\x0a
\x0a\x0a\x0aWhere\x20<tag>\x20is\x20the\x20version\x20string\x20of\x20the\x20release.\x0a

\x0a\x0a\x0aOptional\x20environment\x20variables\x0a\x0a

\x0aThe\x20Go\x20compilation\x20environment\x20can\x20be\x20customized\x20by\x20environment\x20variables.\x0aNone\x20is\x20required\x20by\x20the\x20build,\x20but\x20you\x20may\x20wish\x20to\x20set\x20some\x0ato\x20override\x20the\x20defaults.\x0a

\x0a\x0a
    \x0a
  • $GOROOT\x0a

    \x0aThe\x20root\x20of\x20the\x20Go\x20tree,\x20often\x20$HOME/go1.X.\x0aIts\x20value\x20is\x20built\x20into\x20the\x20tree\x20when\x20it\x20is\x20compiled,\x20and\x0adefaults\x20to\x20the\x20parent\x20of\x20the\x20directory\x20where\x20all.bash\x20was\x20run.\x0aThere\x20is\x20no\x20need\x20to\x20set\x20this\x20unless\x20you\x20want\x20to\x20switch\x20between\x20multiple\x0alocal\x20copies\x20of\x20the\x20repository.\x0a

    \x0a
  • \x0a\x0a
  • $GOROOT_FINAL\x0a

    \x0aThe\x20value\x20assumed\x20by\x20installed\x20binaries\x20and\x20scripts\x20when\x0a$GOROOT\x20is\x20not\x20set\x20explicitly.\x0aIt\x20defaults\x20to\x20the\x20value\x20of\x20$GOROOT.\x0aIf\x20you\x20want\x20to\x20build\x20the\x20Go\x20tree\x20in\x20one\x20location\x0abut\x20move\x20it\x20elsewhere\x20after\x20the\x20build,\x20set\x0a$GOROOT_FINAL\x20to\x20the\x20eventual\x20location.\x0a

    \x0a
  • \x0a\x0a$GOPATH\x0a

    \x0aThe\x20directory\x20where\x20Go\x20projects\x20outside\x20the\x20Go\x20distribution\x20are\x20typically\x0achecked\x20out.\x20For\x20example,\x20golang.org/x/tools\x20might\x20be\x20checked\x20out\x0ato\x20$GOPATH/src/golang.org/x/tools.\x20Executables\x20outside\x20the\x0aGo\x20distribution\x20are\x20installed\x20in\x20$GOPATH/bin\x20(or\x0a$GOBIN,\x20if\x20set).\x20Modules\x20are\x20downloaded\x20and\x20cached\x20in\x0a$GOPATH/pkg/mod.\x0a

    \x0a\x0a

    The\x20default\x20location\x20of\x20$GOPATH\x20is\x20$HOME/go,\x0aand\x20it's\x20not\x20usually\x20necessary\x20to\x20set\x20GOPATH\x20explicitly.\x20However,\x0aif\x20you\x20have\x20checked\x20out\x20the\x20Go\x20distribution\x20to\x20$HOME/go,\x0ayou\x20must\x20set\x20GOPATH\x20to\x20another\x20location\x20to\x20avoid\x20conflicts.\x0a

    \x0a\x0a\x0a
  • $GOBIN\x0a

    \x0aThe\x20directory\x20where\x20executables\x20outside\x20the\x20Go\x20distribution\x20are\x20installed\x0ausing\x20the\x20go\x20command.\x20For\x20example,\x0ago\x20get\x20golang.org/x/tools/cmd/godoc\x20downloads,\x20builds,\x20and\x0ainstalls\x20$GOBIN/godoc.\x20By\x20default,\x20$GOBIN\x20is\x0a$GOPATH/bin\x20(or\x20$HOME/go/bin\x20if\x20GOPATH\x0ais\x20not\x20set).\x20After\x20installing,\x20you\x20will\x20want\x20to\x20add\x20this\x20directory\x20to\x0ayour\x20$PATH\x20so\x20you\x20can\x20use\x20installed\x20tools.\x0a

    \x0a\x0a

    \x0aNote\x20that\x20the\x20Go\x20distribution's\x20executables\x20are\x20installed\x20in\x0a$GOROOT/bin\x20(for\x20executables\x20invoked\x20by\x20people)\x20or\x0a$GOTOOLDIR\x20(for\x20executables\x20invoked\x20by\x20the\x20go\x20command;\x0adefaults\x20to\x20$GOROOT/pkg/$GOOS_GOARCH)\x20instead\x20of\x0a$GOBIN.\x0a

    \x0a
  • \x0a\x0a
  • $GOOS\x20and\x20$GOARCH\x0a

    \x0aThe\x20name\x20of\x20the\x20target\x20operating\x20system\x20and\x20compilation\x20architecture.\x0aThese\x20default\x20to\x20the\x20values\x20of\x20$GOHOSTOS\x20and\x0a$GOHOSTARCH\x20respectively\x20(described\x20below).\x0a

  • \x0a\x0a

    \x0aChoices\x20for\x20$GOOS\x20are\x0aandroid,\x20darwin\x20(macOS/iOS),\x0adragonfly,\x20freebsd,\x20illumos,\x20js,\x0alinux,\x20netbsd,\x20openbsd,\x0aplan9,\x20solaris\x20and\x20windows.\x0a

    \x0a\x0a

    \x0aChoices\x20for\x20$GOARCH\x20are\x0aamd64\x20(64-bit\x20x86,\x20the\x20most\x20mature\x20port),\x0a386\x20(32-bit\x20x86),\x20arm\x20(32-bit\x20ARM),\x20arm64\x20(64-bit\x20ARM),\x0appc64le\x20(PowerPC\x2064-bit,\x20little-endian),\x20ppc64\x20(PowerPC\x2064-bit,\x20big-endian),\x0amips64le\x20(MIPS\x2064-bit,\x20little-endian),\x20mips64\x20(MIPS\x2064-bit,\x20big-endian),\x0amipsle\x20(MIPS\x2032-bit,\x20little-endian),\x20mips\x20(MIPS\x2032-bit,\x20big-endian),\x0as390x\x20(IBM\x20System\x20z\x2064-bit,\x20big-endian),\x20and\x0awasm\x20(WebAssembly\x2032-bit).\x0a

    \x0a\x0a

    \x0aThe\x20valid\x20combinations\x20of\x20$GOOS\x20and\x20$GOARCH\x20are:\x0a\x0a\x0a$GOOS\x20$GOARCH\x0a\x0a\x0aaix\x20ppc64\x0a\x0a\x0aandroid\x20386\x0a\x0a\x0aandroid\x20amd64\x0a\x0a\x0aandroid\x20arm\x0a\x0a\x0aandroid\x20arm64\x0a\x0a\x0adarwin\x20amd64\x0a\x0a\x0adarwin\x20arm64\x0a\x0a\x0adragonfly\x20amd64\x0a\x0a\x0afreebsd\x20386\x0a\x0a\x0afreebsd\x20amd64\x0a\x0a\x0afreebsd\x20arm\x0a\x0a\x0aillumos\x20amd64\x0a\x0a\x0ajs\x20wasm\x0a\x0a\x0alinux\x20386\x0a\x0a\x0alinux\x20amd64\x0a\x0a\x0alinux\x20arm\x0a\x0a\x0alinux\x20arm64\x0a\x0a\x0alinux\x20ppc64\x0a\x0a\x0alinux\x20ppc64le\x0a\x0a\x0alinux\x20mips\x0a\x0a\x0alinux\x20mipsle\x0a\x0a\x0alinux\x20mips64\x0a\x0a\x0alinux\x20mips64le\x0a\x0a\x0alinux\x20s390x\x0a\x0a\x0anetbsd\x20386\x0a\x0a\x0anetbsd\x20amd64\x0a\x0a\x0anetbsd\x20arm\x0a\x0a\x0aopenbsd\x20386\x0a\x0a\x0aopenbsd\x20amd64\x0a\x0a\x0aopenbsd\x20arm\x0a\x0a\x0aopenbsd\x20arm64\x0a\x0a\x0aplan9\x20386\x0a\x0a\x0aplan9\x20amd64\x0a\x0a\x0aplan9\x20arm\x0a\x0a\x0asolaris\x20amd64\x0a\x0a\x0awindows\x20386\x0a\x0a\x0awindows\x20amd64\x0a\x0a\x0a
    \x0a\x0a

  • $GOHOSTOS\x20and\x20$GOHOSTARCH\x0a

    \x0aThe\x20name\x20of\x20the\x20host\x20operating\x20system\x20and\x20compilation\x20architecture.\x0aThese\x20default\x20to\x20the\x20local\x20system's\x20operating\x20system\x20and\x0aarchitecture.\x0a

    \x0a
  • \x0a\x0a

    \x0aValid\x20choices\x20are\x20the\x20same\x20as\x20for\x20$GOOS\x20and\x0a$GOARCH,\x20listed\x20above.\x0aThe\x20specified\x20values\x20must\x20be\x20compatible\x20with\x20the\x20local\x20system.\x0aFor\x20example,\x20you\x20should\x20not\x20set\x20$GOHOSTARCH\x20to\x0aarm\x20on\x20an\x20x86\x20system.\x0a

    \x0a\x0a
  • $GO386\x20(for\x20386\x20only,\x20default\x20is\x20auto-detected\x0aif\x20built\x20on\x20either\x20386\x20or\x20amd64,\x20387\x20otherwise)\x0a

    \x0aThis\x20controls\x20the\x20code\x20generated\x20by\x20gc\x20to\x20use\x20either\x20the\x20387\x20floating-point\x20unit\x0a(set\x20to\x20387)\x20or\x20SSE2\x20instructions\x20(set\x20to\x20sse2)\x20for\x0afloating\x20point\x20computations.\x0a

    \x0a
      \x0a\x09
    • GO386=387:\x20use\x20x87\x20for\x20floating\x20point\x20operations;\x20should\x20support\x20all\x20x86\x20chips\x20(Pentium\x20MMX\x20or\x20later).
    • \x0a\x09
    • GO386=sse2:\x20use\x20SSE2\x20for\x20floating\x20point\x20operations;\x20has\x20better\x20performance\x20than\x20387,\x20but\x20only\x20available\x20on\x20Pentium\x204/Opteron/Athlon\x2064\x20or\x20later.
    • \x0a
    \x0a
  • \x0a\x0a
  • $GOARM\x20(for\x20arm\x20only;\x20default\x20is\x20auto-detected\x20if\x20building\x0aon\x20the\x20target\x20processor,\x206\x20if\x20not)\x0a

    \x0aThis\x20sets\x20the\x20ARM\x20floating\x20point\x20co-processor\x20architecture\x20version\x20the\x20run-time\x0ashould\x20target.\x20If\x20you\x20are\x20compiling\x20on\x20the\x20target\x20system,\x20its\x20value\x20will\x20be\x20auto-detected.\x0a

    \x0a
      \x0a\x09
    • GOARM=5:\x20use\x20software\x20floating\x20point;\x20when\x20CPU\x20doesn't\x20have\x20VFP\x20co-processor
    • \x0a\x09
    • GOARM=6:\x20use\x20VFPv1\x20only;\x20default\x20if\x20cross\x20compiling;\x20usually\x20ARM11\x20or\x20better\x20cores\x20(VFPv2\x20or\x20better\x20is\x20also\x20supported)
    • \x0a\x09
    • GOARM=7:\x20use\x20VFPv3;\x20usually\x20Cortex-A\x20cores
    • \x0a
    \x0a

    \x0aIf\x20in\x20doubt,\x20leave\x20this\x20variable\x20unset,\x20and\x20adjust\x20it\x20if\x20required\x0awhen\x20you\x20first\x20run\x20the\x20Go\x20executable.\x0aThe\x20GoARM\x20page\x0aon\x20the\x20Go\x20community\x20wiki\x0acontains\x20further\x20details\x20regarding\x20Go's\x20ARM\x20support.\x0a

    \x0a
  • \x0a\x0a
  • $GOMIPS\x20(for\x20mips\x20and\x20mipsle\x20only)\x20
    \x20$GOMIPS64\x20(for\x20mips64\x20and\x20mips64le\x20only)\x0a

    \x0a\x09These\x20variables\x20set\x20whether\x20to\x20use\x20floating\x20point\x20instructions.\x20Set\x20to\x20\"hardfloat\"\x20to\x20use\x20floating\x20point\x20instructions;\x20this\x20is\x20the\x20default.\x20\x20Set\x20to\x20\"softfloat\"\x20to\x20use\x20soft\x20floating\x20point.\x0a

    \x0a
  • \x0a\x0a
  • $GOPPC64\x20(for\x20ppc64\x20and\x20ppc64le\x20only)\x0a

    \x0aThis\x20variable\x20sets\x20the\x20processor\x20level\x20(i.e.\x20Instruction\x20Set\x20Architecture\x20version)\x0afor\x20which\x20the\x20compiler\x20will\x20target.\x20The\x20default\x20is\x20power8.\x0a

    \x0a
      \x0a\x09
    • GOPPC64=power8:\x20generate\x20ISA\x20v2.07\x20instructions
    • \x0a\x09
    • GOPPC64=power9:\x20generate\x20ISA\x20v3.00\x20instructions
    • \x0a
    \x0a
  • \x0a\x0a\x0a
  • $GOWASM\x20(for\x20wasm\x20only)\x0a\x09

    \x0a\x09This\x20variable\x20is\x20a\x20comma\x20separated\x20list\x20of\x20experimental\x20WebAssembly\x20features\x20that\x20the\x20compiled\x20WebAssembly\x20binary\x20is\x20allowed\x20to\x20use.\x0a\x09The\x20default\x20is\x20to\x20use\x20no\x20experimental\x20features.\x0a\x09

    \x0a\x09
      \x0a\x09\x09
    • GOWASM=satconv:\x20generate\x20saturating\x20(non-trapping)\x20float-to-int\x20conversions
    • \x0a\x09\x09
    • GOWASM=signext:\x20generate\x20sign-extension\x20operators
    • \x0a\x09
    \x0a
  • \x0a\x0a
\x0a\x0a

\x0aNote\x20that\x20$GOARCH\x20and\x20$GOOS\x20identify\x20the\x0atarget\x20environment,\x20not\x20the\x20environment\x20you\x20are\x20running\x20on.\x0aIn\x20effect,\x20you\x20are\x20always\x20cross-compiling.\x0aBy\x20architecture,\x20we\x20mean\x20the\x20kind\x20of\x20binaries\x0athat\x20the\x20target\x20environment\x20can\x20run:\x0aan\x20x86-64\x20system\x20running\x20a\x2032-bit-only\x20operating\x20system\x0amust\x20set\x20GOARCH\x20to\x20386,\x0anot\x20amd64.\x0a

\x0a\x0a

\x0aIf\x20you\x20choose\x20to\x20override\x20the\x20defaults,\x0aset\x20these\x20variables\x20in\x20your\x20shell\x20profile\x20($HOME/.bashrc,\x0a$HOME/.profile,\x20or\x20equivalent).\x20The\x20settings\x20might\x20look\x0asomething\x20like\x20this:\x0a

\x0a\x0a
\x0aexport\x20GOARCH=amd64\x0aexport\x20GOOS=linux\x0a
\x0a\x0a

\x0aalthough,\x20to\x20reiterate,\x20none\x20of\x20these\x20variables\x20needs\x20to\x20be\x20set\x20to\x20build,\x0ainstall,\x20and\x20develop\x20the\x20Go\x20tree.\x0a

\x0a", From b3ad3c6884b777089269e344754918441674309d Mon Sep 17 00:00:00 2001 From: kekaiwang Date: Tue, 24 Nov 2020 20:57:59 +0800 Subject: [PATCH 02/12] Revert "transaction install" This reverts commit 33c1e377c565cecd59e0eaefe6799870980f30ce. --- content/static/doc/install.html | 29 +++++++++++++---------------- content/static/static.go | 2 +- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/content/static/doc/install.html b/content/static/doc/install.html index 09366631f9..b759457040 100644 --- a/content/static/doc/install.html +++ b/content/static/doc/install.html @@ -3,40 +3,37 @@ "Path": "/doc/install" }-->

- 按照下面的步骤快速下载和安装 Go. + Download and install Go quickly with the steps described here.

-

关于安装的另一个内容,你肯定感兴趣:

+

For other content on installing, you might be interested in:

-

1. 下载 Go

+

1. Go download.

- 点击下面的按钮进行下载 Go 安装包。 + Click the button below to download the Go installer.

- 下载 Go + Download Go

- 没有找到你系统的安装包?选择 - 其他下载. + Don't see your operating system here? Try one of the + other downloads.

2. Go install.

diff --git a/content/static/static.go b/content/static/static.go index 97d3b72da7..20408f39f6 100644 --- a/content/static/static.go +++ b/content/static/static.go @@ -65,7 +65,7 @@ var Files = map[string]string{ "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/install.html": "\x0a

\x0a\x20\x20\xe6\x8c\x89\xe7\x85\xa7\xe4\xb8\x8b\xe9\x9d\xa2\xe7\x9a\x84\xe6\xad\xa5\xe9\xaa\xa4\xe5\xbf\xab\xe9\x80\x9f\xe4\xb8\x8b\xe8\xbd\xbd\xe5\x92\x8c\xe5\xae\x89\xe8\xa3\x85\x20Go.\x0a

\x0a

\xe5\x85\xb3\xe4\xba\x8e\xe5\xae\x89\xe8\xa3\x85\xe7\x9a\x84\xe5\x8f\xa6\xe4\xb8\x80\xe4\xb8\xaa\xe5\x86\x85\xe5\xae\xb9\xef\xbc\x8c\xe4\xbd\xa0\xe8\x82\xaf\xe5\xae\x9a\xe6\x84\x9f\xe5\x85\xb4\xe8\xb6\xa3\xef\xbc\x9a

\x0a
    \x0a\x20\x20
  • \x0a\x20\x20\x20\x20\xe7\xae\xa1\xe7\x90\x86\x20Go\x20\xe7\x9a\x84\xe5\xae\x89\xe8\xa3\x85\x20--\x20\x0a\x20\x20\x20\x20\xe6\x80\x8e\xe4\xb9\x88\xe5\xae\x89\xe8\xa3\x85\xe5\xa4\x9a\xe4\xb8\xaa\xe7\x89\x88\xe6\x9c\xac\xe5\x92\x8c\xe5\x8d\xb8\xe8\xbd\xbd\xe3\x80\x82\x0a\x20\x20
  • \x0a\x20\x20
  • \x0a\x20\x20\x20\x20\xe9\x80\x9a\xe8\xbf\x87\xe6\xba\x90\xe7\xa0\x81\xe5\xae\x89\xe8\xa3\x85\x20Go\x20--\x20\xe6\x80\x8e\xe4\xb9\x88\xe8\x8e\xb7\xe5\xbe\x97\xe6\xba\x90\xe7\xa0\x81\xef\xbc\x8c\xe5\x9c\xa8\xe8\x87\xaa\xe5\xb7\xb1\xe7\x9a\x84\xe7\x94\xb5\xe8\x84\x91\xe4\xb8\x8a\xe7\xbc\x96\xe8\xaf\x91\xe5\xb9\xb6\xe8\xbf\x90\xe8\xa1\x8c\xe5\xa5\xb9\xe4\xbb\xac\xe3\x80\x82\x0a\x20\x20
  • \x0a
\x0a1.\x20\xe4\xb8\x8b\xe8\xbd\xbd\x20Go\x20\x0a

\x0a\x20\x20\xe7\x82\xb9\xe5\x87\xbb\xe4\xb8\x8b\xe9\x9d\xa2\xe7\x9a\x84\xe6\x8c\x89\xe9\x92\xae\xe8\xbf\x9b\xe8\xa1\x8c\xe4\xb8\x8b\xe8\xbd\xbd\x20Go\x20\xe5\xae\x89\xe8\xa3\x85\xe5\x8c\x85\xe3\x80\x82\x0a

\x0a

\x0a\x20\x20\x0a\x20\x20\x20\x20\xe4\xb8\x8b\xe8\xbd\xbd\x20Go\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a

\x0a

\x0a\x20\x20\xe6\xb2\xa1\xe6\x9c\x89\xe6\x89\xbe\xe5\x88\xb0\xe4\xbd\xa0\xe7\xb3\xbb\xe7\xbb\x9f\xe7\x9a\x84\xe5\xae\x89\xe8\xa3\x85\xe5\x8c\x85\xef\xbc\x9f\xe9\x80\x89\xe6\x8b\xa9\x0a\x20\x20\xe5\x85\xb6\xe4\xbb\x96\xe4\xb8\x8b\xe8\xbd\xbd.\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", + "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", "doc/install-source.html": "\x0a\x0a

This\x20topic\x20describes\x20how\x20to\x20build\x20and\x20run\x20Go\x20from\x20source\x20code.\x20To\x20install\x20with\x20an\x20installer,\x20see\x20Download\x20and\x20install.

\x0a\x0aIntroduction\x0a\x0a

\x0aGo\x20is\x20an\x20open\x20source\x20project,\x20distributed\x20under\x20a\x0aBSD-style\x20license.\x0aThis\x20document\x20explains\x20how\x20to\x20check\x20out\x20the\x20sources,\x0abuild\x20them\x20on\x20your\x20own\x20machine,\x20and\x20run\x20them.\x0a

\x0a\x0a

\x0aMost\x20users\x20don't\x20need\x20to\x20do\x20this,\x20and\x20will\x20instead\x20install\x0afrom\x20precompiled\x20binary\x20packages\x20as\x20described\x20in\x0aDownload\x20and\x20install,\x0aa\x20much\x20simpler\x20process.\x0aIf\x20you\x20want\x20to\x20help\x20develop\x20what\x20goes\x20into\x20those\x20precompiled\x0apackages,\x20though,\x20read\x20on.\x0a

\x0a\x0a\x0a\x0a

\x0aThere\x20are\x20two\x20official\x20Go\x20compiler\x20toolchains.\x0aThis\x20document\x20focuses\x20on\x20the\x20gc\x20Go\x0acompiler\x20and\x20tools.\x0aFor\x20information\x20on\x20how\x20to\x20work\x20on\x20gccgo,\x20a\x20more\x20traditional\x0acompiler\x20using\x20the\x20GCC\x20back\x20end,\x20see\x0aSetting\x20up\x20and\x20using\x20gccgo.\x0a

\x0a\x0a

\x0aThe\x20Go\x20compilers\x20support\x20the\x20following\x20instruction\x20sets:\x0a\x0a

\x0a
\x0a\x20\x20amd64,\x20386\x0a
\x0a
\x0a\x20\x20The\x20x86\x20instruction\x20set,\x2064-\x20and\x2032-bit.\x0a
\x0a
\x0a\x20\x20arm64,\x20arm\x0a
\x0a
\x0a\x20\x20The\x20ARM\x20instruction\x20set,\x2064-bit\x20(AArch64)\x20and\x2032-bit.\x0a
\x0a
\x0a\x20\x20mips64,\x20mips64le,\x20mips,\x20\x20mipsle\x0a
\x0a
\x0a\x20\x20The\x20MIPS\x20instruction\x20set,\x20big-\x20and\x20little-endian,\x2064-\x20and\x2032-bit.\x0a
\x0a
\x0a\x20\x20ppc64,\x20ppc64le\x0a
\x0a
\x0a\x20\x20The\x2064-bit\x20PowerPC\x20instruction\x20set,\x20big-\x20and\x20little-endian.\x0a
\x0a
\x0a\x20\x20riscv64\x0a
\x0a
\x0a\x20\x20The\x2064-bit\x20RISC-V\x20instruction\x20set.\x0a
\x0a
\x0a\x20\x20s390x\x0a
\x0a
\x0a\x20\x20The\x20IBM\x20z/Architecture.\x0a
\x0a
\x0a\x20\x20wasm\x0a
\x0a
\x0a\x20\x20WebAssembly.\x0a
\x0a
\x0a

\x0a\x0a

\x0aThe\x20compilers\x20can\x20target\x20the\x20AIX,\x20Android,\x20DragonFly\x20BSD,\x20FreeBSD,\x0aIllumos,\x20Linux,\x20macOS/iOS\x20(Darwin),\x20NetBSD,\x20OpenBSD,\x20Plan\x209,\x20Solaris,\x0aand\x20Windows\x20operating\x20systems\x20(although\x20not\x20all\x20operating\x20systems\x0asupport\x20all\x20architectures).\x0a

\x0a\x0a

\x0aA\x20list\x20of\x20ports\x20which\x20are\x20considered\x20\"first\x20class\"\x20is\x20available\x20at\x20the\x0afirst\x20class\x20ports\x0awiki\x20page.\x0a

\x0a\x0a

\x0aThe\x20full\x20set\x20of\x20supported\x20combinations\x20is\x20listed\x20in\x20the\x0adiscussion\x20of\x20environment\x20variables\x20below.\x0a

\x0a\x0a

\x0aSee\x20the\x20main\x20installation\x20page\x20for\x20the\x20overall\x20system\x20requirements.\x0aThe\x20following\x20additional\x20constraints\x20apply\x20to\x20systems\x20that\x20can\x20be\x20built\x20only\x20from\x20source:\x0a

\x0a\x0a
    \x0a
  • For\x20Linux\x20on\x20PowerPC\x2064-bit,\x20the\x20minimum\x20supported\x20kernel\x20version\x20is\x202.6.37,\x20meaning\x20that\x0aGo\x20does\x20not\x20support\x20CentOS\x206\x20on\x20these\x20systems.\x0a
  • \x0a
\x0a\x20\x0a\x0a\x0aInstall\x20Go\x20compiler\x20binaries\x20for\x20bootstrap\x0a\x0a

\x0aThe\x20Go\x20toolchain\x20is\x20written\x20in\x20Go.\x20To\x20build\x20it,\x20you\x20need\x20a\x20Go\x20compiler\x20installed.\x0aThe\x20scripts\x20that\x20do\x20the\x20initial\x20build\x20of\x20the\x20tools\x20look\x20for\x20a\x20\"go\"\x20command\x0ain\x20$PATH,\x20so\x20as\x20long\x20as\x20you\x20have\x20Go\x20installed\x20in\x20your\x0asystem\x20and\x20configured\x20in\x20your\x20$PATH,\x20you\x20are\x20ready\x20to\x20build\x20Go\x0afrom\x20source.\x20\x0aOr\x20if\x20you\x20prefer\x20you\x20can\x20set\x20$GOROOT_BOOTSTRAP\x20to\x20the\x0aroot\x20of\x20a\x20Go\x20installation\x20to\x20use\x20to\x20build\x20the\x20new\x20Go\x20toolchain;\x0a$GOROOT_BOOTSTRAP/bin/go\x20should\x20be\x20the\x20go\x20command\x20to\x20use.

\x0a\x0aBootstrap\x20toolchain\x20from\x20binary\x20release\x0a\x0a

\x0aTo\x20use\x20a\x20binary\x20release\x20as\x20a\x20bootstrap\x20toolchain,\x20see\x0athe\x20downloads\x20page\x20or\x20use\x20any\x20other\x0apackaged\x20Go\x20distribution.\x0a

\x0a\x0aBootstrap\x20toolchain\x20from\x20source\x0a\x0a

\x0aTo\x20build\x20a\x20bootstrap\x20toolchain\x20from\x20source,\x20use\x0aeither\x20the\x20git\x20branch\x20release-branch.go1.4\x20or\x0ago1.4-bootstrap-20171003.tar.gz,\x0awhich\x20contains\x20the\x20Go\x201.4\x20source\x20code\x20plus\x20accumulated\x20fixes\x0ato\x20keep\x20the\x20tools\x20running\x20on\x20newer\x20operating\x20systems.\x0a(Go\x201.4\x20was\x20the\x20last\x20distribution\x20in\x20which\x20the\x20toolchain\x20was\x20written\x20in\x20C.)\x0aAfter\x20unpacking\x20the\x20Go\x201.4\x20source,\x20cd\x20to\x0athe\x20src\x20subdirectory,\x20set\x20CGO_ENABLED=0\x20in\x0athe\x20environment,\x20and\x20run\x20make.bash\x20(or,\x0aon\x20Windows,\x20make.bat).\x0a

\x0a\x0a

\x0aOnce\x20the\x20Go\x201.4\x20source\x20has\x20been\x20unpacked\x20into\x20your\x20GOROOT_BOOTSTRAP\x20directory,\x0ayou\x20must\x20keep\x20this\x20git\x20clone\x20instance\x20checked\x20out\x20to\x20branch\x0arelease-branch.go1.4.\x20\x20Specifically,\x20do\x20not\x20attempt\x20to\x20reuse\x0athis\x20git\x20clone\x20in\x20the\x20later\x20step\x20named\x20\"Fetch\x20the\x20repository.\"\x20\x20The\x20go1.4\x0abootstrap\x20toolchain\x20must\x20be\x20able\x20to\x20properly\x20traverse\x20the\x20go1.4\x20sources\x0athat\x20it\x20assumes\x20are\x20present\x20under\x20this\x20repository\x20root.\x0a

\x0a\x0aBootstrap\x20toolchain\x20from\x20cross-compiled\x20source\x0a\x0a

\x0aTo\x20cross-compile\x20a\x20bootstrap\x20toolchain\x20from\x20source,\x20which\x20is\x0anecessary\x20on\x20systems\x20Go\x201.4\x20did\x20not\x20target\x20(for\x0aexample,\x20linux/ppc64le),\x20install\x20Go\x20on\x20a\x20different\x20system\x0aand\x20run\x20bootstrap.bash.\x0a

\x0a\x0a

\x0aWhen\x20run\x20as\x20(for\x20example)\x0a

\x0a\x0a
\x0a$\x20GOOS=linux\x20GOARCH=ppc64\x20./bootstrap.bash\x0a
\x0a\x0a

\x0abootstrap.bash\x20cross-compiles\x20a\x20toolchain\x20for\x20that\x20GOOS/GOARCH\x0acombination,\x20leaving\x20the\x20resulting\x20tree\x20in\x20../../go-${GOOS}-${GOARCH}-bootstrap.\x0aThat\x20tree\x20can\x20be\x20copied\x20to\x20a\x20machine\x20of\x20the\x20given\x20target\x20type\x0aand\x20used\x20as\x20GOROOT_BOOTSTRAP\x20to\x20bootstrap\x20a\x20local\x20build.\x0a

\x0a\x0aBootstrap\x20toolchain\x20using\x20gccgo\x0a\x0a

\x0aTo\x20use\x20gccgo\x20as\x20the\x20bootstrap\x20toolchain,\x20you\x20need\x20to\x20arrange\x0afor\x20$GOROOT_BOOTSTRAP/bin/go\x20to\x20be\x20the\x20go\x20tool\x20that\x20comes\x0aas\x20part\x20of\x20gccgo\x205.\x20For\x20example\x20on\x20Ubuntu\x20Vivid:\x0a

\x0a\x0a
\x0a$\x20sudo\x20apt-get\x20install\x20gccgo-5\x0a$\x20sudo\x20update-alternatives\x20--set\x20go\x20/usr/bin/go-5\x0a$\x20GOROOT_BOOTSTRAP=/usr\x20./make.bash\x0a
\x0a\x0aInstall\x20Git,\x20if\x20needed\x0a\x0a

\x0aTo\x20perform\x20the\x20next\x20step\x20you\x20must\x20have\x20Git\x20installed.\x20(Check\x20that\x20you\x0ahave\x20a\x20git\x20command\x20before\x20proceeding.)\x0a

\x0a\x0a

\x0aIf\x20you\x20do\x20not\x20have\x20a\x20working\x20Git\x20installation,\x0afollow\x20the\x20instructions\x20on\x20the\x0aGit\x20downloads\x20page.\x0a

\x0a\x0a(Optional)\x20Install\x20a\x20C\x20compiler\x0a\x0a

\x0aTo\x20build\x20a\x20Go\x20installation\x0awith\x20cgo\x20support,\x20which\x20permits\x20Go\x0aprograms\x20to\x20import\x20C\x20libraries,\x20a\x20C\x20compiler\x20such\x20as\x20gcc\x0aor\x20clang\x20must\x20be\x20installed\x20first.\x20Do\x20this\x20using\x20whatever\x0ainstallation\x20method\x20is\x20standard\x20on\x20the\x20system.\x0a

\x0a\x0a

\x0aTo\x20build\x20without\x20cgo,\x20set\x20the\x20environment\x20variable\x0aCGO_ENABLED=0\x20before\x20running\x20all.bash\x20or\x0amake.bash.\x0a

\x0a\x0aFetch\x20the\x20repository\x0a\x0a

Change\x20to\x20the\x20directory\x20where\x20you\x20intend\x20to\x20install\x20Go,\x20and\x20make\x20sure\x0athe\x20goroot\x20directory\x20does\x20not\x20exist.\x20Then\x20clone\x20the\x20repository\x0aand\x20check\x20out\x20the\x20latest\x20release\x20tag\x20(go1.12,\x0afor\x20example):

\x0a\x0a
\x0a$\x20git\x20clone\x20https://go.googlesource.com/go\x20goroot\x0a$\x20cd\x20goroot\x0a$\x20git\x20checkout\x20<tag>\x0a
\x0a\x0a\x0aWhere\x20<tag>\x20is\x20the\x20version\x20string\x20of\x20the\x20release.\x0a

\x0a\x0a

Go\x20will\x20be\x20installed\x20in\x20the\x20directory\x20where\x20it\x20is\x20checked\x20out.\x20For\x20example,\x0aif\x20Go\x20is\x20checked\x20out\x20in\x20$HOME/goroot,\x20executables\x20will\x20be\x20installed\x0ain\x20$HOME/goroot/bin.\x20The\x20directory\x20may\x20have\x20any\x20name,\x20but\x20note\x0athat\x20if\x20Go\x20is\x20checked\x20out\x20in\x20$HOME/go,\x20it\x20will\x20conflict\x20with\x0athe\x20default\x20location\x20of\x20$GOPATH.\x0aSee\x20GOPATH\x20below.

\x0a\x0a

\x0aReminder:\x20If\x20you\x20opted\x20to\x20also\x20compile\x20the\x20bootstrap\x20binaries\x20from\x20source\x20(in\x20an\x0aearlier\x20section),\x20you\x20still\x20need\x20to\x20git\x20clone\x20again\x20at\x20this\x20point\x0a(to\x20checkout\x20the\x20latest\x20<tag>),\x20because\x20you\x20must\x20keep\x20your\x0ago1.4\x20repository\x20distinct.\x0a

\x0a\x0a(Optional)\x20Switch\x20to\x20the\x20master\x20branch\x0a\x0a

If\x20you\x20intend\x20to\x20modify\x20the\x20go\x20source\x20code,\x20and\x0acontribute\x20your\x20changes\x0ato\x20the\x20project,\x20then\x20move\x20your\x20repository\x0aoff\x20the\x20release\x20branch,\x20and\x20onto\x20the\x20master\x20(development)\x20branch.\x0aOtherwise,\x20skip\x20this\x20step.

\x0a\x0a
\x0a$\x20git\x20checkout\x20master\x0a
\x0a\x0aInstall\x20Go\x0a\x0a

\x0aTo\x20build\x20the\x20Go\x20distribution,\x20run\x0a

\x0a\x0a
\x0a$\x20cd\x20src\x0a$\x20./all.bash\x0a
\x0a\x0a

\x0a(To\x20build\x20under\x20Windows\x20use\x20all.bat.)\x0a

\x0a\x0a

\x0aIf\x20all\x20goes\x20well,\x20it\x20will\x20finish\x20by\x20printing\x20output\x20like:\x0a

\x0a\x0a
\x0aALL\x20TESTS\x20PASSED\x0a\x0a---\x0aInstalled\x20Go\x20for\x20linux/amd64\x20in\x20/home/you/go.\x0aInstalled\x20commands\x20in\x20/home/you/go/bin.\x0a***\x20You\x20need\x20to\x20add\x20/home/you/go/bin\x20to\x20your\x20$PATH.\x20***\x0a
\x0a\x0a

\x0awhere\x20the\x20details\x20on\x20the\x20last\x20few\x20lines\x20reflect\x20the\x20operating\x20system,\x0aarchitecture,\x20and\x20root\x20directory\x20used\x20during\x20the\x20install.\x0a

\x0a\x0a\x0a

\x0aFor\x20more\x20information\x20about\x20ways\x20to\x20control\x20the\x20build,\x20see\x20the\x20discussion\x20of\x0aenvironment\x20variables\x20below.\x0aall.bash\x20(or\x20all.bat)\x20runs\x20important\x20tests\x20for\x20Go,\x0awhich\x20can\x20take\x20more\x20time\x20than\x20simply\x20building\x20Go.\x20If\x20you\x20do\x20not\x20want\x20to\x20run\x0athe\x20test\x20suite\x20use\x20make.bash\x20(or\x20make.bat)\x0ainstead.\x0a

\x0a\x0a\x0a\x0aTesting\x20your\x20installation\x0a\x0a

\x0aCheck\x20that\x20Go\x20is\x20installed\x20correctly\x20by\x20building\x20a\x20simple\x20program.\x0a

\x0a\x0a

\x0aCreate\x20a\x20file\x20named\x20hello.go\x20and\x20put\x20the\x20following\x20program\x20in\x20it:\x0a

\x0a\x0a
\x0apackage\x20main\x0a\x0aimport\x20\"fmt\"\x0a\x0afunc\x20main()\x20{\x0a\x09fmt.Printf(\"hello,\x20world\\n\")\x0a}\x0a
\x0a\x0a

\x0aThen\x20run\x20it\x20with\x20the\x20go\x20tool:\x0a

\x0a\x0a
\x0a$\x20go\x20run\x20hello.go\x0ahello,\x20world\x0a
\x0a\x0a

\x0aIf\x20you\x20see\x20the\x20\"hello,\x20world\"\x20message\x20then\x20Go\x20is\x20installed\x20correctly.\x0a

\x0a\x0aSet\x20up\x20your\x20work\x20environment\x0a\x0a

\x0aYou're\x20almost\x20done.\x0aYou\x20just\x20need\x20to\x20do\x20a\x20little\x20more\x20setup.\x0a

\x0a\x0a

\x0a\x0aHow\x20to\x20Write\x20Go\x20Code\x0aLearn\x20how\x20to\x20set\x20up\x20and\x20use\x20the\x20Go\x20tools\x0a\x0a

\x0a\x0a

\x0aThe\x20How\x20to\x20Write\x20Go\x20Code\x20document\x0aprovides\x20essential\x20setup\x20instructions\x20for\x20using\x20the\x20Go\x20tools.\x0a

\x0a\x0a\x0aInstall\x20additional\x20tools\x0a\x0a

\x0aThe\x20source\x20code\x20for\x20several\x20Go\x20tools\x20(including\x20godoc)\x0ais\x20kept\x20in\x20the\x20go.tools\x20repository.\x0aTo\x20install\x20one\x20of\x20the\x20tools\x20(godoc\x20in\x20this\x20case):\x0a

\x0a\x0a
\x0a$\x20go\x20get\x20golang.org/x/tools/cmd/godoc\x0a
\x0a\x0a

\x0aTo\x20install\x20these\x20tools,\x20the\x20go\x20get\x20command\x20requires\x0athat\x20Git\x20be\x20installed\x20locally.\x0a

\x0a\x0a

\x0aYou\x20must\x20also\x20have\x20a\x20workspace\x20(GOPATH)\x20set\x20up;\x0asee\x20How\x20to\x20Write\x20Go\x20Code\x20for\x20the\x20details.\x0a

\x0a\x0aCommunity\x20resources\x0a\x0a

\x0aThe\x20usual\x20community\x20resources\x20such\x20as\x0a#go-nuts\x20on\x20the\x20Freenode\x20IRC\x20server\x0aand\x20the\x0aGo\x20Nuts\x0amailing\x20list\x20have\x20active\x20developers\x20that\x20can\x20help\x20you\x20with\x20problems\x0awith\x20your\x20installation\x20or\x20your\x20development\x20work.\x0aFor\x20those\x20who\x20wish\x20to\x20keep\x20up\x20to\x20date,\x0athere\x20is\x20another\x20mailing\x20list,\x20golang-checkins,\x0athat\x20receives\x20a\x20message\x20summarizing\x20each\x20checkin\x20to\x20the\x20Go\x20repository.\x0a

\x0a\x0a

\x0aBugs\x20can\x20be\x20reported\x20using\x20the\x20Go\x20issue\x20tracker.\x0a

\x0a\x0a\x0aKeeping\x20up\x20with\x20releases\x0a\x0a

\x0aNew\x20releases\x20are\x20announced\x20on\x20the\x0agolang-announce\x0amailing\x20list.\x0aEach\x20announcement\x20mentions\x20the\x20latest\x20release\x20tag,\x20for\x20instance,\x0ago1.9.\x0a

\x0a\x0a

\x0aTo\x20update\x20an\x20existing\x20tree\x20to\x20the\x20latest\x20release,\x20you\x20can\x20run:\x0a

\x0a\x0a
\x0a$\x20cd\x20go/src\x0a$\x20git\x20fetch\x0a$\x20git\x20checkout\x20<tag>\x0a$\x20./all.bash\x0a
\x0a\x0a\x0aWhere\x20<tag>\x20is\x20the\x20version\x20string\x20of\x20the\x20release.\x0a

\x0a\x0a\x0aOptional\x20environment\x20variables\x0a\x0a

\x0aThe\x20Go\x20compilation\x20environment\x20can\x20be\x20customized\x20by\x20environment\x20variables.\x0aNone\x20is\x20required\x20by\x20the\x20build,\x20but\x20you\x20may\x20wish\x20to\x20set\x20some\x0ato\x20override\x20the\x20defaults.\x0a

\x0a\x0a
    \x0a
  • $GOROOT\x0a

    \x0aThe\x20root\x20of\x20the\x20Go\x20tree,\x20often\x20$HOME/go1.X.\x0aIts\x20value\x20is\x20built\x20into\x20the\x20tree\x20when\x20it\x20is\x20compiled,\x20and\x0adefaults\x20to\x20the\x20parent\x20of\x20the\x20directory\x20where\x20all.bash\x20was\x20run.\x0aThere\x20is\x20no\x20need\x20to\x20set\x20this\x20unless\x20you\x20want\x20to\x20switch\x20between\x20multiple\x0alocal\x20copies\x20of\x20the\x20repository.\x0a

    \x0a
  • \x0a\x0a
  • $GOROOT_FINAL\x0a

    \x0aThe\x20value\x20assumed\x20by\x20installed\x20binaries\x20and\x20scripts\x20when\x0a$GOROOT\x20is\x20not\x20set\x20explicitly.\x0aIt\x20defaults\x20to\x20the\x20value\x20of\x20$GOROOT.\x0aIf\x20you\x20want\x20to\x20build\x20the\x20Go\x20tree\x20in\x20one\x20location\x0abut\x20move\x20it\x20elsewhere\x20after\x20the\x20build,\x20set\x0a$GOROOT_FINAL\x20to\x20the\x20eventual\x20location.\x0a

    \x0a
  • \x0a\x0a$GOPATH\x0a

    \x0aThe\x20directory\x20where\x20Go\x20projects\x20outside\x20the\x20Go\x20distribution\x20are\x20typically\x0achecked\x20out.\x20For\x20example,\x20golang.org/x/tools\x20might\x20be\x20checked\x20out\x0ato\x20$GOPATH/src/golang.org/x/tools.\x20Executables\x20outside\x20the\x0aGo\x20distribution\x20are\x20installed\x20in\x20$GOPATH/bin\x20(or\x0a$GOBIN,\x20if\x20set).\x20Modules\x20are\x20downloaded\x20and\x20cached\x20in\x0a$GOPATH/pkg/mod.\x0a

    \x0a\x0a

    The\x20default\x20location\x20of\x20$GOPATH\x20is\x20$HOME/go,\x0aand\x20it's\x20not\x20usually\x20necessary\x20to\x20set\x20GOPATH\x20explicitly.\x20However,\x0aif\x20you\x20have\x20checked\x20out\x20the\x20Go\x20distribution\x20to\x20$HOME/go,\x0ayou\x20must\x20set\x20GOPATH\x20to\x20another\x20location\x20to\x20avoid\x20conflicts.\x0a

    \x0a\x0a\x0a
  • $GOBIN\x0a

    \x0aThe\x20directory\x20where\x20executables\x20outside\x20the\x20Go\x20distribution\x20are\x20installed\x0ausing\x20the\x20go\x20command.\x20For\x20example,\x0ago\x20get\x20golang.org/x/tools/cmd/godoc\x20downloads,\x20builds,\x20and\x0ainstalls\x20$GOBIN/godoc.\x20By\x20default,\x20$GOBIN\x20is\x0a$GOPATH/bin\x20(or\x20$HOME/go/bin\x20if\x20GOPATH\x0ais\x20not\x20set).\x20After\x20installing,\x20you\x20will\x20want\x20to\x20add\x20this\x20directory\x20to\x0ayour\x20$PATH\x20so\x20you\x20can\x20use\x20installed\x20tools.\x0a

    \x0a\x0a

    \x0aNote\x20that\x20the\x20Go\x20distribution's\x20executables\x20are\x20installed\x20in\x0a$GOROOT/bin\x20(for\x20executables\x20invoked\x20by\x20people)\x20or\x0a$GOTOOLDIR\x20(for\x20executables\x20invoked\x20by\x20the\x20go\x20command;\x0adefaults\x20to\x20$GOROOT/pkg/$GOOS_GOARCH)\x20instead\x20of\x0a$GOBIN.\x0a

    \x0a
  • \x0a\x0a
  • $GOOS\x20and\x20$GOARCH\x0a

    \x0aThe\x20name\x20of\x20the\x20target\x20operating\x20system\x20and\x20compilation\x20architecture.\x0aThese\x20default\x20to\x20the\x20values\x20of\x20$GOHOSTOS\x20and\x0a$GOHOSTARCH\x20respectively\x20(described\x20below).\x0a

  • \x0a\x0a

    \x0aChoices\x20for\x20$GOOS\x20are\x0aandroid,\x20darwin\x20(macOS/iOS),\x0adragonfly,\x20freebsd,\x20illumos,\x20js,\x0alinux,\x20netbsd,\x20openbsd,\x0aplan9,\x20solaris\x20and\x20windows.\x0a

    \x0a\x0a

    \x0aChoices\x20for\x20$GOARCH\x20are\x0aamd64\x20(64-bit\x20x86,\x20the\x20most\x20mature\x20port),\x0a386\x20(32-bit\x20x86),\x20arm\x20(32-bit\x20ARM),\x20arm64\x20(64-bit\x20ARM),\x0appc64le\x20(PowerPC\x2064-bit,\x20little-endian),\x20ppc64\x20(PowerPC\x2064-bit,\x20big-endian),\x0amips64le\x20(MIPS\x2064-bit,\x20little-endian),\x20mips64\x20(MIPS\x2064-bit,\x20big-endian),\x0amipsle\x20(MIPS\x2032-bit,\x20little-endian),\x20mips\x20(MIPS\x2032-bit,\x20big-endian),\x0as390x\x20(IBM\x20System\x20z\x2064-bit,\x20big-endian),\x20and\x0awasm\x20(WebAssembly\x2032-bit).\x0a

    \x0a\x0a

    \x0aThe\x20valid\x20combinations\x20of\x20$GOOS\x20and\x20$GOARCH\x20are:\x0a\x0a\x0a$GOOS\x20$GOARCH\x0a\x0a\x0aaix\x20ppc64\x0a\x0a\x0aandroid\x20386\x0a\x0a\x0aandroid\x20amd64\x0a\x0a\x0aandroid\x20arm\x0a\x0a\x0aandroid\x20arm64\x0a\x0a\x0adarwin\x20amd64\x0a\x0a\x0adarwin\x20arm64\x0a\x0a\x0adragonfly\x20amd64\x0a\x0a\x0afreebsd\x20386\x0a\x0a\x0afreebsd\x20amd64\x0a\x0a\x0afreebsd\x20arm\x0a\x0a\x0aillumos\x20amd64\x0a\x0a\x0ajs\x20wasm\x0a\x0a\x0alinux\x20386\x0a\x0a\x0alinux\x20amd64\x0a\x0a\x0alinux\x20arm\x0a\x0a\x0alinux\x20arm64\x0a\x0a\x0alinux\x20ppc64\x0a\x0a\x0alinux\x20ppc64le\x0a\x0a\x0alinux\x20mips\x0a\x0a\x0alinux\x20mipsle\x0a\x0a\x0alinux\x20mips64\x0a\x0a\x0alinux\x20mips64le\x0a\x0a\x0alinux\x20s390x\x0a\x0a\x0anetbsd\x20386\x0a\x0a\x0anetbsd\x20amd64\x0a\x0a\x0anetbsd\x20arm\x0a\x0a\x0aopenbsd\x20386\x0a\x0a\x0aopenbsd\x20amd64\x0a\x0a\x0aopenbsd\x20arm\x0a\x0a\x0aopenbsd\x20arm64\x0a\x0a\x0aplan9\x20386\x0a\x0a\x0aplan9\x20amd64\x0a\x0a\x0aplan9\x20arm\x0a\x0a\x0asolaris\x20amd64\x0a\x0a\x0awindows\x20386\x0a\x0a\x0awindows\x20amd64\x0a\x0a\x0a
    \x0a\x0a

  • $GOHOSTOS\x20and\x20$GOHOSTARCH\x0a

    \x0aThe\x20name\x20of\x20the\x20host\x20operating\x20system\x20and\x20compilation\x20architecture.\x0aThese\x20default\x20to\x20the\x20local\x20system's\x20operating\x20system\x20and\x0aarchitecture.\x0a

    \x0a
  • \x0a\x0a

    \x0aValid\x20choices\x20are\x20the\x20same\x20as\x20for\x20$GOOS\x20and\x0a$GOARCH,\x20listed\x20above.\x0aThe\x20specified\x20values\x20must\x20be\x20compatible\x20with\x20the\x20local\x20system.\x0aFor\x20example,\x20you\x20should\x20not\x20set\x20$GOHOSTARCH\x20to\x0aarm\x20on\x20an\x20x86\x20system.\x0a

    \x0a\x0a
  • $GO386\x20(for\x20386\x20only,\x20default\x20is\x20auto-detected\x0aif\x20built\x20on\x20either\x20386\x20or\x20amd64,\x20387\x20otherwise)\x0a

    \x0aThis\x20controls\x20the\x20code\x20generated\x20by\x20gc\x20to\x20use\x20either\x20the\x20387\x20floating-point\x20unit\x0a(set\x20to\x20387)\x20or\x20SSE2\x20instructions\x20(set\x20to\x20sse2)\x20for\x0afloating\x20point\x20computations.\x0a

    \x0a
      \x0a\x09
    • GO386=387:\x20use\x20x87\x20for\x20floating\x20point\x20operations;\x20should\x20support\x20all\x20x86\x20chips\x20(Pentium\x20MMX\x20or\x20later).
    • \x0a\x09
    • GO386=sse2:\x20use\x20SSE2\x20for\x20floating\x20point\x20operations;\x20has\x20better\x20performance\x20than\x20387,\x20but\x20only\x20available\x20on\x20Pentium\x204/Opteron/Athlon\x2064\x20or\x20later.
    • \x0a
    \x0a
  • \x0a\x0a
  • $GOARM\x20(for\x20arm\x20only;\x20default\x20is\x20auto-detected\x20if\x20building\x0aon\x20the\x20target\x20processor,\x206\x20if\x20not)\x0a

    \x0aThis\x20sets\x20the\x20ARM\x20floating\x20point\x20co-processor\x20architecture\x20version\x20the\x20run-time\x0ashould\x20target.\x20If\x20you\x20are\x20compiling\x20on\x20the\x20target\x20system,\x20its\x20value\x20will\x20be\x20auto-detected.\x0a

    \x0a
      \x0a\x09
    • GOARM=5:\x20use\x20software\x20floating\x20point;\x20when\x20CPU\x20doesn't\x20have\x20VFP\x20co-processor
    • \x0a\x09
    • GOARM=6:\x20use\x20VFPv1\x20only;\x20default\x20if\x20cross\x20compiling;\x20usually\x20ARM11\x20or\x20better\x20cores\x20(VFPv2\x20or\x20better\x20is\x20also\x20supported)
    • \x0a\x09
    • GOARM=7:\x20use\x20VFPv3;\x20usually\x20Cortex-A\x20cores
    • \x0a
    \x0a

    \x0aIf\x20in\x20doubt,\x20leave\x20this\x20variable\x20unset,\x20and\x20adjust\x20it\x20if\x20required\x0awhen\x20you\x20first\x20run\x20the\x20Go\x20executable.\x0aThe\x20GoARM\x20page\x0aon\x20the\x20Go\x20community\x20wiki\x0acontains\x20further\x20details\x20regarding\x20Go's\x20ARM\x20support.\x0a

    \x0a
  • \x0a\x0a
  • $GOMIPS\x20(for\x20mips\x20and\x20mipsle\x20only)\x20
    \x20$GOMIPS64\x20(for\x20mips64\x20and\x20mips64le\x20only)\x0a

    \x0a\x09These\x20variables\x20set\x20whether\x20to\x20use\x20floating\x20point\x20instructions.\x20Set\x20to\x20\"hardfloat\"\x20to\x20use\x20floating\x20point\x20instructions;\x20this\x20is\x20the\x20default.\x20\x20Set\x20to\x20\"softfloat\"\x20to\x20use\x20soft\x20floating\x20point.\x0a

    \x0a
  • \x0a\x0a
  • $GOPPC64\x20(for\x20ppc64\x20and\x20ppc64le\x20only)\x0a

    \x0aThis\x20variable\x20sets\x20the\x20processor\x20level\x20(i.e.\x20Instruction\x20Set\x20Architecture\x20version)\x0afor\x20which\x20the\x20compiler\x20will\x20target.\x20The\x20default\x20is\x20power8.\x0a

    \x0a
      \x0a\x09
    • GOPPC64=power8:\x20generate\x20ISA\x20v2.07\x20instructions
    • \x0a\x09
    • GOPPC64=power9:\x20generate\x20ISA\x20v3.00\x20instructions
    • \x0a
    \x0a
  • \x0a\x0a\x0a
  • $GOWASM\x20(for\x20wasm\x20only)\x0a\x09

    \x0a\x09This\x20variable\x20is\x20a\x20comma\x20separated\x20list\x20of\x20experimental\x20WebAssembly\x20features\x20that\x20the\x20compiled\x20WebAssembly\x20binary\x20is\x20allowed\x20to\x20use.\x0a\x09The\x20default\x20is\x20to\x20use\x20no\x20experimental\x20features.\x0a\x09

    \x0a\x09
      \x0a\x09\x09
    • GOWASM=satconv:\x20generate\x20saturating\x20(non-trapping)\x20float-to-int\x20conversions
    • \x0a\x09\x09
    • GOWASM=signext:\x20generate\x20sign-extension\x20operators
    • \x0a\x09
    \x0a
  • \x0a\x0a
\x0a\x0a

\x0aNote\x20that\x20$GOARCH\x20and\x20$GOOS\x20identify\x20the\x0atarget\x20environment,\x20not\x20the\x20environment\x20you\x20are\x20running\x20on.\x0aIn\x20effect,\x20you\x20are\x20always\x20cross-compiling.\x0aBy\x20architecture,\x20we\x20mean\x20the\x20kind\x20of\x20binaries\x0athat\x20the\x20target\x20environment\x20can\x20run:\x0aan\x20x86-64\x20system\x20running\x20a\x2032-bit-only\x20operating\x20system\x0amust\x20set\x20GOARCH\x20to\x20386,\x0anot\x20amd64.\x0a

\x0a\x0a

\x0aIf\x20you\x20choose\x20to\x20override\x20the\x20defaults,\x0aset\x20these\x20variables\x20in\x20your\x20shell\x20profile\x20($HOME/.bashrc,\x0a$HOME/.profile,\x20or\x20equivalent).\x20The\x20settings\x20might\x20look\x0asomething\x20like\x20this:\x0a

\x0a\x0a
\x0aexport\x20GOARCH=amd64\x0aexport\x20GOOS=linux\x0a
\x0a\x0a

\x0aalthough,\x20to\x20reiterate,\x20none\x20of\x20these\x20variables\x20needs\x20to\x20be\x20set\x20to\x20build,\x0ainstall,\x20and\x20develop\x20the\x20Go\x20tree.\x0a

\x0a", From 14e293d56b39ad8d14afbe344616b5bd8139117b Mon Sep 17 00:00:00 2001 From: kekaiwang Date: Tue, 24 Nov 2020 22:19:13 +0800 Subject: [PATCH 03/12] complete tutorial/getting-started page --- .../static/doc/tutorial/getting-started.html | 153 +++++++----------- content/static/static.go | 2 +- 2 files changed, 59 insertions(+), 96 deletions(-) diff --git a/content/static/doc/tutorial/getting-started.html b/content/static/doc/tutorial/getting-started.html index 0ae3a63419..9c71f69038 100644 --- a/content/static/doc/tutorial/getting-started.html +++ b/content/static/doc/tutorial/getting-started.html @@ -1,63 +1,56 @@

- In this tutorial, you'll get a brief introduction to Go programming. Along the - way, you will: + 在本教程中,你会简要了解 Go 编程。跟随教程,你将:

    -
  • Install Go (if you haven't already).
  • -
  • Write some simple "Hello, world" code.
  • -
  • Use the go command to run your code.
  • +
  • 安装 Go(如果你还没有安装)。
  • +
  • 编写简单的 “Hello, world" 代码。
  • +
  • 使用 go 命令执行你的代码。
  • - Use the Go package discovery tool to find packages you can use in your own - code. + 使用 Go 发现工具包去查找可以在你自己代码中使用的包。
  • -
  • Call functions of an external module.
  • +
  • 调用外部模块的功能。
-

Prerequisites

+

前提

  • - Some programming experience. The code here is pretty - simple, but it helps to know something about functions. + 一些编程经验。 这里的代码很简单,但有助于了解一些功能。
  • - A tool to edit your code. Any text editor you have will - work fine. Most text editors have good support for Go. The most popular are - VSCode (free), GoLand (paid), and Vim (free). + 一个编辑代码的工具。 任何文本编辑器都可以。大多数文本编辑器对 Go 都有很好的支持。最受欢迎的是 VSCode(免费)、GoLand(付费)和 Vim(免费)。
  • - A command terminal. Go works well using any terminal on - Linux and Mac, and on PowerShell or cmd in Windows. + 命令行终端。 Go可以在任何终端上正常运行,如 Linux 和 Mac ,以及在 PowerShell 或者 Windows 的 cmd。
-

Install Go

+

安装 Go

-

Just use the Download and install steps.

+

只需使用 下载和安装 步骤。

-

Write some code

+

写一些代码

- Get started with Hello, World. + 从 Hello, World 开始。

  1. - Open a command prompt and cd to your home directory. - + 打开命令行并 cd 到你的主目录。

    - On Linux or Mac: + 在 Linux 或 Mac 系统上:

    @@ -66,7 +59,7 @@ 

    Write some code

    >

    - On Windows: + 在 Windows 系统上:

    @@ -76,10 +69,9 @@ 

    Write some code

  2. - Create a hello directory for your first Go source code. - + 为你的第一个 Go 代码创建一个 hello 目录。

    - For example, use the following commands: + 例如:使用下面的命令

    @@ -90,12 +82,11 @@ 

    Write some code

  3. - In your text editor, create a file hello.go in which to write your code. + 在你的文本编辑器中,创建一个文件 hello.go 去编写你的代码。
  4. - Paste the following code into your hello.go file and save the file. - + 将以下代码粘贴到 hello.go 文件中,然后保存文件。
     package main
     
    @@ -108,32 +99,26 @@ 

    Write some code

    >

    - This is your Go code. In this code, you: + 这是你的 Go 代码,在这个代码中:

    • - Declare a main package (a package is a way to group - functions). + 声明一个 main 包(包是一种管理功能的方法)。
    • - Import the popular - fmt package, - which contains functions for formatting text, including printing to the - console. This package is one of the - standard library packages you got - when you installed Go. + 引用流行的 + fmt, + 其中包含格式化文本的功能,包含打印到控制台。这个包是一个 标准库包,在安装的 Go 的时候内置的。
    • - Implement a main function to print a message to the - console. A main function executes by default when you run - code in the file. + 实现 main 函数打印信息到控制台。 当执行你的代码时,main 函数是默认执行的。
  5. - Run your code to see the greeting. + 运行你的代码可以查看结果。
     $ go run hello.go
    @@ -142,12 +127,11 @@ 

    Write some code

    >

    - The + 这个 go run commandgo run 命令 - is one of many go commands you'll use to get things done with - Go. Use the following command to get a list of the others: + 是许多用于使用 Go 完成操作的 go 命令之一。使用下面的命令获取其他的列表:

    @@ -157,57 +141,45 @@ 

    Write some code

-

Call code in an external package

+

使用外部包的代码

- When you need your code to do something that might have been implemented by - someone else, you can look for a package that has functions you can use in - your code. + 当你当代码需要引用其他代码的时候,你可以查找其他包中包含你想要的功能。

  1. - Make your printed message a little more interesting with a function from an - external module. - + 通过使用其他模块中的功能使你的打印信息更加有趣。
    1. - Visit pkg.go.dev and + 访问 pkg.go.dev 并且 search for a "quote" package查找 "quote" 包.
    2. - Locate and click the rsc.io/quote package in search results - (if you see rsc.io/quote/v3, ignore it for now). + 在搜索结果中找到并点击 rsc.io/quote 包( + 当你看到 rsc.io/quote/v3 包时请暂时忽略)。、
    3. - On the Doc tab, under Index, note the - list of functions you can call from your code. You'll use the - Go function. + 在 文档 标签,索引里面,注意列表里面是你可以调用的功能。你可以使用 Go 函数。
    4. - At the top of this page, note that package quote is - included in the rsc.io/quote module. + 在页面的顶部,注意 quote 包是包含在 rsc.io/quote 模块中的。

    - You can use the pkg.go.dev site to find published modules whose packages - have functions you can use in your own code. Packages are published in - modules -- like rsc.io/quote -- where others can use them. - Modules are improved with new versions over time, and you can upgrade your - code to use the improved versions. + 你可以使用 pkg.go.dev 网站去查找已发布的模块,你可以在你的代码里面使用它。包发布在模块中 -- 就像 + rsc.io/quote -- 其他人可以使用它门。随着新版本对模块的改进,你可以升级代码去使用改进的版本。

  2. - In your Go code, import the rsc.io/quote package and add a call - to its Go function. + 在你的代码里面,引用 rsc.io/quote 包并调用它的 Go 函数。

    - After adding the highlighted lines, your code should include the - following: + 添加下面高亮的行后,你的代码需要包含以下内容:

    @@ -224,21 +196,18 @@ 

    Call code in an external package

  3. - Put your own code in a module for tracking dependencies. + 将你的代码放在模块中去跟踪依赖关系。

    - When your code imports packages from another module, a go.mod file lists - the specific modules and versions providing those packages. That file - stays with your code, including in your source code repository. + 当你的代码从另一个模块中引入包时,go.mod 文件会列出这些模块和使用的版本。这些文件在你的代码里面,在你的源代码里面。

    - To create a go.mod file, run the + 创建一个 go.mod 文件,并执行 go mod init command, giving it the name of the module your code will be in (here, just use - "hello"): + >go mod init 命令, 给它提供代码所在模块的里面(这里,只需要使用 "hello"):

    @@ -249,8 +218,7 @@ 

    Call code in an external package

  4. - Run your code to see the message generated by the function you're calling. - + 执行你的代码查看信息你调用的函数产生的消息。
     $ go run hello.go
     go: finding module for package rsc.io/quote
    @@ -260,23 +228,18 @@ 

    Call code in an external package

    >

    - Notice that your code calls the Go function, printing a - clever message about communication. + 注意,你的代码调用了 Go 的函数,打印出了关于执行的明确信息。

    - But before it ran the code, go run located and downloaded the - rsc.io/quote module that contains the package you imported. - By default, it downloaded the latest version -- v1.5.2. Go build commands - are designed to locate the modules required for packages you import. + 但在执行代码之前, go run 先查找并下载 rsc.io/quote 模块中包含你要引用的包。 + 默认情况下,它会下载最新的版本 -- v1.5.2。Go 构建命令会查找你引用包的指定模块。

-

Write more code

+

写更多代码

- With this quick introduction, you got Go installed and learned some of the - basics. To write some more code with another tutorial, take a look at - Create a Go module. + 通过这个快速入门,你已经安装并且学习了一些基础知识。在其他教程中编写更多代码,请查看创建一个 Go 模块.

diff --git a/content/static/static.go b/content/static/static.go index 20408f39f6..09212659d9 100644 --- a/content/static/static.go +++ b/content/static/static.go @@ -97,7 +97,7 @@ var Files = map[string]string{ "doc/tutorial/create-module.html": "\x0a\x0a

\x0a\x20\x20This\x20is\x20the\x20first\x20part\x20of\x20a\x20tutorial\x20that\x20introduces\x20a\x20few\x20fundamental\x0a\x20\x20features\x20of\x20the\x20Go\x20language.\x20If\x20you're\x20just\x20getting\x20started\x20with\x20Go,\x20be\x20sure\x0a\x20\x20to\x20take\x20a\x20look\x20at\x20the\x0a\x20\x20getting\x20started\x20tutorial,\x20which\x20introduces\x0a\x20\x20the\x20go\x20command,\x20Go\x20modules,\x20and\x20very\x20simple\x20Go\x20code.\x0a

\x0a\x0a

\x0a\x20\x20In\x20this\x20tutorial\x20you'll\x20create\x20two\x20modules.\x20The\x20first\x20is\x20a\x20library\x20which\x20is\x0a\x20\x20intended\x20to\x20be\x20imported\x20by\x20other\x20libraries\x20or\x20applications.\x20The\x20second\x20is\x20a\x0a\x20\x20caller\x20application\x20which\x20will\x20use\x20the\x20first.\x0a

\x0a\x0a

\x0a\x20\x20This\x20tutorial's\x20sequence\x20includes\x20six\x20brief\x20topics\x20that\x20each\x20illustrate\x20a\x0a\x20\x20different\x20part\x20of\x20the\x20language.\x0a

\x0a\x0a
    \x0a\x20\x20
  1. \x0a\x20\x20\x20\x20Create\x20a\x20module\x20--\x20Write\x20a\x20small\x20module\x20with\x20functions\x20you\x20can\x20call\x20from\x0a\x20\x20\x20\x20another\x20module.\x0a\x20\x20
  2. \x0a\x20\x20
  3. \x0a\x20\x20\x20\x20Call\x20your\x20code\x20from\x20another\x20module\x20--\x0a\x20\x20\x20\x20Import\x20and\x20use\x20your\x20new\x20module.\x0a\x20\x20
  4. \x0a\x20\x20
  5. \x0a\x20\x20\x20\x20Return\x20and\x20handle\x20an\x20error\x20--\x20Add\x20simple\x0a\x20\x20\x20\x20error\x20handling.\x0a\x20\x20
  6. \x0a\x20\x20
  7. \x0a\x20\x20\x20\x20Return\x20a\x20random\x20greeting\x20--\x20Handle\x20data\x0a\x20\x20\x20\x20in\x20slices\x20(Go's\x20dynamically-sized\x20arrays).\x0a\x20\x20
  8. \x0a\x20\x20
  9. \x0a\x20\x20\x20\x20Return\x20greetings\x20for\x20multiple\x20people\x0a\x20\x20\x20\x20--\x20Store\x20key/value\x20pairs\x20in\x20a\x20map.\x0a\x20\x20
  10. \x0a\x20\x20
  11. \x0a\x20\x20\x20\x20Add\x20a\x20test\x20--\x20Use\x20Go's\x20built-in\x20unit\x20testing\x0a\x20\x20\x20\x20features\x20to\x20test\x20your\x20code.\x0a\x20\x20
  12. \x0a\x20\x20
  13. \x0a\x20\x20\x20\x20Compile\x20and\x20install\x20the\x20application\x20--\x0a\x20\x20\x20\x20Compile\x20and\x20install\x20your\x20code\x20locally.\x0a\x20\x20
  14. \x0a
\x0a\x0a\x0a\x20\x20Note:\x20For\x20other\x20tutorials,\x20see\x0a\x20\x20Tutorials.\x0a\x0a\x0aPrerequisites\x0a\x0a
    \x0a\x20\x20
  • \x0a\x20\x20\x20\x20Some\x20programming\x20experience.\x20The\x20code\x20here\x20is\x20pretty\x0a\x20\x20\x20\x20simple,\x20but\x20it\x20helps\x20to\x20know\x20something\x20about\x20functions,\x20loops,\x20and\x20arrays.\x0a\x20\x20
  • \x0a\x20\x20
  • \x0a\x20\x20\x20\x20A\x20tool\x20to\x20edit\x20your\x20code.\x20Any\x20text\x20editor\x20you\x20have\x20will\x0a\x20\x20\x20\x20work\x20fine.\x20Most\x20text\x20editors\x20have\x20good\x20support\x20for\x20Go.\x20The\x20most\x20popular\x20are\x0a\x20\x20\x20\x20VSCode\x20(free),\x20GoLand\x20(paid),\x20and\x20Vim\x20(free).\x0a\x20\x20
  • \x0a\x20\x20
  • \x0a\x20\x20\x20\x20A\x20command\x20terminal.\x20Go\x20works\x20well\x20using\x20any\x20terminal\x20on\x0a\x20\x20\x20\x20Linux\x20and\x20Mac,\x20and\x20on\x20PowerShell\x20or\x20cmd\x20in\x20Windows.\x0a\x20\x20
  • \x0a
\x0a\x0aStart\x20a\x20module\x20that\x20others\x20can\x20use\x0a\x0a

\x0a\x20\x20Start\x20by\x20creating\x20a\x0a\x20\x20Go\x20module.\x20In\x20a\x0a\x20\x20module,\x20you\x20collect\x20one\x20or\x20more\x20related\x20packages\x20for\x20a\x20discrete\x20and\x20useful\x20set\x0a\x20\x20of\x20functions.\x20For\x20example,\x20you\x20might\x20create\x20a\x20module\x20with\x20packages\x20that\x20have\x0a\x20\x20functions\x20for\x20doing\x20financial\x20analysis\x20so\x20that\x20others\x20writing\x20financial\x0a\x20\x20applications\x20can\x20use\x20your\x20work.\x0a

\x0a\x0a

\x0a\x20\x20Go\x20code\x20is\x20grouped\x20into\x20packages,\x20and\x20packages\x20are\x20grouped\x20into\x20modules.\x20Your\x0a\x20\x20package's\x20module\x20specifies\x20the\x20context\x20Go\x20needs\x20to\x20run\x20the\x20code,\x20including\x20the\x0a\x20\x20Go\x20version\x20the\x20code\x20is\x20written\x20for\x20and\x20the\x20set\x20of\x20other\x20modules\x20it\x20requires.\x0a

\x0a\x0a

\x0a\x20\x20As\x20you\x20add\x20or\x20improve\x20functionality\x20in\x20your\x20module,\x20you\x20publish\x20new\x20versions\x0a\x20\x20of\x20the\x20module.\x20Developers\x20writing\x20code\x20that\x20calls\x20functions\x20in\x20your\x20module\x20can\x0a\x20\x20import\x20the\x20module's\x20updated\x20packages\x20and\x20test\x20with\x20the\x20new\x20version\x20before\x0a\x20\x20putting\x20it\x20into\x20production\x20use.\x0a

\x0a\x0a
    \x0a\x20\x20
  1. \x0a\x20\x20\x20\x20Open\x20a\x20command\x20prompt\x20and\x20cd\x20to\x20your\x20home\x20directory.\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20On\x20Linux\x20or\x20Mac:\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0acd\x0a\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20On\x20Windows:\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0acd\x20%HOMEPATH%\x0a\x0a\x20\x20
  2. \x0a\x0a\x20\x20
  3. \x0a\x20\x20\x20\x20Create\x20a\x20greetings\x20directory\x20for\x20your\x20Go\x20module\x20source\x20code.\x0a\x20\x20\x20\x20This\x20is\x20where\x20you'll\x20write\x20your\x20module\x20code.\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20For\x20example,\x20from\x20your\x20home\x20directory\x20use\x20the\x20following\x20commands:\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0amkdir\x20greetings\x0acd\x20greetings\x0a\x0a\x20\x20
  4. \x0a\x0a\x20\x20
  5. \x0a\x20\x20\x20\x20Start\x20your\x20module\x20using\x20the\x0a\x20\x20\x20\x20go\x20mod\x20init\x20command\x0a\x20\x20\x20\x20to\x20create\x20a\x20go.mod\x20file.\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20Run\x20the\x20go\x20mod\x20init\x20command,\x20giving\x20it\x20the\x20path\x20of\x20the\x20module\x0a\x20\x20\x20\x20\x20\x20your\x20code\x20will\x20be\x20in.\x20Here,\x20use\x20example.com/greetings\x20for\x20the\x0a\x20\x20\x20\x20\x20\x20module\x20path\x20--\x20in\x20production\x20code,\x20this\x20would\x20be\x20the\x20URL\x20from\x20which\x20your\x0a\x20\x20\x20\x20\x20\x20module\x20can\x20be\x20downloaded.\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0a$\x20go\x20mod\x20init\x20example.com/greetings\x0ago:\x20creating\x20new\x20go.mod:\x20module\x20example.com/greetings\x0a\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20The\x20go\x20mod\x20init\x20command\x20creates\x20a\x20go.mod\x20file\x20that\x20identifies\x0a\x20\x20\x20\x20\x20\x20your\x20code\x20as\x20a\x20module\x20that\x20might\x20be\x20used\x20from\x20other\x20code.\x20The\x20file\x20you\x0a\x20\x20\x20\x20\x20\x20just\x20created\x20includes\x20only\x20the\x20name\x20of\x20your\x20module\x20and\x20the\x20Go\x20version\x20your\x0a\x20\x20\x20\x20\x20\x20code\x20supports.\x20But\x20as\x20you\x20add\x20dependencies\x20--\x20meaning\x20packages\x20from\x20other\x0a\x20\x20\x20\x20\x20\x20modules\x20--\x20the\x20go.mod\x20file\x20will\x20list\x20the\x20specific\x20module\x20versions\x20to\x20use.\x0a\x20\x20\x20\x20\x20\x20This\x20keeps\x20builds\x20reproducible\x20and\x20gives\x20you\x20direct\x20control\x20over\x20which\x0a\x20\x20\x20\x20\x20\x20module\x20versions\x20to\x20use.\x0a\x20\x20\x20\x20

    \x0a\x20\x20
  6. \x0a\x0a\x20\x20
  7. \x0a\x20\x20\x20\x20In\x20your\x20text\x20editor,\x20create\x20a\x20file\x20in\x20which\x20to\x20write\x20your\x20code\x20and\x20call\x20it\x0a\x20\x20\x20\x20greetings.go.\x0a\x20\x20
  8. \x0a\x0a\x20\x20
  9. \x0a\x20\x20\x20\x20Paste\x20the\x20following\x20code\x20into\x20your\x20greetings.go\x20file\x20and\x20save\x20the\x20file.\x0a\x0a\x20\x20\x20\x20
    \x0apackage\x20greetings\x0a\x0aimport\x20\"fmt\"\x0a\x0a//\x20Hello\x20returns\x20a\x20greeting\x20for\x20the\x20named\x20person.\x0afunc\x20Hello(name\x20string)\x20string\x20{\x0a\x20\x20\x20\x20//\x20Return\x20a\x20greeting\x20that\x20embeds\x20the\x20name\x20in\x20a\x20message.\x0a\x20\x20\x20\x20message\x20:=\x20fmt.Sprintf(\"Hi,\x20%v.\x20Welcome!\",\x20name)\x0a\x20\x20\x20\x20return\x20message\x0a}\x0a\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20This\x20is\x20the\x20first\x20code\x20for\x20your\x20module.\x20It\x20returns\x20a\x20greeting\x20to\x20any\x0a\x20\x20\x20\x20\x20\x20caller\x20that\x20asks\x20for\x20one.\x20You'll\x20write\x20code\x20that\x20calls\x20this\x20function\x20in\x0a\x20\x20\x20\x20\x20\x20the\x20next\x20step.\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20In\x20this\x20code,\x20you:\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
      \x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20\x20\x20Declare\x20a\x20greetings\x20package\x20to\x20collect\x20related\x20functions.\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20\x20\x20Implement\x20a\x20Hello\x20function\x20to\x20return\x20the\x20greeting.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

      \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20This\x20function\x20takes\x20a\x20name\x20parameter\x20whose\x20type\x20is\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20string,\x20and\x20returns\x20a\x20string.\x20In\x20Go,\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20function\x20whose\x20name\x20starts\x20with\x20a\x20capital\x20letter\x20can\x20be\x20called\x20by\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20function\x20not\x20in\x20the\x20same\x20package.\x20This\x20is\x20known\x20in\x20Go\x20as\x20an\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20exported\x20name.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

      \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20\x20\x20Declare\x20a\x20message\x20variable\x20to\x20hold\x20your\x20greeting.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

      \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20In\x20Go,\x20the\x20:=\x20operator\x20is\x20a\x20shortcut\x20for\x20declaring\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20initializing\x20a\x20variable\x20in\x20one\x20line\x20(Go\x20uses\x20the\x20value\x20on\x20the\x20right\x20to\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20determine\x20the\x20variable's\x20type).\x20Taking\x20the\x20long\x20way,\x20you\x20might\x20have\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20written\x20this\x20as:\x0a\x20\x20\x20\x20\x20\x20\x20\x20

      \x0a\x20\x20\x20\x20\x20\x20\x20\x20
      \x0avar\x20message\x20string\x0amessage\x20=\x20fmt.Sprintf(\"Hi,\x20%v.\x20Welcome!\",\x20name)\x0a\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20\x20\x20Use\x20the\x20fmt\x20package's\x20Sprintf\x20function\x20to\x0a\x20\x20\x20\x20\x20\x20\x20\x20create\x20a\x20greeting\x20message.\x20The\x20first\x20argument\x20is\x20a\x20format\x20string,\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20Sprintf\x20substitutes\x20the\x20name\x20parameter's\x20value\x0a\x20\x20\x20\x20\x20\x20\x20\x20for\x20the\x20%v\x20format\x20verb.\x20Inserting\x20the\x20value\x20of\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20name\x20parameter\x20completes\x20the\x20greeting\x20text.\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20
    • Return\x20the\x20formatted\x20greeting\x20text\x20to\x20the\x20caller.
    • \x0a\x20\x20\x20\x20
    \x0a\x20\x20
  10. \x0a
\x0a\x0a

\x0a\x20\x20In\x20the\x20next\x20step,\x20you'll\x20call\x20this\x0a\x20\x20function\x20from\x20another\x20module.\x0a

\x0a\x0a\x0a\x20\x20Call\x20your\x20code\x20from\x20another\x20module\x20>\x0a

\x0a", - "doc/tutorial/getting-started.html": "\x0a\x0a

\x0a\x20\x20In\x20this\x20tutorial,\x20you'll\x20get\x20a\x20brief\x20introduction\x20to\x20Go\x20programming.\x20Along\x20the\x0a\x20\x20way,\x20you\x20will:\x0a

\x0a\x0a
    \x0a\x20\x20
  • Install\x20Go\x20(if\x20you\x20haven't\x20already).
  • \x0a\x20\x20
  • Write\x20some\x20simple\x20\"Hello,\x20world\"\x20code.
  • \x0a\x20\x20
  • Use\x20the\x20go\x20command\x20to\x20run\x20your\x20code.
  • \x0a\x20\x20
  • \x0a\x20\x20\x20\x20Use\x20the\x20Go\x20package\x20discovery\x20tool\x20to\x20find\x20packages\x20you\x20can\x20use\x20in\x20your\x20own\x0a\x20\x20\x20\x20code.\x0a\x20\x20
  • \x0a\x20\x20
  • Call\x20functions\x20of\x20an\x20external\x20module.
  • \x0a
\x0a\x0a\x0a\x20\x20Note:\x20For\x20other\x20tutorials,\x20see\x0a\x20\x20Tutorials.\x0a\x0a\x0aPrerequisites\x0a\x0a
    \x0a\x20\x20
  • \x0a\x20\x20\x20\x20Some\x20programming\x20experience.\x20The\x20code\x20here\x20is\x20pretty\x0a\x20\x20\x20\x20simple,\x20but\x20it\x20helps\x20to\x20know\x20something\x20about\x20functions.\x0a\x20\x20
  • \x0a\x20\x20
  • \x0a\x20\x20\x20\x20A\x20tool\x20to\x20edit\x20your\x20code.\x20Any\x20text\x20editor\x20you\x20have\x20will\x0a\x20\x20\x20\x20work\x20fine.\x20Most\x20text\x20editors\x20have\x20good\x20support\x20for\x20Go.\x20The\x20most\x20popular\x20are\x0a\x20\x20\x20\x20VSCode\x20(free),\x20GoLand\x20(paid),\x20and\x20Vim\x20(free).\x0a\x20\x20
  • \x0a\x20\x20
  • \x0a\x20\x20\x20\x20A\x20command\x20terminal.\x20Go\x20works\x20well\x20using\x20any\x20terminal\x20on\x0a\x20\x20\x20\x20Linux\x20and\x20Mac,\x20and\x20on\x20PowerShell\x20or\x20cmd\x20in\x20Windows.\x0a\x20\x20
  • \x0a
\x0a\x0aInstall\x20Go\x0a\x0a

Just\x20use\x20the\x20Download\x20and\x20install\x20steps.

\x0a\x0aWrite\x20some\x20code\x0a\x0a

\x0a\x20\x20Get\x20started\x20with\x20Hello,\x20World.\x0a

\x0a\x0a
    \x0a\x20\x20
  1. \x0a\x20\x20\x20\x20Open\x20a\x20command\x20prompt\x20and\x20cd\x20to\x20your\x20home\x20directory.\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20On\x20Linux\x20or\x20Mac:\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0acd\x0a\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20On\x20Windows:\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0acd\x20%HOMEPATH%\x0a\x0a\x20\x20
  2. \x0a\x0a\x20\x20
  3. \x0a\x20\x20\x20\x20Create\x20a\x20hello\x20directory\x20for\x20your\x20first\x20Go\x20source\x20code.\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20For\x20example,\x20use\x20the\x20following\x20commands:\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0amkdir\x20hello\x0acd\x20hello\x0a\x0a\x20\x20
  4. \x0a\x0a\x20\x20
  5. \x0a\x20\x20\x20\x20In\x20your\x20text\x20editor,\x20create\x20a\x20file\x20hello.go\x20in\x20which\x20to\x20write\x20your\x20code.\x0a\x20\x20
  6. \x0a\x0a\x20\x20
  7. \x0a\x20\x20\x20\x20Paste\x20the\x20following\x20code\x20into\x20your\x20hello.go\x20file\x20and\x20save\x20the\x20file.\x0a\x0a\x20\x20\x20\x20
    \x0apackage\x20main\x0a\x0aimport\x20\"fmt\"\x0a\x0afunc\x20main()\x20{\x0a\x20\x20\x20\x20fmt.Println(\"Hello,\x20World!\")\x0a}\x0a\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20This\x20is\x20your\x20Go\x20code.\x20In\x20this\x20code,\x20you:\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
      \x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20\x20\x20Declare\x20a\x20main\x20package\x20(a\x20package\x20is\x20a\x20way\x20to\x20group\x0a\x20\x20\x20\x20\x20\x20\x20\x20functions).\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20\x20\x20Import\x20the\x20popular\x0a\x20\x20\x20\x20\x20\x20\x20\x20fmt\x20package,\x0a\x20\x20\x20\x20\x20\x20\x20\x20which\x20contains\x20functions\x20for\x20formatting\x20text,\x20including\x20printing\x20to\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20console.\x20This\x20package\x20is\x20one\x20of\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20standard\x20library\x20packages\x20you\x20got\x0a\x20\x20\x20\x20\x20\x20\x20\x20when\x20you\x20installed\x20Go.\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20\x20\x20Implement\x20a\x20main\x20function\x20to\x20print\x20a\x20message\x20to\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20console.\x20A\x20main\x20function\x20executes\x20by\x20default\x20when\x20you\x20run\x0a\x20\x20\x20\x20\x20\x20\x20\x20code\x20in\x20the\x20file.\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20
    \x0a\x20\x20
  8. \x0a\x0a\x20\x20
  9. \x0a\x20\x20\x20\x20Run\x20your\x20code\x20to\x20see\x20the\x20greeting.\x0a\x0a\x20\x20\x20\x20
    \x0a$\x20go\x20run\x20hello.go\x0aHello,\x20World!\x0a\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20The\x0a\x20\x20\x20\x20\x20\x20go\x20run\x20command\x0a\x20\x20\x20\x20\x20\x20is\x20one\x20of\x20many\x20go\x20commands\x20you'll\x20use\x20to\x20get\x20things\x20done\x20with\x0a\x20\x20\x20\x20\x20\x20Go.\x20Use\x20the\x20following\x20command\x20to\x20get\x20a\x20list\x20of\x20the\x20others:\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0a$\x20go\x20help\x0a\x0a\x20\x20
  10. \x0a
\x0a\x0aCall\x20code\x20in\x20an\x20external\x20package\x0a\x0a

\x0a\x20\x20When\x20you\x20need\x20your\x20code\x20to\x20do\x20something\x20that\x20might\x20have\x20been\x20implemented\x20by\x0a\x20\x20someone\x20else,\x20you\x20can\x20look\x20for\x20a\x20package\x20that\x20has\x20functions\x20you\x20can\x20use\x20in\x0a\x20\x20your\x20code.\x0a

\x0a\x0a
    \x0a\x20\x20
  1. \x0a\x20\x20\x20\x20Make\x20your\x20printed\x20message\x20a\x20little\x20more\x20interesting\x20with\x20a\x20function\x20from\x20an\x0a\x20\x20\x20\x20external\x20module.\x0a\x0a\x20\x20\x20\x20
      \x0a\x20\x20\x20\x20\x20\x20
    1. \x0a\x20\x20\x20\x20\x20\x20\x20\x20Visit\x20pkg.go.dev\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20search\x20for\x20a\x20\"quote\"\x20package.\x0a\x20\x20\x20\x20\x20\x20
    2. \x0a\x20\x20\x20\x20\x20\x20
    3. \x0a\x20\x20\x20\x20\x20\x20\x20\x20Locate\x20and\x20click\x20the\x20rsc.io/quote\x20package\x20in\x20search\x20results\x0a\x20\x20\x20\x20\x20\x20\x20\x20(if\x20you\x20see\x20rsc.io/quote/v3,\x20ignore\x20it\x20for\x20now).\x0a\x20\x20\x20\x20\x20\x20
    4. \x0a\x20\x20\x20\x20\x20\x20
    5. \x0a\x20\x20\x20\x20\x20\x20\x20\x20On\x20the\x20Doc\x20tab,\x20under\x20Index,\x20note\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20list\x20of\x20functions\x20you\x20can\x20call\x20from\x20your\x20code.\x20You'll\x20use\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20Go\x20function.\x0a\x20\x20\x20\x20\x20\x20
    6. \x0a\x20\x20\x20\x20\x20\x20
    7. \x0a\x20\x20\x20\x20\x20\x20\x20\x20At\x20the\x20top\x20of\x20this\x20page,\x20note\x20that\x20package\x20quote\x20is\x0a\x20\x20\x20\x20\x20\x20\x20\x20included\x20in\x20the\x20rsc.io/quote\x20module.\x0a\x20\x20\x20\x20\x20\x20
    8. \x0a\x20\x20\x20\x20
    \x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20You\x20can\x20use\x20the\x20pkg.go.dev\x20site\x20to\x20find\x20published\x20modules\x20whose\x20packages\x0a\x20\x20\x20\x20\x20\x20have\x20functions\x20you\x20can\x20use\x20in\x20your\x20own\x20code.\x20Packages\x20are\x20published\x20in\x0a\x20\x20\x20\x20\x20\x20modules\x20--\x20like\x20rsc.io/quote\x20--\x20where\x20others\x20can\x20use\x20them.\x0a\x20\x20\x20\x20\x20\x20Modules\x20are\x20improved\x20with\x20new\x20versions\x20over\x20time,\x20and\x20you\x20can\x20upgrade\x20your\x0a\x20\x20\x20\x20\x20\x20code\x20to\x20use\x20the\x20improved\x20versions.\x0a\x20\x20\x20\x20

    \x0a\x20\x20
  2. \x0a\x0a\x20\x20
  3. \x0a\x20\x20\x20\x20In\x20your\x20Go\x20code,\x20import\x20the\x20rsc.io/quote\x20package\x20and\x20add\x20a\x20call\x0a\x20\x20\x20\x20to\x20its\x20Go\x20function.\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20After\x20adding\x20the\x20highlighted\x20lines,\x20your\x20code\x20should\x20include\x20the\x0a\x20\x20\x20\x20\x20\x20following:\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0apackage\x20main\x0a\x0aimport\x20\"fmt\"\x0a\x0aimport\x20\"rsc.io/quote\"\x0a\x0afunc\x20main()\x20{\x0a\x20\x20\x20\x20fmt.Println(quote.Go())\x0a}\x0a
    \x0a\x20\x20
  4. \x0a\x0a\x20\x20
  5. \x0a\x20\x20\x20\x20Put\x20your\x20own\x20code\x20in\x20a\x20module\x20for\x20tracking\x20dependencies.\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20When\x20your\x20code\x20imports\x20packages\x20from\x20another\x20module,\x20a\x20go.mod\x20file\x20lists\x0a\x20\x20\x20\x20\x20\x20the\x20specific\x20modules\x20and\x20versions\x20providing\x20those\x20packages.\x20That\x20file\x0a\x20\x20\x20\x20\x20\x20stays\x20with\x20your\x20code,\x20including\x20in\x20your\x20source\x20code\x20repository.\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20To\x20create\x20a\x20go.mod\x20file,\x20run\x20the\x0a\x20\x20\x20\x20\x20\x20go\x20mod\x20init\x20command,\x20giving\x20it\x20the\x20name\x20of\x20the\x20module\x20your\x20code\x20will\x20be\x20in\x20(here,\x20just\x20use\x0a\x20\x20\x20\x20\x20\x20\"hello\"):\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0a$\x20go\x20mod\x20init\x20hello\x0ago:\x20creating\x20new\x20go.mod:\x20module\x20hello\x0a\x0a\x20\x20
  6. \x0a\x0a\x20\x20
  7. \x0a\x20\x20\x20\x20Run\x20your\x20code\x20to\x20see\x20the\x20message\x20generated\x20by\x20the\x20function\x20you're\x20calling.\x0a\x0a\x20\x20\x20\x20
    \x0a$\x20go\x20run\x20hello.go\x0ago:\x20finding\x20module\x20for\x20package\x20rsc.io/quote\x0ago:\x20found\x20rsc.io/quote\x20in\x20rsc.io/quote\x20v1.5.2\x0aDon't\x20communicate\x20by\x20sharing\x20memory,\x20share\x20memory\x20by\x20communicating.\x0a\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20Notice\x20that\x20your\x20code\x20calls\x20the\x20Go\x20function,\x20printing\x20a\x0a\x20\x20\x20\x20\x20\x20clever\x20message\x20about\x20communication.\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20But\x20before\x20it\x20ran\x20the\x20code,\x20go\x20run\x20located\x20and\x20downloaded\x20the\x0a\x20\x20\x20\x20\x20\x20rsc.io/quote\x20module\x20that\x20contains\x20the\x20package\x20you\x20imported.\x0a\x20\x20\x20\x20\x20\x20By\x20default,\x20it\x20downloaded\x20the\x20latest\x20version\x20--\x20v1.5.2.\x20Go\x20build\x20commands\x0a\x20\x20\x20\x20\x20\x20are\x20designed\x20to\x20locate\x20the\x20modules\x20required\x20for\x20packages\x20you\x20import.\x0a\x20\x20\x20\x20

    \x0a\x20\x20
  8. \x0a
\x0a\x0aWrite\x20more\x20code\x0a\x0a

\x0a\x20\x20With\x20this\x20quick\x20introduction,\x20you\x20got\x20Go\x20installed\x20and\x20learned\x20some\x20of\x20the\x0a\x20\x20basics.\x20To\x20write\x20some\x20more\x20code\x20with\x20another\x20tutorial,\x20take\x20a\x20look\x20at\x0a\x20\x20Create\x20a\x20Go\x20module.\x0a

\x0a", + "doc/tutorial/getting-started.html": "\x0a\x0a

\x0a\x20\x20\xe5\x9c\xa8\xe6\x9c\xac\xe6\x95\x99\xe7\xa8\x8b\xe4\xb8\xad\xef\xbc\x8c\xe4\xbd\xa0\xe4\xbc\x9a\xe7\xae\x80\xe8\xa6\x81\xe4\xba\x86\xe8\xa7\xa3\x20Go\x20\xe7\xbc\x96\xe7\xa8\x8b\xe3\x80\x82\xe8\xb7\x9f\xe9\x9a\x8f\xe6\x95\x99\xe7\xa8\x8b\xef\xbc\x8c\xe4\xbd\xa0\xe5\xb0\x86\xef\xbc\x9a\x0a

\x0a\x0a
    \x0a\x20\x20
  • \xe5\xae\x89\xe8\xa3\x85\x20Go\xef\xbc\x88\xe5\xa6\x82\xe6\x9e\x9c\xe4\xbd\xa0\xe8\xbf\x98\xe6\xb2\xa1\xe6\x9c\x89\xe5\xae\x89\xe8\xa3\x85\xef\xbc\x89\xe3\x80\x82
  • \x0a\x20\x20
  • \xe7\xbc\x96\xe5\x86\x99\xe7\xae\x80\xe5\x8d\x95\xe7\x9a\x84\x20\xe2\x80\x9cHello,\x20world\"\x20\xe4\xbb\xa3\xe7\xa0\x81\xe3\x80\x82
  • \x0a\x20\x20
  • \xe4\xbd\xbf\xe7\x94\xa8\x20go\x20\xe5\x91\xbd\xe4\xbb\xa4\xe6\x89\xa7\xe8\xa1\x8c\xe4\xbd\xa0\xe7\x9a\x84\xe4\xbb\xa3\xe7\xa0\x81\xe3\x80\x82
  • \x0a\x20\x20
  • \x0a\x20\x20\x20\x20\xe4\xbd\xbf\xe7\x94\xa8\x20Go\x20\xe5\x8f\x91\xe7\x8e\xb0\xe5\xb7\xa5\xe5\x85\xb7\xe5\x8c\x85\xe5\x8e\xbb\xe6\x9f\xa5\xe6\x89\xbe\xe5\x8f\xaf\xe4\xbb\xa5\xe5\x9c\xa8\xe4\xbd\xa0\xe8\x87\xaa\xe5\xb7\xb1\xe4\xbb\xa3\xe7\xa0\x81\xe4\xb8\xad\xe4\xbd\xbf\xe7\x94\xa8\xe7\x9a\x84\xe5\x8c\x85\xe3\x80\x82\x0a\x20\x20
  • \x0a\x20\x20
  • \xe8\xb0\x83\xe7\x94\xa8\xe5\xa4\x96\xe9\x83\xa8\xe6\xa8\xa1\xe5\x9d\x97\xe7\x9a\x84\xe5\x8a\x9f\xe8\x83\xbd\xe3\x80\x82
  • \x0a
\x0a\x0a\x0a\x20\x20\xe6\x8f\x90\xe7\xa4\xba:\x20\xe5\x85\xb6\xe4\xbb\x96\xe6\x95\x99\xe7\xa8\x8b,\x20\xe6\x9f\xa5\xe7\x9c\x8b\x0a\x20\x20\xe6\x95\x99\xe7\xa8\x8b.\x0a\x0a\x0a\xe5\x89\x8d\xe6\x8f\x90\x0a\x0a
    \x0a\x20\x20
  • \x0a\x20\x20\x20\x20\xe4\xb8\x80\xe4\xba\x9b\xe7\xbc\x96\xe7\xa8\x8b\xe7\xbb\x8f\xe9\xaa\x8c\xe3\x80\x82\x20\xe8\xbf\x99\xe9\x87\x8c\xe7\x9a\x84\xe4\xbb\xa3\xe7\xa0\x81\xe5\xbe\x88\xe7\xae\x80\xe5\x8d\x95\xef\xbc\x8c\xe4\xbd\x86\xe6\x9c\x89\xe5\x8a\xa9\xe4\xba\x8e\xe4\xba\x86\xe8\xa7\xa3\xe4\xb8\x80\xe4\xba\x9b\xe5\x8a\x9f\xe8\x83\xbd\xe3\x80\x82\x0a\x20\x20
  • \x0a\x20\x20
  • \x0a\x20\x20\x20\x20\xe4\xb8\x80\xe4\xb8\xaa\xe7\xbc\x96\xe8\xbe\x91\xe4\xbb\xa3\xe7\xa0\x81\xe7\x9a\x84\xe5\xb7\xa5\xe5\x85\xb7\xe3\x80\x82\x20\xe4\xbb\xbb\xe4\xbd\x95\xe6\x96\x87\xe6\x9c\xac\xe7\xbc\x96\xe8\xbe\x91\xe5\x99\xa8\xe9\x83\xbd\xe5\x8f\xaf\xe4\xbb\xa5\xe3\x80\x82\xe5\xa4\xa7\xe5\xa4\x9a\xe6\x95\xb0\xe6\x96\x87\xe6\x9c\xac\xe7\xbc\x96\xe8\xbe\x91\xe5\x99\xa8\xe5\xaf\xb9\x20Go\x20\xe9\x83\xbd\xe6\x9c\x89\xe5\xbe\x88\xe5\xa5\xbd\xe7\x9a\x84\xe6\x94\xaf\xe6\x8c\x81\xe3\x80\x82\xe6\x9c\x80\xe5\x8f\x97\xe6\xac\xa2\xe8\xbf\x8e\xe7\x9a\x84\xe6\x98\xaf\x20VSCode(\xe5\x85\x8d\xe8\xb4\xb9)\xe3\x80\x81GoLand\xef\xbc\x88\xe4\xbb\x98\xe8\xb4\xb9\xef\xbc\x89\xe5\x92\x8c\x20Vim\xef\xbc\x88\xe5\x85\x8d\xe8\xb4\xb9\xef\xbc\x89\xe3\x80\x82\x0a\x20\x20
  • \x0a\x20\x20
  • \x0a\x20\x20\x20\x20\xe5\x91\xbd\xe4\xbb\xa4\xe8\xa1\x8c\xe7\xbb\x88\xe7\xab\xaf\xe3\x80\x82\x20Go\xe5\x8f\xaf\xe4\xbb\xa5\xe5\x9c\xa8\xe4\xbb\xbb\xe4\xbd\x95\xe7\xbb\x88\xe7\xab\xaf\xe4\xb8\x8a\xe6\xad\xa3\xe5\xb8\xb8\xe8\xbf\x90\xe8\xa1\x8c\xef\xbc\x8c\xe5\xa6\x82\x20Linux\x20\xe5\x92\x8c\x20Mac\x20\xef\xbc\x8c\xe4\xbb\xa5\xe5\x8f\x8a\xe5\x9c\xa8\x20PowerShell\x20\xe6\x88\x96\xe8\x80\x85\x20Windows\x20\xe7\x9a\x84\x20cmd\xe3\x80\x82\x0a\x20\x20
  • \x0a
\x0a\x0a\xe5\xae\x89\xe8\xa3\x85\x20Go\x0a\x0a

\xe5\x8f\xaa\xe9\x9c\x80\xe4\xbd\xbf\xe7\x94\xa8\x20\xe4\xb8\x8b\xe8\xbd\xbd\xe5\x92\x8c\xe5\xae\x89\xe8\xa3\x85\x20\xe6\xad\xa5\xe9\xaa\xa4\xe3\x80\x82

\x0a\x0a\xe5\x86\x99\xe4\xb8\x80\xe4\xba\x9b\xe4\xbb\xa3\xe7\xa0\x81\x0a\x0a

\x0a\x20\x20\xe4\xbb\x8e\x20Hello,\x20World\x20\xe5\xbc\x80\xe5\xa7\x8b\xe3\x80\x82\x0a

\x0a\x0a
    \x0a\x20\x20
  1. \x0a\x20\x20\x20\x20\xe6\x89\x93\xe5\xbc\x80\xe5\x91\xbd\xe4\xbb\xa4\xe8\xa1\x8c\xe5\xb9\xb6\x20cd\x20\xe5\x88\xb0\xe4\xbd\xa0\xe7\x9a\x84\xe4\xb8\xbb\xe7\x9b\xae\xe5\xbd\x95\xe3\x80\x82\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\xe5\x9c\xa8\x20Linux\x20\xe6\x88\x96\x20Mac\x20\xe7\xb3\xbb\xe7\xbb\x9f\xe4\xb8\x8a\xef\xbc\x9a\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0acd\x0a\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\xe5\x9c\xa8\x20Windows\x20\xe7\xb3\xbb\xe7\xbb\x9f\xe4\xb8\x8a:\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0acd\x20%HOMEPATH%\x0a\x0a\x20\x20
  2. \x0a\x0a\x20\x20
  3. \x0a\x20\x20\x20\x20\xe4\xb8\xba\xe4\xbd\xa0\xe7\x9a\x84\xe7\xac\xac\xe4\xb8\x80\xe4\xb8\xaa\x20Go\x20\xe4\xbb\xa3\xe7\xa0\x81\xe5\x88\x9b\xe5\xbb\xba\xe4\xb8\x80\xe4\xb8\xaa\x20hello\x20\xe7\x9b\xae\xe5\xbd\x95\xe3\x80\x82\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\xe4\xbe\x8b\xe5\xa6\x82\xef\xbc\x9a\xe4\xbd\xbf\xe7\x94\xa8\xe4\xb8\x8b\xe9\x9d\xa2\xe7\x9a\x84\xe5\x91\xbd\xe4\xbb\xa4\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0amkdir\x20hello\x0acd\x20hello\x0a\x0a\x20\x20
  4. \x0a\x0a\x20\x20
  5. \x0a\x20\x20\x20\x20\xe5\x9c\xa8\xe4\xbd\xa0\xe7\x9a\x84\xe6\x96\x87\xe6\x9c\xac\xe7\xbc\x96\xe8\xbe\x91\xe5\x99\xa8\xe4\xb8\xad\xef\xbc\x8c\xe5\x88\x9b\xe5\xbb\xba\xe4\xb8\x80\xe4\xb8\xaa\xe6\x96\x87\xe4\xbb\xb6\x20hello.go\x20\xe5\x8e\xbb\xe7\xbc\x96\xe5\x86\x99\xe4\xbd\xa0\xe7\x9a\x84\xe4\xbb\xa3\xe7\xa0\x81\xe3\x80\x82\x0a\x20\x20
  6. \x0a\x0a\x20\x20
  7. \x0a\x20\x20\x20\x20\xe5\xb0\x86\xe4\xbb\xa5\xe4\xb8\x8b\xe4\xbb\xa3\xe7\xa0\x81\xe7\xb2\x98\xe8\xb4\xb4\xe5\x88\xb0\x20hello.go\x20\xe6\x96\x87\xe4\xbb\xb6\xe4\xb8\xad\xef\xbc\x8c\xe7\x84\xb6\xe5\x90\x8e\xe4\xbf\x9d\xe5\xad\x98\xe6\x96\x87\xe4\xbb\xb6\xe3\x80\x82\x0a\x20\x20\x20\x20
    \x0apackage\x20main\x0a\x0aimport\x20\"fmt\"\x0a\x0afunc\x20main()\x20{\x0a\x20\x20\x20\x20fmt.Println(\"Hello,\x20World!\")\x0a}\x0a\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\xe8\xbf\x99\xe6\x98\xaf\xe4\xbd\xa0\xe7\x9a\x84\x20Go\x20\xe4\xbb\xa3\xe7\xa0\x81\xef\xbc\x8c\xe5\x9c\xa8\xe8\xbf\x99\xe4\xb8\xaa\xe4\xbb\xa3\xe7\xa0\x81\xe4\xb8\xad\xef\xbc\x9a\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
      \x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\xe5\xa3\xb0\xe6\x98\x8e\xe4\xb8\x80\xe4\xb8\xaa\x20main\x20\xe5\x8c\x85\xef\xbc\x88\xe5\x8c\x85\xe6\x98\xaf\xe4\xb8\x80\xe7\xa7\x8d\xe7\xae\xa1\xe7\x90\x86\xe5\x8a\x9f\xe8\x83\xbd\xe7\x9a\x84\xe6\x96\xb9\xe6\xb3\x95\xef\xbc\x89\xe3\x80\x82\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\xe5\xbc\x95\xe7\x94\xa8\xe6\xb5\x81\xe8\xa1\x8c\xe7\x9a\x84\x0a\x20\x20\x20\x20\x20\x20\x20\x20fmt\x20\xe5\x8c\x85,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\xe5\x85\xb6\xe4\xb8\xad\xe5\x8c\x85\xe5\x90\xab\xe6\xa0\xbc\xe5\xbc\x8f\xe5\x8c\x96\xe6\x96\x87\xe6\x9c\xac\xe7\x9a\x84\xe5\x8a\x9f\xe8\x83\xbd\xef\xbc\x8c\xe5\x8c\x85\xe5\x90\xab\xe6\x89\x93\xe5\x8d\xb0\xe5\x88\xb0\xe6\x8e\xa7\xe5\x88\xb6\xe5\x8f\xb0\xe3\x80\x82\xe8\xbf\x99\xe4\xb8\xaa\xe5\x8c\x85\xe6\x98\xaf\xe4\xb8\x80\xe4\xb8\xaa\x20\xe6\xa0\x87\xe5\x87\x86\xe5\xba\x93\xe5\x8c\x85\xef\xbc\x8c\xe5\x9c\xa8\xe5\xae\x89\xe8\xa3\x85\xe7\x9a\x84\x20Go\x20\xe7\x9a\x84\xe6\x97\xb6\xe5\x80\x99\xe5\x86\x85\xe7\xbd\xae\xe7\x9a\x84\xe3\x80\x82\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\xe5\xae\x9e\xe7\x8e\xb0\x20main\x20\xe5\x87\xbd\xe6\x95\xb0\xe6\x89\x93\xe5\x8d\xb0\xe4\xbf\xa1\xe6\x81\xaf\xe5\x88\xb0\xe6\x8e\xa7\xe5\x88\xb6\xe5\x8f\xb0\xe3\x80\x82\x20\xe5\xbd\x93\xe6\x89\xa7\xe8\xa1\x8c\xe4\xbd\xa0\xe7\x9a\x84\xe4\xbb\xa3\xe7\xa0\x81\xe6\x97\xb6\xef\xbc\x8cmain\x20\xe5\x87\xbd\xe6\x95\xb0\xe6\x98\xaf\xe9\xbb\x98\xe8\xae\xa4\xe6\x89\xa7\xe8\xa1\x8c\xe7\x9a\x84\xe3\x80\x82\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20
    \x0a\x20\x20
  8. \x0a\x0a\x20\x20
  9. \x0a\x20\x20\x20\x20\xe8\xbf\x90\xe8\xa1\x8c\xe4\xbd\xa0\xe7\x9a\x84\xe4\xbb\xa3\xe7\xa0\x81\xe5\x8f\xaf\xe4\xbb\xa5\xe6\x9f\xa5\xe7\x9c\x8b\xe7\xbb\x93\xe6\x9e\x9c\xe3\x80\x82\x0a\x0a\x20\x20\x20\x20
    \x0a$\x20go\x20run\x20hello.go\x0aHello,\x20World!\x0a\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\xe8\xbf\x99\xe4\xb8\xaa\x0a\x20\x20\x20\x20\x20\x20go\x20run\x20\xe5\x91\xbd\xe4\xbb\xa4\x0a\x20\x20\x20\x20\x20\x20\xe6\x98\xaf\xe8\xae\xb8\xe5\xa4\x9a\xe7\x94\xa8\xe4\xba\x8e\xe4\xbd\xbf\xe7\x94\xa8\x20Go\x20\xe5\xae\x8c\xe6\x88\x90\xe6\x93\x8d\xe4\xbd\x9c\xe7\x9a\x84\x20go\x20\xe5\x91\xbd\xe4\xbb\xa4\xe4\xb9\x8b\xe4\xb8\x80\xe3\x80\x82\xe4\xbd\xbf\xe7\x94\xa8\xe4\xb8\x8b\xe9\x9d\xa2\xe7\x9a\x84\xe5\x91\xbd\xe4\xbb\xa4\xe8\x8e\xb7\xe5\x8f\x96\xe5\x85\xb6\xe4\xbb\x96\xe7\x9a\x84\xe5\x88\x97\xe8\xa1\xa8\xef\xbc\x9a\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0a$\x20go\x20help\x0a\x0a\x20\x20
  10. \x0a
\x0a\x0a\xe4\xbd\xbf\xe7\x94\xa8\xe5\xa4\x96\xe9\x83\xa8\xe5\x8c\x85\xe7\x9a\x84\xe4\xbb\xa3\xe7\xa0\x81\x0a\x0a

\x0a\x20\x20\xe5\xbd\x93\xe4\xbd\xa0\xe5\xbd\x93\xe4\xbb\xa3\xe7\xa0\x81\xe9\x9c\x80\xe8\xa6\x81\xe5\xbc\x95\xe7\x94\xa8\xe5\x85\xb6\xe4\xbb\x96\xe4\xbb\xa3\xe7\xa0\x81\xe7\x9a\x84\xe6\x97\xb6\xe5\x80\x99\xef\xbc\x8c\xe4\xbd\xa0\xe5\x8f\xaf\xe4\xbb\xa5\xe6\x9f\xa5\xe6\x89\xbe\xe5\x85\xb6\xe4\xbb\x96\xe5\x8c\x85\xe4\xb8\xad\xe5\x8c\x85\xe5\x90\xab\xe4\xbd\xa0\xe6\x83\xb3\xe8\xa6\x81\xe7\x9a\x84\xe5\x8a\x9f\xe8\x83\xbd\xe3\x80\x82\x0a

\x0a\x0a
    \x0a\x20\x20
  1. \x0a\x20\x20\x20\x20\xe9\x80\x9a\xe8\xbf\x87\xe4\xbd\xbf\xe7\x94\xa8\xe5\x85\xb6\xe4\xbb\x96\xe6\xa8\xa1\xe5\x9d\x97\xe4\xb8\xad\xe7\x9a\x84\xe5\x8a\x9f\xe8\x83\xbd\xe4\xbd\xbf\xe4\xbd\xa0\xe7\x9a\x84\xe6\x89\x93\xe5\x8d\xb0\xe4\xbf\xa1\xe6\x81\xaf\xe6\x9b\xb4\xe5\x8a\xa0\xe6\x9c\x89\xe8\xb6\xa3\xe3\x80\x82\x0a\x20\x20\x20\x20
      \x0a\x20\x20\x20\x20\x20\x20
    1. \x0a\x20\x20\x20\x20\x20\x20\x20\x20\xe8\xae\xbf\xe9\x97\xae\x20pkg.go.dev\x20\xe5\xb9\xb6\xe4\xb8\x94\x0a\x20\x20\x20\x20\x20\x20\x20\x20\xe6\x9f\xa5\xe6\x89\xbe\x20\"quote\"\x20\xe5\x8c\x85.\x0a\x20\x20\x20\x20\x20\x20
    2. \x0a\x20\x20\x20\x20\x20\x20
    3. \x0a\x20\x20\x20\x20\x20\x20\x20\x20\xe5\x9c\xa8\xe6\x90\x9c\xe7\xb4\xa2\xe7\xbb\x93\xe6\x9e\x9c\xe4\xb8\xad\xe6\x89\xbe\xe5\x88\xb0\xe5\xb9\xb6\xe7\x82\xb9\xe5\x87\xbb\x20rsc.io/quote\x20\xe5\x8c\x85\xef\xbc\x88\x0a\x20\x20\x20\x20\x20\x20\x20\x20\xe5\xbd\x93\xe4\xbd\xa0\xe7\x9c\x8b\xe5\x88\xb0\x20\x20rsc.io/quote/v3\x20\xe5\x8c\x85\xe6\x97\xb6\xe8\xaf\xb7\xe6\x9a\x82\xe6\x97\xb6\xe5\xbf\xbd\xe7\x95\xa5\xef\xbc\x89\xe3\x80\x82\xe3\x80\x81\x0a\x20\x20\x20\x20\x20\x20
    4. \x0a\x20\x20\x20\x20\x20\x20
    5. \x0a\x20\x20\x20\x20\x20\x20\x20\x20\xe5\x9c\xa8\x20\xe6\x96\x87\xe6\xa1\xa3\x20\xe6\xa0\x87\xe7\xad\xbe\xef\xbc\x8c\xe7\xb4\xa2\xe5\xbc\x95\xe9\x87\x8c\xe9\x9d\xa2\xef\xbc\x8c\xe6\xb3\xa8\xe6\x84\x8f\xe5\x88\x97\xe8\xa1\xa8\xe9\x87\x8c\xe9\x9d\xa2\xe6\x98\xaf\xe4\xbd\xa0\xe5\x8f\xaf\xe4\xbb\xa5\xe8\xb0\x83\xe7\x94\xa8\xe7\x9a\x84\xe5\x8a\x9f\xe8\x83\xbd\xe3\x80\x82\xe4\xbd\xa0\xe5\x8f\xaf\xe4\xbb\xa5\xe4\xbd\xbf\xe7\x94\xa8\x20Go\x20\xe5\x87\xbd\xe6\x95\xb0\xe3\x80\x82\x0a\x20\x20\x20\x20\x20\x20
    6. \x0a\x20\x20\x20\x20\x20\x20
    7. \x0a\x20\x20\x20\x20\x20\x20\x20\x20\xe5\x9c\xa8\xe9\xa1\xb5\xe9\x9d\xa2\xe7\x9a\x84\xe9\xa1\xb6\xe9\x83\xa8\xef\xbc\x8c\xe6\xb3\xa8\xe6\x84\x8f\x20quote\x20\xe5\x8c\x85\xe6\x98\xaf\xe5\x8c\x85\xe5\x90\xab\xe5\x9c\xa8\x20rsc.io/quote\x20\x20\xe6\xa8\xa1\xe5\x9d\x97\xe4\xb8\xad\xe7\x9a\x84\xe3\x80\x82\x0a\x20\x20\x20\x20\x20\x20
    8. \x0a\x20\x20\x20\x20
    \x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\xe4\xbd\xa0\xe5\x8f\xaf\xe4\xbb\xa5\xe4\xbd\xbf\xe7\x94\xa8\x20pkg.go.dev\x20\xe7\xbd\x91\xe7\xab\x99\xe5\x8e\xbb\xe6\x9f\xa5\xe6\x89\xbe\xe5\xb7\xb2\xe5\x8f\x91\xe5\xb8\x83\xe7\x9a\x84\xe6\xa8\xa1\xe5\x9d\x97\xef\xbc\x8c\xe4\xbd\xa0\xe5\x8f\xaf\xe4\xbb\xa5\xe5\x9c\xa8\xe4\xbd\xa0\xe7\x9a\x84\xe4\xbb\xa3\xe7\xa0\x81\xe9\x87\x8c\xe9\x9d\xa2\xe4\xbd\xbf\xe7\x94\xa8\xe5\xae\x83\xe3\x80\x82\xe5\x8c\x85\xe5\x8f\x91\xe5\xb8\x83\xe5\x9c\xa8\xe6\xa8\xa1\xe5\x9d\x97\xe4\xb8\xad\x20--\x20\xe5\xb0\xb1\xe5\x83\x8f\x0a\x20\x20\x20\x20\x20\x20rsc.io/quote\x20--\x20\xe5\x85\xb6\xe4\xbb\x96\xe4\xba\xba\xe5\x8f\xaf\xe4\xbb\xa5\xe4\xbd\xbf\xe7\x94\xa8\xe5\xae\x83\xe9\x97\xa8\xe3\x80\x82\xe9\x9a\x8f\xe7\x9d\x80\xe6\x96\xb0\xe7\x89\x88\xe6\x9c\xac\xe5\xaf\xb9\xe6\xa8\xa1\xe5\x9d\x97\xe7\x9a\x84\xe6\x94\xb9\xe8\xbf\x9b\xef\xbc\x8c\xe4\xbd\xa0\xe5\x8f\xaf\xe4\xbb\xa5\xe5\x8d\x87\xe7\xba\xa7\xe4\xbb\xa3\xe7\xa0\x81\xe5\x8e\xbb\xe4\xbd\xbf\xe7\x94\xa8\xe6\x94\xb9\xe8\xbf\x9b\xe7\x9a\x84\xe7\x89\x88\xe6\x9c\xac\xe3\x80\x82\x0a\x20\x20\x20\x20

    \x0a\x20\x20
  2. \x0a\x0a\x20\x20
  3. \x0a\x20\x20\x20\x20\xe5\x9c\xa8\xe4\xbd\xa0\xe7\x9a\x84\xe4\xbb\xa3\xe7\xa0\x81\xe9\x87\x8c\xe9\x9d\xa2\xef\xbc\x8c\xe5\xbc\x95\xe7\x94\xa8\x20rsc.io/quote\x20\xe5\x8c\x85\xe5\xb9\xb6\xe8\xb0\x83\xe7\x94\xa8\xe5\xae\x83\xe7\x9a\x84\x20Go\x20\xe5\x87\xbd\xe6\x95\xb0\xe3\x80\x82\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\xe6\xb7\xbb\xe5\x8a\xa0\xe4\xb8\x8b\xe9\x9d\xa2\xe9\xab\x98\xe4\xba\xae\xe7\x9a\x84\xe8\xa1\x8c\xe5\x90\x8e\xef\xbc\x8c\xe4\xbd\xa0\xe7\x9a\x84\xe4\xbb\xa3\xe7\xa0\x81\xe9\x9c\x80\xe8\xa6\x81\xe5\x8c\x85\xe5\x90\xab\xe4\xbb\xa5\xe4\xb8\x8b\xe5\x86\x85\xe5\xae\xb9\xef\xbc\x9a\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0apackage\x20main\x0a\x0aimport\x20\"fmt\"\x0a\x0aimport\x20\"rsc.io/quote\"\x0a\x0afunc\x20main()\x20{\x0a\x20\x20\x20\x20fmt.Println(quote.Go())\x0a}\x0a
    \x0a\x20\x20
  4. \x0a\x0a\x20\x20
  5. \x0a\x20\x20\x20\x20\xe5\xb0\x86\xe4\xbd\xa0\xe7\x9a\x84\xe4\xbb\xa3\xe7\xa0\x81\xe6\x94\xbe\xe5\x9c\xa8\xe6\xa8\xa1\xe5\x9d\x97\xe4\xb8\xad\xe5\x8e\xbb\xe8\xb7\x9f\xe8\xb8\xaa\xe4\xbe\x9d\xe8\xb5\x96\xe5\x85\xb3\xe7\xb3\xbb\xe3\x80\x82\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\xe5\xbd\x93\xe4\xbd\xa0\xe7\x9a\x84\xe4\xbb\xa3\xe7\xa0\x81\xe4\xbb\x8e\xe5\x8f\xa6\xe4\xb8\x80\xe4\xb8\xaa\xe6\xa8\xa1\xe5\x9d\x97\xe4\xb8\xad\xe5\xbc\x95\xe5\x85\xa5\xe5\x8c\x85\xe6\x97\xb6\xef\xbc\x8cgo.mod\x20\xe6\x96\x87\xe4\xbb\xb6\xe4\xbc\x9a\xe5\x88\x97\xe5\x87\xba\xe8\xbf\x99\xe4\xba\x9b\xe6\xa8\xa1\xe5\x9d\x97\xe5\x92\x8c\xe4\xbd\xbf\xe7\x94\xa8\xe7\x9a\x84\xe7\x89\x88\xe6\x9c\xac\xe3\x80\x82\xe8\xbf\x99\xe4\xba\x9b\xe6\x96\x87\xe4\xbb\xb6\xe5\x9c\xa8\xe4\xbd\xa0\xe7\x9a\x84\xe4\xbb\xa3\xe7\xa0\x81\xe9\x87\x8c\xe9\x9d\xa2\xef\xbc\x8c\xe5\x9c\xa8\xe4\xbd\xa0\xe7\x9a\x84\xe6\xba\x90\xe4\xbb\xa3\xe7\xa0\x81\xe9\x87\x8c\xe9\x9d\xa2\xe3\x80\x82\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\xe5\x88\x9b\xe5\xbb\xba\xe4\xb8\x80\xe4\xb8\xaa\x20go.mod\x20\xe6\x96\x87\xe4\xbb\xb6\xef\xbc\x8c\xe5\xb9\xb6\xe6\x89\xa7\xe8\xa1\x8c\x0a\x20\x20\x20\x20\x20\x20go\x20mod\x20init\x20\xe5\x91\xbd\xe4\xbb\xa4,\x20\xe7\xbb\x99\xe5\xae\x83\xe6\x8f\x90\xe4\xbe\x9b\xe4\xbb\xa3\xe7\xa0\x81\xe6\x89\x80\xe5\x9c\xa8\xe6\xa8\xa1\xe5\x9d\x97\xe7\x9a\x84\xe9\x87\x8c\xe9\x9d\xa2\xef\xbc\x88\xe8\xbf\x99\xe9\x87\x8c\xef\xbc\x8c\xe5\x8f\xaa\xe9\x9c\x80\xe8\xa6\x81\xe4\xbd\xbf\xe7\x94\xa8\x20\"hello\"\xef\xbc\x89:\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0a$\x20go\x20mod\x20init\x20hello\x0ago:\x20creating\x20new\x20go.mod:\x20module\x20hello\x0a\x0a\x20\x20
  6. \x0a\x0a\x20\x20
  7. \x0a\x20\x20\x20\x20\xe6\x89\xa7\xe8\xa1\x8c\xe4\xbd\xa0\xe7\x9a\x84\xe4\xbb\xa3\xe7\xa0\x81\xe6\x9f\xa5\xe7\x9c\x8b\xe4\xbf\xa1\xe6\x81\xaf\xe4\xbd\xa0\xe8\xb0\x83\xe7\x94\xa8\xe7\x9a\x84\xe5\x87\xbd\xe6\x95\xb0\xe4\xba\xa7\xe7\x94\x9f\xe7\x9a\x84\xe6\xb6\x88\xe6\x81\xaf\xe3\x80\x82\x0a\x20\x20\x20\x20
    \x0a$\x20go\x20run\x20hello.go\x0ago:\x20finding\x20module\x20for\x20package\x20rsc.io/quote\x0ago:\x20found\x20rsc.io/quote\x20in\x20rsc.io/quote\x20v1.5.2\x0aDon't\x20communicate\x20by\x20sharing\x20memory,\x20share\x20memory\x20by\x20communicating.\x0a\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\xe6\xb3\xa8\xe6\x84\x8f\xef\xbc\x8c\xe4\xbd\xa0\xe7\x9a\x84\xe4\xbb\xa3\xe7\xa0\x81\xe8\xb0\x83\xe7\x94\xa8\xe4\xba\x86\x20Go\x20\xe7\x9a\x84\xe5\x87\xbd\xe6\x95\xb0\xef\xbc\x8c\xe6\x89\x93\xe5\x8d\xb0\xe5\x87\xba\xe4\xba\x86\xe5\x85\xb3\xe4\xba\x8e\xe6\x89\xa7\xe8\xa1\x8c\xe7\x9a\x84\xe6\x98\x8e\xe7\xa1\xae\xe4\xbf\xa1\xe6\x81\xaf\xe3\x80\x82\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20\xe4\xbd\x86\xe5\x9c\xa8\xe6\x89\xa7\xe8\xa1\x8c\xe4\xbb\xa3\xe7\xa0\x81\xe4\xb9\x8b\xe5\x89\x8d\xef\xbc\x8c\x20go\x20run\x20\xe5\x85\x88\xe6\x9f\xa5\xe6\x89\xbe\xe5\xb9\xb6\xe4\xb8\x8b\xe8\xbd\xbd\x20rsc.io/quote\x20\xe6\xa8\xa1\xe5\x9d\x97\xe4\xb8\xad\xe5\x8c\x85\xe5\x90\xab\xe4\xbd\xa0\xe8\xa6\x81\xe5\xbc\x95\xe7\x94\xa8\xe7\x9a\x84\xe5\x8c\x85\xe3\x80\x82\x0a\x20\x20\x20\x20\x20\x20\xe9\xbb\x98\xe8\xae\xa4\xe6\x83\x85\xe5\x86\xb5\xe4\xb8\x8b\xef\xbc\x8c\xe5\xae\x83\xe4\xbc\x9a\xe4\xb8\x8b\xe8\xbd\xbd\xe6\x9c\x80\xe6\x96\xb0\xe7\x9a\x84\xe7\x89\x88\xe6\x9c\xac\x20--\x20v1.5.2\xe3\x80\x82Go\x20\xe6\x9e\x84\xe5\xbb\xba\xe5\x91\xbd\xe4\xbb\xa4\xe4\xbc\x9a\xe6\x9f\xa5\xe6\x89\xbe\xe4\xbd\xa0\xe5\xbc\x95\xe7\x94\xa8\xe5\x8c\x85\xe7\x9a\x84\xe6\x8c\x87\xe5\xae\x9a\xe6\xa8\xa1\xe5\x9d\x97\xe3\x80\x82\x0a\x20\x20\x20\x20

    \x0a\x20\x20
  8. \x0a
\x0a\x0a\xe5\x86\x99\xe6\x9b\xb4\xe5\xa4\x9a\xe4\xbb\xa3\xe7\xa0\x81\x0a\x0a

\x0a\x20\x20\xe9\x80\x9a\xe8\xbf\x87\xe8\xbf\x99\xe4\xb8\xaa\xe5\xbf\xab\xe9\x80\x9f\xe5\x85\xa5\xe9\x97\xa8\xef\xbc\x8c\xe4\xbd\xa0\xe5\xb7\xb2\xe7\xbb\x8f\xe5\xae\x89\xe8\xa3\x85\xe5\xb9\xb6\xe4\xb8\x94\xe5\xad\xa6\xe4\xb9\xa0\xe4\xba\x86\xe4\xb8\x80\xe4\xba\x9b\xe5\x9f\xba\xe7\xa1\x80\xe7\x9f\xa5\xe8\xaf\x86\xe3\x80\x82\xe5\x9c\xa8\xe5\x85\xb6\xe4\xbb\x96\xe6\x95\x99\xe7\xa8\x8b\xe4\xb8\xad\xe7\xbc\x96\xe5\x86\x99\xe6\x9b\xb4\xe5\xa4\x9a\xe4\xbb\xa3\xe7\xa0\x81\xef\xbc\x8c\xe8\xaf\xb7\xe6\x9f\xa5\xe7\x9c\x8b\xe5\x88\x9b\xe5\xbb\xba\xe4\xb8\x80\xe4\xb8\xaa\x20Go\x20\xe6\xa8\xa1\xe5\x9d\x97.\x0a

\x0a", "doc/tutorial/greetings-multiple-people.html": "\x0a\x0a

\x0a\x20\x20In\x20the\x20last\x20changes\x20you'll\x20make\x20to\x20your\x20module's\x20code,\x20you'll\x20add\x20support\x20for\x0a\x20\x20getting\x20greetings\x20for\x20multiple\x20people\x20in\x20one\x20request.\x20In\x20other\x20words,\x20you'll\x0a\x20\x20handle\x20a\x20multiple-value\x20input\x20and\x20pair\x20values\x20with\x20a\x20multiple-value\x20output.\x0a

\x0a\x0a\x0a\x20\x20Note:\x20This\x20topic\x20is\x20part\x20of\x20a\x20multi-part\x20tutorial\x20that\x20begins\x0a\x20\x20with\x20Create\x20a\x20Go\x20module.\x0a\x0a\x0a

\x0a\x20\x20To\x20do\x20this,\x20you'll\x20need\x20to\x20pass\x20a\x20set\x20of\x20names\x20to\x20a\x20function\x20that\x20can\x20return\x20a\x0a\x20\x20greeting\x20for\x20each\x20of\x20them.\x20Changing\x20the\x20Hello\x20function's\x0a\x20\x20parameter\x20from\x20a\x20single\x20name\x20to\x20a\x20set\x20of\x20names\x20would\x20change\x20the\x20function\x0a\x20\x20signature.\x20If\x20you\x20had\x20already\x20published\x20the\x20greetings\x20module\x20and\x0a\x20\x20users\x20had\x20already\x20written\x20code\x20calling\x20Hello,\x20that\x20change\x20would\x0a\x20\x20break\x20their\x20programs.\x20In\x20this\x20situation,\x20a\x20better\x20choice\x20is\x20to\x20give\x20new\x0a\x20\x20functionality\x20a\x20new\x20name.\x0a

\x0a\x0a

\x0a\x20\x20In\x20the\x20last\x20code\x20you'll\x20add\x20with\x20this\x20tutorial,\x20update\x20the\x20code\x20as\x20if\x20you've\x0a\x20\x20already\x20published\x20a\x20version\x20of\x20the\x20greetings\x20module.\x20Instead\x20of\x0a\x20\x20changing\x20the\x20Hello\x20function,\x20add\x20a\x20new\x20function\x0a\x20\x20Hellos\x20that\x20takes\x20a\x20set\x20of\x20names.\x20Then,\x20for\x20the\x20sake\x20of\x0a\x20\x20simplicity,\x20have\x20the\x20new\x20function\x20call\x20the\x20existing\x20one.\x20Keeping\x20both\x0a\x20\x20functions\x20in\x20the\x20package\x20leaves\x20the\x20original\x20for\x20existing\x20callers\x20(or\x20future\x0a\x20\x20callers\x20who\x20only\x20need\x20one\x20greeting)\x20and\x20adds\x20a\x20new\x20one\x20for\x20callers\x20that\x20want\x0a\x20\x20the\x20expanded\x20functionality.\x0a

\x0a\x0a
    \x0a\x20\x20
  1. \x0a\x20\x20\x20\x20In\x20greetings/greetings.go,\x20change\x20your\x20code\x20so\x20it\x20looks\x20like\x20the\x20following.\x0a\x0a\x20\x20\x20\x20
    \x0apackage\x20greetings\x0a\x0aimport\x20(\x0a\x20\x20\x20\x20\"errors\"\x0a\x20\x20\x20\x20\"fmt\"\x0a\x20\x20\x20\x20\"math/rand\"\x0a\x20\x20\x20\x20\"time\"\x0a)\x0a\x0a//\x20Hello\x20returns\x20a\x20greeting\x20for\x20the\x20named\x20person.\x0afunc\x20Hello(name\x20string)\x20(string,\x20error)\x20{\x0a\x20\x20\x20\x20//\x20If\x20no\x20name\x20was\x20given,\x20return\x20an\x20error\x20with\x20a\x20message.\x0a\x20\x20\x20\x20if\x20name\x20==\x20\"\"\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20return\x20name,\x20errors.New(\"empty\x20name\")\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20//\x20Create\x20a\x20message\x20using\x20a\x20random\x20format.\x0a\x20\x20\x20\x20message\x20:=\x20fmt.Sprintf(randomFormat(),\x20name)\x0a\x20\x20\x20\x20return\x20message,\x20nil\x0a}\x0a\x0a//\x20Hellos\x20returns\x20a\x20map\x20that\x20associates\x20each\x20of\x20the\x20named\x20people\x0a//\x20with\x20a\x20greeting\x20message.\x0afunc\x20Hellos(names\x20[]string)\x20(map[string]string,\x20error)\x20{\x0a\x20\x20\x20\x20//\x20A\x20map\x20to\x20associate\x20names\x20with\x20messages.\x0a\x20\x20\x20\x20messages\x20:=\x20make(map[string]string)\x0a\x20\x20\x20\x20//\x20Loop\x20through\x20the\x20received\x20slice\x20of\x20names,\x20calling\x0a\x20\x20\x20\x20//\x20the\x20Hello\x20function\x20to\x20get\x20a\x20message\x20for\x20each\x20name.\x0a\x20\x20\x20\x20for\x20_,\x20name\x20:=\x20range\x20names\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20message,\x20err\x20:=\x20Hello(name)\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20err\x20!=\x20nil\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20return\x20nil,\x20err\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20//\x20In\x20the\x20map,\x20associate\x20the\x20retrieved\x20message\x20with\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20//\x20the\x20name.\x0a\x20\x20\x20\x20\x20\x20\x20\x20messages[name]\x20=\x20message\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20return\x20messages,\x20nil\x0a}\x0a\x0a//\x20Init\x20sets\x20initial\x20values\x20for\x20variables\x20used\x20in\x20the\x20function.\x0afunc\x20init()\x20{\x0a\x20\x20\x20\x20rand.Seed(time.Now().UnixNano())\x0a}\x0a\x0a//\x20randomFormat\x20returns\x20one\x20of\x20a\x20set\x20of\x20greeting\x20messages.\x20The\x20returned\x0a//\x20message\x20is\x20selected\x20at\x20random.\x0afunc\x20randomFormat()\x20string\x20{\x0a\x20\x20\x20\x20//\x20A\x20slice\x20of\x20message\x20formats.\x0a\x20\x20\x20\x20formats\x20:=\x20[]string{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\"Hi,\x20%v.\x20Welcome!\",\x0a\x20\x20\x20\x20\x20\x20\x20\x20\"Great\x20to\x20see\x20you,\x20%v!\",\x0a\x20\x20\x20\x20\x20\x20\x20\x20\"Hail,\x20%v!\x20Well\x20met!\",\x0a\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20//\x20Return\x20one\x20of\x20the\x20message\x20formats\x20selected\x20at\x20random.\x0a\x20\x20\x20\x20return\x20formats[rand.Intn(len(formats))]\x0a}\x0a
    \x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20In\x20this\x20code,\x20you:\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
      \x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20\x20\x20Add\x20a\x20Hellos\x20function\x20whose\x20parameter\x20is\x20a\x20slice\x20of\x20names\x0a\x20\x20\x20\x20\x20\x20\x20\x20rather\x20than\x20a\x20single\x20name.\x20Also,\x20you\x20change\x20one\x20of\x20its\x20return\x20types\x20from\x0a\x20\x20\x20\x20\x20\x20\x20\x20a\x20string\x20to\x20a\x20map\x20so\x20you\x20can\x20return\x20names\x0a\x20\x20\x20\x20\x20\x20\x20\x20mapped\x20to\x20greeting\x20messages.\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20\x20\x20Have\x20the\x20new\x20Hellos\x20function\x20call\x20the\x20existing\x20Hello\x20function.\x20This\x0a\x20\x20\x20\x20\x20\x20\x20\x20leaves\x20both\x20functions\x20in\x20place.\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20\x20\x20Create\x20a\x20messages\x0a\x20\x20\x20\x20\x20\x20\x20\x20map\x20to\x20associate\x20each\x20of\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20received\x20names\x20(as\x20a\x20key)\x20with\x20a\x20generated\x20message\x20(as\x20a\x20value).\x20In\x20Go,\x0a\x20\x20\x20\x20\x20\x20\x20\x20you\x20initialize\x20a\x20map\x20with\x20the\x20following\x20syntax:\x0a\x20\x20\x20\x20\x20\x20\x20\x20make(map[key-type]value-type).\x20You\x20have\x0a\x20\x20\x20\x20\x20\x20\x20\x20the\x20Hello\x20function\x20return\x20this\x20map\x20to\x20the\x20caller.\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20\x20\x20Loop\x20through\x20the\x20names\x20your\x20function\x20received,\x20checking\x20that\x20each\x20has\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20non-empty\x20value,\x20then\x20associate\x20a\x20message\x20with\x20each.\x20In\x20this\x0a\x20\x20\x20\x20\x20\x20\x20\x20for\x20loop,\x20range\x20returns\x20two\x20values:\x20the\x20index\x0a\x20\x20\x20\x20\x20\x20\x20\x20of\x20the\x20current\x20item\x20in\x20the\x20loop\x20and\x20a\x20copy\x20of\x20the\x20item's\x20value.\x20You\x0a\x20\x20\x20\x20\x20\x20\x20\x20don't\x20need\x20the\x20index,\x20so\x20you\x20use\x20the\x20Go\x0a\x20\x20\x20\x20\x20\x20\x20\x20blank\x20identifier\x20(an\x20underscore)\x0a\x20\x20\x20\x20\x20\x20\x20\x20to\x20ignore\x20it.\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20
    \x0a\x20\x20
  2. \x0a\x0a\x20\x20
  3. \x0a\x20\x20\x20\x20In\x20your\x20hello/hello.go\x20calling\x20code,\x20pass\x20a\x20slice\x20of\x20names,\x20then\x20print\x20the\x0a\x20\x20\x20\x20contents\x20of\x20the\x20names/messages\x20map\x20you\x20get\x20back.\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20In\x20hello.go,\x20change\x20your\x20code\x20so\x20it\x20looks\x20like\x20the\x20following.\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0apackage\x20main\x0a\x0aimport\x20(\x0a\x20\x20\x20\x20\"fmt\"\x0a\x20\x20\x20\x20\"log\"\x0a\x0a\x20\x20\x20\x20\"example.com/greetings\"\x0a)\x0a\x0afunc\x20main()\x20{\x0a\x20\x20\x20\x20//\x20Set\x20properties\x20of\x20the\x20predefined\x20Logger,\x20including\x0a\x20\x20\x20\x20//\x20the\x20log\x20entry\x20prefix\x20and\x20a\x20flag\x20to\x20disable\x20printing\x0a\x20\x20\x20\x20//\x20the\x20time,\x20source\x20file,\x20and\x20line\x20number.\x0a\x20\x20\x20\x20log.SetPrefix(\"greetings:\x20\")\x0a\x20\x20\x20\x20log.SetFlags(0)\x0a\x0a\x20\x20\x20\x20//\x20A\x20slice\x20of\x20names.\x0a\x20\x20\x20\x20names\x20:=\x20[]string{\"Gladys\",\x20\"Samantha\",\x20\"Darrin\"}\x0a\x0a\x20\x20\x20\x20//\x20Request\x20greeting\x20messages\x20for\x20the\x20names.\x0a\x20\x20\x20\x20messages,\x20err\x20:=\x20greetings.Hellos(names)\x0a\x20\x20\x20\x20if\x20err\x20!=\x20nil\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20log.Fatal(err)\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20//\x20If\x20no\x20error\x20was\x20returned,\x20print\x20the\x20returned\x20map\x20of\x0a\x20\x20\x20\x20//\x20messages\x20to\x20the\x20console.\x0a\x20\x20\x20\x20fmt.Println(messages)\x0a}\x0a
    \x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20With\x20these\x20changes,\x20you:\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
      \x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20\x20\x20Create\x20a\x20names\x20variable\x20as\x20a\x20slice\x20type\x20holding\x20three\x0a\x20\x20\x20\x20\x20\x20\x20\x20names.\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20\x20\x20\x20\x20Pass\x20the\x20names\x20variable\x20as\x20the\x20argument\x20to\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20Hellos\x20function.\x0a\x20\x20\x20\x20\x20\x20
    • \x0a\x20\x20\x20\x20
    \x0a\x20\x20
  4. \x0a\x0a\x20\x20
  5. \x0a\x20\x20\x20\x20At\x20the\x20command\x20line,\x20change\x20to\x20the\x20directory\x20that\x20contains\x20hello/hello.go,\x0a\x20\x20\x20\x20then\x20run\x20hello.go\x20to\x20confirm\x20that\x20the\x20code\x20works.\x0a\x0a\x20\x20\x20\x20

    \x0a\x20\x20\x20\x20\x20\x20The\x20output\x20should\x20be\x20a\x20string\x20representation\x20of\x20the\x20map\x20associating\x20names\x0a\x20\x20\x20\x20\x20\x20with\x20messages,\x20something\x20like\x20the\x20following:\x0a\x20\x20\x20\x20

    \x0a\x0a\x20\x20\x20\x20
    \x0a$\x20go\x20run\x20hello.go\x0amap[Darrin:Hail,\x20Darrin!\x20Well\x20met!\x20Gladys:Hi,\x20Gladys.\x20Welcome!\x20Samantha:Hail,\x20Samantha!\x20Well\x20met!]\x0a\x0a\x20\x20
  6. \x0a
\x0a\x0a

\x0a\x20\x20This\x20topic\x20introduced\x20maps\x20for\x20representing\x20name/value\x20pairs.\x20It\x20also\x0a\x20\x20introduced\x20the\x20idea\x20of\x0a\x20\x20preserving\x20backward\x20compatibility\x0a\x20\x20by\x20implementing\x20a\x20new\x20function\x20for\x20new\x20or\x20changed\x20functionality\x20in\x20a\x20module.\x0a\x20\x20In\x20the\x20tutorial's\x20next\x20topic,\x20you'll\x20use\x0a\x20\x20built-in\x20features\x20to\x20create\x20a\x20unit\x20test\x20for\x20your\x20code.\x0a

\x0a\x0a\x0a\x20\x20<\x20Return\x20a\x20random\x20greeting\x0a\x20\x20Add\x20a\x20test\x20>\x0a

\x0a", From ae7e37874c20942608d8d86b07a1352010c58465 Mon Sep 17 00:00:00 2001 From: wangkekai <75264356@qq.com> Date: Fri, 27 Nov 2020 18:44:44 +0800 Subject: [PATCH 04/12] Update content/static/doc/tutorial/getting-started.html Co-authored-by: LeiSangSang <63998077+LeiSangSang@users.noreply.github.com> --- content/static/doc/tutorial/getting-started.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/static/doc/tutorial/getting-started.html b/content/static/doc/tutorial/getting-started.html index 9c71f69038..97342dde08 100644 --- a/content/static/doc/tutorial/getting-started.html +++ b/content/static/doc/tutorial/getting-started.html @@ -12,7 +12,7 @@
  • 编写简单的 “Hello, world" 代码。
  • 使用 go 命令执行你的代码。
  • - 使用 Go 发现工具包去查找可以在你自己代码中使用的包。 + 使用 Go 包(Go Package)发现工具去查找可以在你自己代码中使用的包。
  • 调用外部模块的功能。
  • From 438918d6a8efa0745bd88944d23e6446e64e95b2 Mon Sep 17 00:00:00 2001 From: wangkekai <75264356@qq.com> Date: Fri, 27 Nov 2020 18:45:16 +0800 Subject: [PATCH 05/12] Update content/static/doc/tutorial/getting-started.html Co-authored-by: LeiSangSang <63998077+LeiSangSang@users.noreply.github.com> --- content/static/doc/tutorial/getting-started.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/static/doc/tutorial/getting-started.html b/content/static/doc/tutorial/getting-started.html index 97342dde08..3ccd8a501d 100644 --- a/content/static/doc/tutorial/getting-started.html +++ b/content/static/doc/tutorial/getting-started.html @@ -14,7 +14,7 @@
  • 使用 Go 包(Go Package)发现工具去查找可以在你自己代码中使用的包。
  • -
  • 调用外部模块的功能。
  • +
  • 调用外部模块提供的函数(function)。