diff --git a/content/static/doc/tutorial/getting-started.html b/content/static/doc/tutorial/getting-started.html index 0ae3a63419..4f62f60d2f 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 编程。跟随教程,你将:

-

Prerequisites

+

前提

-

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. + 当你的代码需要引用其他代码的时候,你可以在其他的包中找到你想用在自己代码中的功能(function)。

  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. + 在左侧 Documentation(文档) 标签页面的 Index(索引) 下面的清单里列举的是你可以调用的功能(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",