Skip to content

Commit e7b262c

Browse files
oioojdmitshur
authored andcommitted
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 <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Trust: Baokun Lee <[email protected]>
1 parent c34a3f0 commit e7b262c

File tree

2 files changed

+33
-22
lines changed

2 files changed

+33
-22
lines changed

content/static/doc/tutorial/getting-started.html

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,31 @@ <h2 id="code">Write some code</h2>
8989
>
9090
</li>
9191

92+
<li>
93+
Initialize a new module for tracking dependencies.
94+
95+
<p>
96+
When your code imports packages from another module, a go.mod file lists
97+
the specific modules and versions providing those packages. That file
98+
stays with your code, including in your source code repository.
99+
</p>
100+
101+
<p>
102+
To create a go.mod file, run the
103+
<a
104+
href="https://golang.org/cmd/go/#hdr-Initialize_new_module_in_current_directory"
105+
><code>go mod init</code> command</a
106+
>, giving it the name of the module your code will be in (here, just use
107+
"hello"):
108+
</p>
109+
110+
<pre>
111+
$ go mod init hello
112+
go: creating new go.mod: module hello
113+
</pre
114+
>
115+
</li>
116+
92117
<li>
93118
In your text editor, create a file hello.go in which to write your code.
94119
</li>
@@ -224,26 +249,15 @@ <h2 id="call">Call code in an external package</h2>
224249
</li>
225250

226251
<li>
227-
Put your own code in a module for tracking dependencies.
252+
Add new module requirements and sums.
228253

229254
<p>
230-
When your code imports packages from another module, a go.mod file lists
231-
the specific modules and versions providing those packages. That file
232-
stays with your code, including in your source code repository.
255+
Go will add the <code>quote</code> module as a requirement, as well as a go.sum file for use in authenticating the module. For more, see <a href="https://golang.org/cmd/go/#hdr-Module_authentication_using_go_sum">Module authentication using go.sum</a>.
233256
</p>
234-
235-
<p>
236-
To create a go.mod file, run the
237-
<a
238-
href="https://golang.org/cmd/go/#hdr-Initialize_new_module_in_current_directory"
239-
><code>go mod init</code> command</a
240-
>, giving it the name of the module your code will be in (here, just use
241-
"hello"):
242-
</p>
243-
244257
<pre>
245-
$ go mod init hello
246-
go: creating new go.mod: module hello
258+
$ go mod tidy
259+
go: finding module for package rsc.io/quote
260+
go: found rsc.io/quote in rsc.io/quote v1.5.2
247261
</pre
248262
>
249263
</li>
@@ -253,8 +267,6 @@ <h2 id="call">Call code in an external package</h2>
253267

254268
<pre>
255269
$ go run .
256-
go: finding module for package rsc.io/quote
257-
go: found rsc.io/quote in rsc.io/quote v1.5.2
258270
Don't communicate by sharing memory, share memory by communicating.
259271
</pre
260272
>
@@ -265,10 +277,9 @@ <h2 id="call">Call code in an external package</h2>
265277
</p>
266278

267279
<p>
268-
But before it ran the code, <code>go run</code> located and downloaded the
280+
When you ran <code>go mod tidy</code>, it located and downloaded the
269281
<code>rsc.io/quote</code> module that contains the package you imported.
270-
By default, it downloaded the latest version -- v1.5.2. Go build commands
271-
are designed to locate the modules required for packages you import.
282+
By default, it downloaded the latest version -- v1.5.2.
272283
</p>
273284
</li>
274285
</ol>

0 commit comments

Comments
 (0)