Skip to content

Commit 61b5c86

Browse files
committed
doc/go1.18: document Go 1.17 bootstrap and //go:build fix
For #44505 and #41184. Change-Id: I9503292dace1aa60de167ca5807bf131554465b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/386774 Trust: Russ Cox <[email protected]> Run-TryBot: Russ Cox <[email protected]> Reviewed-by: Jeremy Faller <[email protected]>
1 parent d27248c commit 61b5c86

File tree

1 file changed

+45
-5
lines changed

1 file changed

+45
-5
lines changed

doc/go1.18.html

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ <h3 id="fuzzing">Fuzzing</h3>
250250

251251
<h3 id="go-command">Go command</h3>
252252

253+
<h4 id="go-get"><code>go</code> <code>get</code></h4>
254+
253255
<p><!-- golang.org/issue/43684 -->
254256
<code>go</code> <code>get</code> no longer builds or installs packages in
255257
module-aware mode. <code>go</code> <code>get</code> is now dedicated to
@@ -269,6 +271,8 @@ <h3 id="go-command">Go command</h3>
269271
and installs packages, as before.
270272
</p>
271273

274+
<h4 id="go-version"><code>go</code> <code>version</code></h4>
275+
272276
<p><!-- golang.org/issue/37475 -->
273277
The <code>go</code> command now embeds version control information in
274278
binaries including the currently checked-out revision, commit time, and a
@@ -303,6 +307,8 @@ <h3 id="go-command">Go command</h3>
303307
<code>debug/buildinfo</code> package from <code>go</code> 1.18+.
304308
</p>
305309

310+
<h4 id="go-mod-download"><code>go</code> <code>mod</code> <code>download</code></h4>
311+
306312
<p><!-- https://golang.org/issue/44435 -->
307313
If the main module's <code>go.mod</code> file
308314
specifies <a href="/ref/mod#go-mod-file-go"><code>go</code> <code>1.17</code></a>
@@ -316,6 +322,8 @@ <h3 id="go-command">Go command</h3>
316322
<code>go</code> <code>mod</code> <code>download</code> <code>all</code>.
317323
</p>
318324

325+
<h4 id="go-mod-vendor"><code>go</code> <code>mod</code> <code>vendor</code></h4>
326+
319327
<p><!-- https://golang.org/issue/47327 -->
320328
The <code>go</code> <code>mod</code> <code>vendor</code> subcommand now
321329
supports a <code>-o</code> flag to set the output directory.
@@ -325,13 +333,17 @@ <h3 id="go-command">Go command</h3>
325333
third-party tools that need to collect package source code.)
326334
</p>
327335

336+
<h4 id="go-mod-vendor"><code>go</code> <code>build</code> <code>-asan</code></h4>
337+
328338
<p><!-- CL 298612 -->
329339
The <code>go</code> <code>build</code> command and related commands
330340
now support an <code>-asan</code> flag that enables interoperation
331341
with C (or C++) code compiled with the address sanitizer (C compiler
332342
option <code>-fsanitize=address</code>).
333343
</p>
334344

345+
<h4 id="go-mod-tidy"><code>go</code> <code>mod</code> <code>tidy</code></h4>
346+
335347
<p><!-- https://golang.org/issue/47738, CL 344572 -->
336348
The <code>go</code> <code>mod</code> <code>tidy</code> command now retains
337349
additional checksums in the <code>go.sum</code> file for modules whose source
@@ -342,6 +354,8 @@ <h3 id="go-command">Go command</h3>
342354
module's <code>go.mod</code> file.
343355
</p>
344356

357+
<h4 id="go-work"><code>go</code> <code>work</code></h4>
358+
345359
<p><!-- https://golang.org/issue/45713 -->
346360
The <code>go</code> command now supports a "Workspace" mode. If a
347361
<code>go.work</code> file is found in the working directory or a
@@ -355,6 +369,8 @@ <h3 id="go-command">Go command</h3>
355369
documentation.
356370
</p>
357371

372+
<h4 id="go-test"><code>go</code> <code>test</code></h4>
373+
358374
<p><!-- CL 251441 -->
359375
The <code>go</code> command now supports additional command line
360376
options for the new <a href="#fuzzing">fuzzing support described
@@ -376,19 +392,36 @@ <h3 id="go-command">Go command</h3>
376392
</ul>
377393
</p>
378394

395+
<h4 id="go-build-lines"><code>//go:build</code> lines</h4>
396+
379397
<p><!-- CL 240611 -->
380-
TODO: <a href="https://golang.org/cl/240611">https://golang.org/cl/240611</a>: 240611: cmd/fix: add buildtag fix
398+
Go 1.17 introduced <code>//go:build</code> lines as a more readable way to write build constraints,
399+
instead of <code>//</code> <code>+build</code> lines.
400+
As of Go 1.17, <code>gofmt</code> adds <code>//go:build</code> lines
401+
to match existing <code>+build</code> lines and keeps them in sync,
402+
while <code>go</code> <code>vet</code> diagnoses when they are out of sync.
403+
</p>
404+
405+
<p>Since the release of Go 1.18 marks the end of support for Go 1.16,
406+
all supported versions of Go now understand <code>//go:build</code> lines.
407+
In Go 1.18, <code>go</code> <code>fix</code> now removes the now-obsolete
408+
<code>//</code> <code>+build</code> lines in modules declaring
409+
<code>go</code> <code>1.17</code> or later in their <code>go.mod</code> files.
410+
</p>
411+
412+
<p>
413+
For more information, see <a href="https://go.dev/design/draft-gobuild">https://go.dev/design/draft-gobuild</a>.
381414
</p>
382415

383-
<h3 id="gofmt"><code>gofmt</code></h3>
416+
<h3 id="gofmt">Gofmt</h3>
384417

385418
<p><!-- https://golang.org/issue/43566 -->
386419
<code>gofmt</code> now reads and formats input files concurrently, with a
387420
memory limit proportional to <code>GOMAXPROCS</code>. On a machine with
388421
multiple CPUs, <code>gofmt</code> should now be significantly faster.
389422
</p>
390423

391-
<h3 id="vet"><code>vet</code></h3>
424+
<h3 id="vet">Vet</h3>
392425

393426
<h4 id="vet-generics">Updates for Generics</h4>
394427

@@ -510,10 +543,17 @@ <h2 id="linker">Linker</h2>
510543
new <code>go</code> command <code>-asan</code> option.
511544
</p>
512545

513-
<h2 id="build">Build</h2>
546+
<h2 id="bootstrap">Bootstrap</h2>
514547

515548
<p><!-- CL 369914, CL 370274 -->
516-
TODO: <a href="https://golang.org/cl/369914">https://golang.org/cl/369914</a>: for default bootstrap, use Go 1.17 if present, falling back to Go 1.4
549+
When building a Go release from source and <code>GOROOT_BOOTSTRAP</code>
550+
is not set, previous versions of Go looked for a Go 1.4 or later bootstrap toolchain
551+
in the directory <code>$HOME/go1.4</code> (<code>%HOMEDRIVE%%HOMEPATH%\go1.4</code> on Windows).
552+
Go now looks first for <code>$HOME/go1.17</code> or <code>$HOME/sdk/go1.17</code>
553+
before falling back to <code>$HOME/go1.4</code>.
554+
We intend for Go 1.19 to require Go 1.17 or later for bootstrap,
555+
and this change should make the transition smoother.
556+
For more details, see <a href="https://go.dev/issue/44505">go.dev/issue/44505</a>.
517557
</p>
518558

519559
<h2 id="library">Core library</h2>

0 commit comments

Comments
 (0)