From e7b262c538518b210432d76bce99d358c72cead3 Mon Sep 17 00:00:00 2001 From: Baokun Lee Date: Mon, 1 Feb 2021 10:25:15 +0800 Subject: [PATCH] content: improve getting started document Improve the guidance document to adapt to the Go 1.16. Fixes golang/go#43672 Change-Id: I443540591d032e05dbec951e2a4995f6dbc2bc77 Reviewed-on: https://go-review.googlesource.com/c/website/+/288277 Run-TryBot: Baokun Lee TryBot-Result: Go Bot Reviewed-by: Dmitri Shuralyov Trust: Baokun Lee --- .../static/doc/tutorial/getting-started.html | 53 +++++++++++-------- content/static/static.go | 2 +- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/content/static/doc/tutorial/getting-started.html b/content/static/doc/tutorial/getting-started.html index 0e76bb13..a92cf209 100644 --- a/content/static/doc/tutorial/getting-started.html +++ b/content/static/doc/tutorial/getting-started.html @@ -89,6 +89,31 @@ cd hello > +
  • + Initialize a new 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. +

    + +

    + To create a go.mod file, run the + go mod init command, giving it the name of the module your code will be in (here, just use + "hello"): +

    + +
    +$ go mod init hello
    +go: creating new go.mod: module hello
    +
    +
  • +
  • In your text editor, create a file hello.go in which to write your code.
  • @@ -224,26 +249,15 @@ func main() {
  • - Put your own code in a module for tracking dependencies. + Add new module requirements and sums.

    - 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 will add the quote module as a requirement, as well as a go.sum file for use in authenticating the module. For more, see Module authentication using go.sum.

    - -

    - To create a go.mod file, run the - go mod init command, giving it the name of the module your code will be in (here, just use - "hello"): -

    -
    -$ go mod init hello
    -go: creating new go.mod: module hello
    +$ go mod tidy
    +go: finding module for package rsc.io/quote
    +go: found rsc.io/quote in rsc.io/quote v1.5.2
     
  • @@ -253,8 +267,6 @@ go: creating new go.mod: module hello
     $ go run .
    -go: finding module for package rsc.io/quote
    -go: found rsc.io/quote in rsc.io/quote v1.5.2
     Don't communicate by sharing memory, share memory by communicating.
     
    @@ -265,10 +277,9 @@ Don't communicate by sharing memory, share memory by communicating.

    - But before it ran the code, go run located and downloaded the + When you ran go mod tidy, it 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. + By default, it downloaded the latest version -- v1.5.2.

    diff --git a/content/static/static.go b/content/static/static.go index cf7a4f44..d90de341 100644 --- a/content/static/static.go +++ b/content/static/static.go @@ -111,7 +111,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,\x20and\x20it's\x20made\x20up\x20of\x20all\x20the\x20files\x20in\x20the\x20same\x20directory).\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\x20the\x20main\x20package.\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\x20.\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\x20.\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\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\x20Initialize\x20a\x20new\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\x20In\x20your\x20text\x20editor,\x20create\x20a\x20file\x20hello.go\x20in\x20which\x20to\x20write\x20your\x20code.\x0a\x20\x20
    8. \x0a\x0a\x20\x20
    9. \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,\x20and\x20it's\x20made\x20up\x20of\x20all\x20the\x20files\x20in\x20the\x20same\x20directory).\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\x20the\x20main\x20package.\x0a\x20\x20\x20\x20\x20\x20
      • \x0a\x20\x20\x20\x20
      \x0a\x20\x20
    10. \x0a\x0a\x20\x20
    11. \x0a\x20\x20\x20\x20Run\x20your\x20code\x20to\x20see\x20the\x20greeting.\x0a\x0a\x20\x20\x20\x20
      \x0a$\x20go\x20run\x20.\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
    12. \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\x20Add\x20new\x20module\x20requirements\x20and\x20sums.\x0a\x0a\x20\x20\x20\x20

      \x0a\x20\x20\x20\x20\x20\x20Go\x20will\x20add\x20the\x20quote\x20module\x20as\x20a\x20requirement,\x20as\x20well\x20as\x20a\x20go.sum\x20file\x20for\x20use\x20in\x20authenticating\x20the\x20module.\x20For\x20more,\x20see\x20Module\x20authentication\x20using\x20go.sum.\x0a\x20\x20\x20\x20

      \x0a\x20\x20\x20\x20
      \x0a$\x20go\x20mod\x20tidy\x0ago:\x20finding\x20module\x20for\x20package\x20rsc.io/quote\x0ago:\x20found\x20rsc.io/quote\x20in\x20rsc.io/quote\x20v1.5.2\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\x20.\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\x20When\x20you\x20ran\x20go\x20mod\x20tidy,\x20it\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.\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/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\x20Hellos\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",