]> Cypherpunks.ru repositories - gostls13.git/blob - doc/go1.21.html
spec: remove unnecessary sentence
[gostls13.git] / doc / go1.21.html
1 <!--{
2         "Title": "Go 1.21 Release Notes",
3         "Path":  "/doc/go1.21"
4 }-->
5
6 <!--
7 NOTE: In this document and others in this directory, the convention is to
8 set fixed-width phrases with non-fixed-width spaces, as in
9 <code>hello</code> <code>world</code>.
10 Do not send CLs removing the interior tags from such phrases.
11 -->
12
13 <style>
14   main ul li { margin: 0.5em 0; }
15 </style>
16
17 <h2 id="introduction">DRAFT RELEASE NOTES — Introduction to Go 1.21</h2>
18
19 <p>
20   <strong>
21     Go 1.21 is not yet released. These are work-in-progress
22     release notes. Go 1.21 is expected to be released in August 2023.
23   </strong>
24 </p>
25
26 <p>
27   The latest Go release, version 1.21, arrives six months after <a href="/doc/go1.20">Go 1.20</a>.
28   Most of its changes are in the implementation of the toolchain, runtime, and libraries.
29   As always, the release maintains the Go 1 <a href="/doc/go1compat">promise of compatibility</a>;
30   in fact, Go 1.21 <a href="#godebug">improves upon that promise</a>.
31   We expect almost all Go programs to continue to compile and run as before.
32 </p>
33
34 <p><!-- https://go.dev/issue/57631 -->
35   Go 1.21 introduces a small change to the numbering of releases.
36   In the past, we used Go 1.<i>N</i> to refer to both the overall Go language version and release family
37   as well as the first release in that family.
38   Starting in Go 1.21, the first release is now Go 1.<i>N</i>.0.
39   Today we are releasing both the Go 1.21 language and its initial implementation, the Go 1.21.0 release.
40   These notes refer to “Go 1.21”; tools like <code>go</code> <code>version</code> will report “<code>go1.21.0</code>”
41   (until you upgrade to Go 1.21.1).
42   See “<a href="/doc/toolchain#versions">Go versions</a>” in the “Go Toolchains” documentation for details
43   about the new version numbering.
44 </p>
45
46 <h2 id="language">Changes to the language</h2>
47
48 <p>
49   Go 1.21 adds three new built-ins to the language.
50
51   <ul>
52     <li><!-- https://go.dev/issue/59488 -->
53       The new functions <code>min</code> and <code>max</code> compute the
54       smallest (or largest, for <code>max</code>) value of a fixed number
55       of given arguments.
56       See the language spec for
57       <a href="https://tip.golang.org/ref/spec#Min_and_max">details</a>.
58     </li>
59     <li><!-- https://go.dev/issue/56351 -->
60       The new function <code>clear</code> deletes all elements from a
61       map or zeroes all elements of a slice.
62       See the language spec for
63       <a href="https://tip.golang.org/ref/spec#Clear">details</a>.
64     </li>
65   </ul>
66 </p>
67
68 <p><!-- https://go.dev/issue/57411 -->
69   Package initialization order is now specified more precisely. The
70   new algorithm is:
71   <ul>
72     <li>
73       Sort all packages by import path.
74     </li>
75     <li>Repeat until the list of packages is empty:
76       <ul>
77         <li>
78           Find the first package in the list for which all imports are
79           already initialized.
80         </li>
81         <li>
82           Initialize that package and remove it from the list.
83         </li>
84       </ul>
85     </li>
86   </ul>
87   This may change the behavior of some programs that rely on a
88   specific initialization ordering that was not expressed by explicit
89   imports. The behavior of such programs was not well defined by the
90   spec in past releases. The new rule provides an unambiguous definition.
91 </p>
92
93 <p>
94   Multiple improvements that increase the power and precision of type inference have been made.
95 </p>
96 <ul>
97   <li><!-- https://go.dev/issue/59338 -->
98     A (possibly partially instantiated generic) function may now be called with arguments that are
99     themselves (possibly partially instantiated) generic functions.
100     The compiler will attempt to infer the missing type arguments of the callee (as before) and,
101     for each argument that is a generic function that is not fully instantiated,
102     its missing type arguments (new).
103     Typical use cases are calls to generic functions operating on containers
104     (such as <a href="/pkg/slices#IndexFunc">slices.IndexFunc</a>) where a function argument
105     may also be generic, and where the type argument of the called function and its arguments
106     are inferred from the container type.
107     More generally, a generic function may now be used without explicit instantiation when
108     it is assigned to a variable or returned as a result value if the type arguments can
109     be inferred from the assignment.
110   </li>
111   <li><!-- https://go.dev/issue/60353, https://go.dev/issue/57192, https://go.dev/issue/52397, https://go.dev/issue/41176 -->
112     Type inference now also considers methods when a value is assigned to an interface:
113     type arguments for type parameters used in method signatures may be inferred from
114     the corresponding parameter types of matching methods.
115   </li>
116   <li><!-- https://go.dev/issue/51593 https://go.dev/issue/39661 -->
117     Similarly, since a type argument must implement all the methods of its corresponding constraint,
118     the methods of the type argument and constraint are matched which may lead to the inference of
119     additional type arguments.
120   </li>
121   <li><!-- https://go.dev/issue/58671 -->
122     If multiple untyped constant arguments of different kinds (such as an untyped int and
123     an untyped floating-point constant) are passed to parameters with the same (not otherwise
124     specified) type parameter type, instead of an error, now type inference determines the
125     type using the same approach as an operator with untyped constant operands.
126     This change brings the types inferred from untyped constant arguments in line with the
127     types of constant expressions.
128   </li>
129   <li><!-- https://go.dev/issue/59750 -->
130     Type inference is now precise when matching corresponding types in assignments:
131     component types (such as the elements of slices, or the parameter types in function signatures)
132     must be identical (given suitable type arguments) to match, otherwise inference fails.
133     This change produces more accurate error messages:
134     where in the past type inference may have succeeded incorrectly and lead to an invalid assignment,
135     the compiler now reports an inference error if two types can't possibly match.
136   </li>
137 </ul>
138
139 <p><!-- https://go.dev/issue/58650 -->
140   More generally, the description of
141   <a href="https://tip.golang.org/ref/spec#Type_inference">type inference</a>
142   in the language spec has been clarified.
143   Together, all these changes make type inference more powerful and inference failures less surprising.
144 </p>
145
146 <!-- https://go.dev/issue/57969 -->
147 <p>
148   Go 1.21 includes a preview of a language change we are considering for a future version of Go:
149   making for loop variables per-iteration instead of per-loop, to avoid accidental sharing bugs.
150   For details about how to try that language change, see <a href="https://go.dev/wiki/LoopvarExperiment">the LoopvarExperiment wiki page</a>.
151 </p>
152
153 <h2 id="tools">Tools</h2>
154 <p>
155   Go 1.21 adds improved support for backwards compatibility and forwards compatibility
156   in the Go toolchain.
157 </p>
158
159 <p><!-- https://go.dev/issue/56986 -->
160   To improve backwards compatibility, Go 1.21 formalizes
161   Go's use of the GODEBUG environment variable to control
162   the default behavior for changes that are non-breaking according to the
163   <a href="/doc/go1compat">compatibility policy</a>
164   but nonetheless may cause existing programs to break.
165   (For example, programs that depend on buggy behavior may break
166   when a bug is fixed, but bug fixes are not considered breaking changes.)
167   When Go must make this kind of behavior change,
168   it now chooses between the old and new behavior based on the
169   <code>go</code> line in the workspace's <code>go.work</code> file
170   or else the main module's <code>go.mod</code> file.
171   Upgrading to a new Go toolchain but leaving the <code>go</code> line
172   set to its original (older) Go version preserves the behavior of the older
173   toolchain.
174   With this compatibility support, the latest Go toolchain should always
175   be the best, most secure, implementation of an older version of Go.
176   See “<a href="/doc/godebug">Go, Backwards Compatibility, and GODEBUG</a>” for details.
177 </p>
178
179 <p><!-- https://go.dev/issue/57001 -->
180   To improve forwards compatibility, Go 1.21 now reads the <code>go</code> line
181   in a <code>go.work</code> or <code>go.mod</code> file as a strict
182   minimum requirement: <code>go</code> <code>1.21.0</code> means
183   that the workspace or module cannot be used with Go 1.20 or with Go 1.21rc1.
184   This allows projects that depend on fixes made in later versions of Go
185   to ensure that they are not used with earlier versions.
186   It also gives better error reporting for projects that make use of new Go features:
187   when the problem is that a newer Go version is needed,
188   that problem is reported clearly, instead of attempting to build the code
189   and instead printing errors about unresolved imports or syntax errors.
190 </p>
191
192 <p>
193   To make these new stricter version requirements easier to manage,
194   the <code>go</code> command can now invoke not just the toolchain
195   bundled in its own release but also other Go toolchain versions found in the PATH
196   or downloaded on demand.
197   If a <code>go.mod</code> or <code>go.work</code> <code>go</code> line
198   declares a minimum requirement on a newer version of Go, the <code>go</code>
199   command will find and run that version automatically.
200   The new <code>toolchain</code> directive sets a suggested minimum toolchain to use,
201   which may be newer than the strict <code>go</code> minimum.
202   See “<a href="/doc/toolchain">Go Toolchains</a>” for details.
203 </p>
204
205 <h3 id="go-command">Go command</h3>
206
207 <p><!-- https://go.dev/issue/58099, CL 474236 -->
208   The <code>-pgo</code> build flag now defaults to <code>-pgo=auto</code>,
209   and the restriction of specifying a single main package on the command
210   line is now removed. If a file named <code>default.pgo</code> is present
211   in the main package's directory, the <code>go</code> command will use
212   it to enable profile-guided optimization for building the corresponding
213   program.
214 </p>
215
216 <p>
217   The <code>-C</code> <code>dir</code> flag must now be the first
218   flag on the command-line when used.
219 </p>
220
221 <p><!-- https://go.dev/issue/37708, CL 463837 -->
222   The new <code>go</code> <code>test</code> option
223   <code>-fullpath</code> prints full path names in test log messages,
224   rather than just base names.
225 </p>
226
227 <p><!-- https://go.dev/issue/15513, CL 466397 -->
228   The <code>go</code> <code>test</code> <code>-c</code> flag now
229   supports writing test binaries for multiple packages, each to
230   <code>pkg.test</code> where <code>pkg</code> is the package name.
231   It is an error if more than one test package being compiled has a given package name.]
232 </p>
233
234 <p><!-- https://go.dev/issue/15513, CL 466397 -->
235   The <code>go</code> <code>test</code> <code>-o</code> flag now
236   accepts a directory argument, in which case test binaries are written to that
237   directory instead of the current directory.
238 </p>
239
240 <h3 id="cgo">Cgo</h3>
241
242 <p><!-- CL 490819 -->
243   In files that <code>import "C"</code>, the Go toolchain now
244   correctly reports errors for attempts to declare Go methods on C types.
245 </p>
246
247 <h2 id="runtime-changes">Runtime</h2>
248
249 <p><!-- https://go.dev/issue/7181 -->
250   When printing very deep stacks, the runtime now prints the first 50
251   (innermost) frames followed by the bottom 50 (outermost) frames,
252   rather than just printing the first 100 frames. This makes it easier
253   to see how deeply recursive stacks started, and is especially
254   valuable for debugging stack overflows.
255 </p>
256
257 <p><!-- https://go.dev/issue/59960 -->
258   On Linux platforms that support transparent huge pages, the Go runtime
259   now manages which parts of the heap may be backed by huge pages more
260   explicitly. This leads to better utilization of memory: small heaps
261   should see less memory used (up to 50% in pathological cases) while
262   large heaps should see fewer broken huge pages for dense parts of the
263   heap, improving CPU usage and latency by up to 1%.
264 </p>
265
266 <p><!-- https://go.dev/issue/57069, https://go.dev/issue/56966 -->
267   As a result of runtime-internal garbage collection tuning,
268   applications may see up to a 40% reduction in application tail latency
269   and a small decrease in memory use. Some applications may also observe
270   a small loss in throughput.
271
272   The memory use decrease should be proportional to the loss in
273   throughput, such that the previous release's throughput/memory
274   tradeoff may be recovered (with little change to latency) by
275   increasing <code>GOGC</code> and/or <code>GOMEMLIMIT</code> slightly.
276 </p>
277
278 <p><!-- https://go.dev/issue/51676 -->
279   Calls from C to Go on threads created in C require some setup to prepare for
280   Go execution. On Unix platforms, this setup is now preserved across multiple
281   calls from the same thread. This significantly reduces the overhead of
282   subsequent C to Go calls from ~1-3 microseconds per call to ~100-200
283   nanoseconds per call.
284 </p>
285
286 <h2 id="compiler">Compiler</h2>
287
288 <p>
289   Profile-guide optimization (PGO), added as a preview in Go 1.20, is now ready
290   for general use. PGO enables additional optimizations on code identified as
291   hot by profiles of production workloads. As mentioned in the
292   <a href="#go-command">Go command section</a>, PGO is enabled by default for
293   binaries that contain a <code>default.pgo</code> profile in the main
294   package directory. Performance improvements vary depending on application
295   behavior, with most programs from a representative set of Go programs seeing
296   between 2 and 7% improvement from enabling PGO. See the
297   <a href="/doc/pgo">PGO user guide</a> for detailed documentation.
298 </p>
299
300 <!-- https://go.dev/issue/59959 -->
301 <p>
302   PGO builds can now devirtualize some interface method calls, adding a
303   concrete call to the most common callee. This enables further optimization,
304   such as inlining the callee.
305 </p>
306
307 <!-- CL 497455 -->
308 <p>
309   Go 1.21 improves build speed by up to 6%, largely thanks to building the
310   compiler itself with PGO.
311 </p>
312
313 <h2 id="assembler">Assembler</h2>
314
315 <!-- https://go.dev/issue/58378 -->
316 <p>
317   On amd64, frameless nosplit assembly functions are no longer automatically marked as <code>NOFRAME</code>.
318   Instead, the <code>NOFRAME</code> attribute must be explicitly specified if desired,
319   which is already the behavior on other architectures supporting frame pointers.
320   With this, the runtime now maintains the frame pointers for stack transitions.
321 </p>
322
323 <!-- CL 476295 -->
324 <p>
325   The verifier that checks for incorrect uses of <code>R15</code> when dynamic linking on amd64 has been improved.
326 </p>
327
328 <h2 id="linker">Linker</h2>
329
330 <p><!-- https://go.dev/issue/57302, CL 461749, CL 457455 -->
331   On windows/amd64, the linker (with help from the compiler) now emits
332   SEH unwinding data by default, which improves the integration
333   of Go applications with Windows debuggers and other tools.
334 </p>
335
336 <!-- CL 463395, CL 461315 -->
337 <p>
338   In Go 1.21 the linker (with help from the compiler) is now capable of
339   deleting dead (unreferenced) global map variables, if the number of
340   entries in the variable initializer is sufficiently large, and if the
341   initializer expressions are side-effect free.
342 </p>
343
344 <h2 id="library">Core library</h2>
345
346 <h3 id="slog">New log/slog package</h3>
347
348 <p><!-- https://go.dev/issue/59060, https://go.dev/issue/59141, https://go.dev/issue/59204, https://go.dev/issue/59280,
349         https://go.dev/issue/59282, https://go.dev/issue/59339, https://go.dev/issue/59345, https://go.dev/issue/61200,
350         CL 477295, CL 484096, CL 486376, CL 486415, CL 487855, CL 508195 -->
351   The new <a href="/pkg/log/slog">log/slog</a> package provides structured logging with levels.
352   Structured logging emits key-value pairs
353   to enable fast, accurate processing of large amounts of log data.
354   The package supports integration with popular log analysis tools and services.
355 </p>
356
357 <h3 id="slogtest">New testing/slogtest package</h3>
358
359 <p><!-- CL 487895 -->
360   The new <a href="/pkg/testing/slogtest">testing/slogtest</a> package can help
361   to validate <a href="/pkg/log/slog#Handler">slog.Handler</a> implementations.
362 </p>
363
364 <h3 id="slices">New slices package</h3>
365
366 <p>
367   <!-- https://go.dev/issue/45955, https://go.dev/issue/54768 -->
368   <!-- https://go.dev/issue/57348, https://go.dev/issue/57433 -->
369   <!-- https://go.dev/issue/58565, https://go.dev/issue/60091 -->
370   <!-- https://go.dev/issue/60546 -->
371   <!-- CL 467417, CL 468855, CL 483175, CL 496078, CL 498175, CL 502955 -->
372   The new <a href="/pkg/slices">slices</a> package provides many common
373   operations on slices, using generic functions that work with slices
374   of any element type.
375 </p>
376
377 <h3 id="maps">New maps package</h3>
378
379 <p><!-- https://go.dev/issue/57436, CL 464343 -->
380   The new <a href="/pkg/maps/">maps</a> package provides several
381   common operations on maps, using generic functions that work with
382   maps of any key or element type.
383 </p>
384
385 <h3 id="cmp">New cmp package</h3>
386
387 <p><!-- https://go.dev/issue/59488, CL 496356 -->
388   The new <a href="/pkg/cmp/">cmp</a> package defines the type
389   constraint <a href="/pkg/cmp/#Ordered"><code>Ordered</code></a> and
390   two new generic functions
391   <a href="/pkg/cmp/#Less"><code>Less</code></a>
392   and <a href="/pkg/cmp/#Compare"><code>Compare</code></a> that are
393   useful with <a href="/ref/spec/#Comparison_operators">ordered
394   types</a>.
395 </p>
396
397 <h3 id="minor_library_changes">Minor changes to the library</h3>
398
399 <p>
400   As always, there are various minor changes and updates to the library,
401   made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a>
402   in mind.
403   There are also various performance improvements, not enumerated here.
404 </p>
405
406 <dl id="archive/tar"><dt><a href="/pkg/archive/tar/">archive/tar</a></dt>
407   <dd>
408     <p><!-- https://go.dev/issue/54451, CL 491175 -->
409       The implementation of the
410       <a href="/pkg/io/fs/#FileInfo"><code>io/fs.FileInfo</code></a>
411       interface returned by
412       <a href="/pkg/archive/tar/#Header.FileInfo"><code>Header.FileInfo</code></a>
413       now implements a <code>String</code> method that calls
414       <a href="/pkg/io/fs/#FormatFileInfo"><code>io/fs.FormatFileInfo</code></a>.
415     </p>
416   </dd>
417 </dl><!-- archive/tar -->
418
419 <dl id="archive/zip"><dt><a href="/pkg/archive/zip/">archive/zip</a></dt>
420   <dd>
421     <p><!-- https://go.dev/issue/54451, CL 491175 -->
422       The implementation of the
423       <a href="/pkg/io/fs/#FileInfo"><code>io/fs.FileInfo</code></a>
424       interface returned by
425       <a href="/pkg/archive/zip/#FileHeader.FileInfo"><code>FileHeader.FileInfo</code></a>
426       now implements a <code>String</code> method that calls
427       <a href="/pkg/io/fs/#FormatFileInfo"><code>io/fs.FormatFileInfo</code></a>.
428     </p>
429
430     <p><!-- https://go.dev/issue/54451, CL 491175 -->
431       The implementation of the
432       <a href="/pkg/io/fs/#DirEntry"><code>io/fs.DirEntry</code></a>
433       interface returned by the
434       <a href="/pkg/io/fs/#ReadDirFile.ReadDir"><code>io/fs.ReadDirFile.ReadDir</code></a>
435       method of the
436       <a href="/pkg/io/fs/#File"><code>io/fs.File</code></a>
437       returned by
438       <a href="/pkg/archive/zip/#Reader.Open"><code>Reader.Open</code></a>
439       now implements a <code>String</code> method that calls
440       <a href="/pkg/io/fs/#FormatDirEntry"><code>io/fs.FormatDirEntry</code></a>.
441     </p>
442   </dd>
443 </dl><!-- archive/zip -->
444
445 <dl id="bytes"><dt><a href="/pkg/bytes/">bytes</a></dt>
446   <dd>
447     <p><!-- https://go.dev/issue/53685, CL 474635 -->
448       The <a href="/pkg/bytes/#Buffer"><code>Buffer</code></a> type
449       has two new methods:
450       <a href="/pkg/bytes/#Buffer.Available"><code>Available</code></a>
451       and <a href="/pkg/bytes/#AvailableBuffer"><code>AvailableBuffer</code></a>.
452       These may be used along with the
453       <a href="/pkg/bytes/#Buffer.Write"><code>Write</code></a>
454       method to append directly to the <code>Buffer</code>.
455     </p>
456   </dd>
457 </dl><!-- bytes -->
458
459 <dl id="context"><dt><a href="/pkg/context/">context</a></dt>
460   <dd>
461     <p><!-- https://go.dev/issue/40221, CL 479918 -->
462       The new <a href="/pkg/context/#WithoutCancel"><code>WithoutCancel</code></a>
463       function returns a copy of a context that is not canceled when the original
464       context is canceled.
465     </p>
466     <p><!-- https://go.dev/issue/56661, CL 449318 -->
467       The new <a href="/pkg/context/#WithDeadlineCause"><code>WithDeadlineCause</code></a>
468       and <a href="/pkg/context/#WithTimeoutCause"><code>WithTimeoutCause</code></a>
469       functions provide a way to set a context cancellation cause when a deadline or
470       timer expires. The cause may be retrieved with the
471       <a href="/pkg/context/#Cause"><code>Cause</code></a> function.
472     </p>
473     <p><!-- https://go.dev/issue/57928, CL 482695 -->
474       The new <a href="/pkg/context/#AfterFunc"><code>AfterFunc</code></a>
475       function registers a function to run after a context has been cancelled.
476     </p>
477
478     <p><!-- CL 455455 -->
479       An optimization means that the results of calling
480       <a href="/pkg/context/#Background"><code>Background</code></a>
481       and <a href="/pkg/context/#TODO"><code>TODO</code></a> and
482       converting them to a shared type can be considered equal.
483       In previous releases they were always different.  Comparing
484       <a href="/pkg/context/#Context"><code>Context</code></a> values
485       for equality has never been well-defined, so this is not
486       considered to be an incompatible change.
487     </p>
488   </dd>
489 </dl>
490
491 <dl id="crypto/elliptic"><dt><a href="/pkg/crypto/elliptic/">crypto/elliptic</a></dt>
492   <dd>
493     <p><!-- CL 459977 -->
494       All of the <a href="/pkg/crypto/elliptic/#Curve"><code>Curve</code></a> methods have been deprecated, along with <a href="/pkg/crypto/elliptic/#GenerateKey"><code>GenerateKey</code></a>, <a href="/pkg/crypto/elliptic/#Marshal"><code>Marshal</code></a>, and <a href="/pkg/crypto/elliptic/#Unmarshal"><code>Unmarshal</code></a>. For ECDH operations, the new <a href="/pkg/crypto/ecdh/"><code>crypto/ecdh</code></a> package should be used instead. For lower-level operations, use third-party modules such as <a href="https://pkg.go.dev/filippo.io/nistec">filippo.io/nistec</a>.
495     </p>
496   </dd>
497 </dl><!-- crypto/elliptic -->
498
499 <dl id="crypto/rand"><dt><a href="/pkg/crypto/rand/">crypto/rand</a></dt>
500   <dd>
501     <p><!-- CL 463123 -->
502       The <a href="/pkg/crypto/rand/"><code>crypto/rand</code></a> package now uses the <code>getrandom</code> system call on NetBSD 10.0 and later.
503     </p>
504   </dd>
505 </dl><!-- crypto/rand -->
506
507 <dl id="crypto/rsa"><dt><a href="/pkg/crypto/rsa/">crypto/rsa</a></dt>
508   <dd>
509     <p><!-- CL 471259, CL 492935 -->
510       The performance of private RSA operations (decryption and signing) is now better than Go 1.19 for <code>GOARCH=amd64</code> and <code>GOARCH=arm64</code>. It had regressed in Go 1.20.
511     </p>
512     <p>
513       Due to the addition of private fields to <a href="/pkg/crypto/rsa/#PrecomputedValues"><code>PrecomputedValues</code></a>, <a href="/pkg/crypto/rsa/#PrivateKey.Precompute"><code>PrivateKey.Precompute</code></a> must be called for optimal performance even if deserializing (for example from JSON) a previously-precomputed private key.
514     </p>
515     <p><!-- https://go.dev/issue/56921, CL 459976 -->
516       The <a href="/pkg/crypto/rsa/#GenerateMultiPrimeKey"><code>GenerateMultiPrimeKey</code></a> function and the <a href="/pkg/crypto/rsa/#PrecomputedValues.CRTValues"><code>PrecomputedValues.CRTValues</code></a> field have been deprecated. <a href="/pkg/crypto/rsa/#PrecomputedValues.CRTValues"><code>PrecomputedValues.CRTValues</code></a> will still be populated when <a href="/pkg/crypto/rsa/#PrivateKey.Precompute"><code>PrivateKey.Precompute</code></a> is called, but the values will not be used during decryption operations.
517     </p>
518   </dd>
519 </dl><!-- crypto/rsa -->
520
521 <!-- CL 483815 reverted -->
522
523 <dl id="crypto/sha256"><dt><a href="/pkg/crypto/sha256/">crypto/sha256</a></dt>
524   <dd>
525     <p><!-- https://go.dev/issue/50543, CL 408795 -->
526       SHA-224 and SHA-256 operations now use native instructions when available when <code>GOARCH=amd64</code>, providing a performance improvement on the order of 3-4x.
527     </p>
528   </dd>
529 </dl><!-- crypto/sha256 -->
530
531 <!-- CL 481478 reverted -->
532 <!-- CL 483816 reverted -->
533
534 <dl id="crypto/tls"><dt><a href="/pkg/crypto/tls/">crypto/tls</a></dt>
535   <dd>
536     <p><!-- https://go.dev/issue/60105, CL 496818, CL 496820, CL 496822, CL 496821, CL 501675 -->
537       Applications can now control the content of session tickets.
538       <ul>
539         <li>
540           The new <a href="/pkg/crypto/tls/#SessionState"><code>SessionState</code></a> type
541           describes a resumable session.
542         </li>
543         <li>
544           The <a href="/pkg/crypto/tls/#SessionState.Bytes"><code>SessionState.Bytes</code></a>
545           method and <a href="/pkg/crypto/tls/#ParseSessionState"><code>ParseSessionState</code></a>
546           function serialize and deserialize a <code>SessionState</code>.
547         </li>
548         <li>
549           The <a href="/pkg/crypto/tls/#Config.WrapSession"><code>Config.WrapSession</code></a> and
550           <a href="/pkg/crypto/tls/#Config.UnwrapSession"><code>Config.UnwrapSession</code></a>
551           hooks convert a <code>SessionState</code> to and from a ticket.
552         </li>
553         <li>
554           The <a href="/pkg/crypto/tls/#Config.EncryptTicket"><code>Config.EncryptTicket</code></a>
555           and <a href="/pkg/crypto/tls/#Config.DecryptTicket"><code>Config.DecryptTicket</code></a>
556           methods provide a default implementation of <code>WrapSession</code> and
557           <code>UnwrapSession</code>.
558         </li>
559         <li>
560           The <a href="/pkg/crypto/tls/#ClientSessionState.ResumptionState"><code>ClientSessionState.ResumptionState</code></a> method and
561           <a href="/pkg/crypto/tls/#NewResumptionState"><code>NewResumptionState</code></a> function
562           may be used by a <code>ClientSessionCache</code> implementation to store and
563           resume sessions.
564         </li>
565       </ul>
566     </p>
567
568     <p><!-- CL 497376 -->
569       The package now supports the extended master secret extension (RFC 7627),
570       and enables it by default. Additionally, the deprecation of
571       <a href="/pkg/crypto/tls/#ConnectionState.TLSUnique"><code>ConnectionState.TLSUnique</code></a>
572       has been reverted, and it is populated when a connection which uses
573       extended master secret is resumed. Session tickets produced by
574       Go pre-1.21 are not interoperable with Go 1.21, meaning connections
575       resumed across versions will fall back to full handshakes.
576     </p>
577
578     <p><!-- https://go.dev/issue/44886, https://go.dev/issue/60107, CL 493655, CL 496995 -->
579       The new <a href="/pkg/crypto/tls/#QUICConn"><code>QUICConn</code></a> type
580       provides support for QUIC implementations. Note that this is not itself
581       a QUIC implementation.
582     </p>
583
584     <p><!-- https://go.dev/issue/46308, CL 497377 -->
585       The new <a href="/pkg/crypto/tls/#VersionName"><code>VersionName</code></a> function
586       returns the name for a TLS version number.
587     </p>
588
589     <p><!-- https://go.dev/issue/52113, CL 410496 -->
590       The TLS alert codes sent from the server for client authentication failures have
591       been improved. Prior to Go 1.21, these failures always resulted in a "bad certificate" alert.
592       Starting from Go 1.21, certain failures will result in more appropriate alert codes,
593       as defined by RFC 5246 and RFC 8446:
594       <ul>
595         <li>
596           For TLS 1.3 connections, if the server is configured to require client authentication using
597           <a href="/pkg/crypto/tls/#RequireAnyClientCert"></code>RequireAnyClientCert</code></a> or
598           <a href="/pkg/crypto/tls/#RequireAndVerifyClientCert"></code>RequireAndVerifyClientCert</code></a>,
599           and the client does not provide any certificate, the server will now return the "certificate required" alert.
600         </li>
601         <li>
602           If the client provides a certificate that is not signed by the set of trusted certificate authorities
603           configured on the server, the server will return the "unknown certificate authority" alert.
604         </li>
605         <li>
606           If the client provides a certificate that is either expired or not yet valid,
607           the server will return the "expired certificate" alert.
608         </li>
609         <li>
610           In all other scenarios related to client authentication failures, the server still returns "bad certificate".
611         </li>
612       </ul>
613     </p>
614   </dd>
615 </dl><!-- crypto/tls -->
616
617 <dl id="crypto/x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt>
618   <dd>
619     <p><!-- https://go.dev/issue/53573, CL 468875 -->
620       <a href="/pkg/crypto/x509/#RevocationList.RevokedCertificates"><code>RevocationList.RevokedCertificates</code></a> has been deprecated and replaced with the new <a href="/pkg/crypto/x509/#RevocationList.RevokedCertificateEntries"><code>RevokedCertificateEntries</code></a> field, which is a slice of <a href="/pkg/crypto/x509/#RevocationListEntry"><code>RevocationListEntry</code></a>. <a href="/pkg/crypto/x509/#RevocationListEntry"><code>RevocationListEntry</code></a> contains all of the fields in <a href="/pkg/crypto/x509/pkix#RevokedCertificate"><code>pkix.RevokedCertificate</code></a>, as well as the revocation reason code.
621     </p>
622   </dd>
623 </dl><!-- crypto/x509 -->
624
625 <dl id="debug/elf"><dt><a href="/pkg/debug/elf/">debug/elf</a></dt>
626   <dd>
627     <p><!-- https://go.dev/issue/56892, CL 452617 -->
628       The new
629       <a href="/pkg/debug/elf/#File.DynValue"><code>File.DynValue</code></a>
630       method may be used to retrieve the numeric values listed with a
631       given dynamic tag.
632     </p>
633
634     <p><!-- https://go.dev/issue/56887, CL 452496 -->
635       The constant flags permitted in a <code>DT_FLAGS_1</code>
636       dynamic tag are now defined with type
637       <a href="/pkg/debug/elf/#DynFlag1"><code>DynFlag1</code></a>. These
638       tags have names starting with <code>DF_1</code>.
639     </p>
640
641     <p><!-- CL 473256 -->
642       The package now defines the constant
643       <a href="/pkg/debug/elf/#COMPRESS_ZSTD"><code>COMPRESS_ZSTD</code></a>.
644     </p>
645
646     <p><!-- https://go.dev/issue/60348, CL 496918 -->
647       The package now defines the constant
648       <a href="/pkg/debug/elf/#R_PPC64_REL24_P9NOTOC"><code>R_PPC64_REL24_P9NOTOC</code></a>.
649     </p>
650   </dd>
651 </dl><!-- debug/elf -->
652
653 <dl id="debug/pe"><dt><a href="/pkg/debug/pe/">debug/pe</a></dt>
654   <dd>
655     <p><!-- CL 488475 -->
656       Attempts to read from a section containing uninitialized data
657       using
658       <a href="/pkg/debug/pe/#Section.Data"><code>Section.Data</code></a>
659       or the reader returned by <a href="/pkg/debug/pe/#Section.Open"><code>Section.Open</code></a>
660       now return an error.
661     </p>
662   </dd>
663 </dl><!-- debug/pe -->
664
665 <dl id="embed"><dt><a href="/pkg/embed/">embed</a></dt>
666   <dd>
667     <p><!-- https://go.dev/issue/57803, CL 483235 -->
668       The <a href="/pkg/io/fs/#File"><code>io/fs.File</code></a>
669       returned by
670       <a href="/pkg/embed/#FS.Open"><code>FS.Open</code></a> now
671       has a <code>ReadAt</code> method that
672       implements <a href="/pkg/io/#ReaderAt"><code>io.ReaderAt</code></a>.
673     </p>
674
675     <p><!-- https://go.dev/issue/54451, CL 491175 -->
676       Calling <code><a href="/pkg/embed/FS.Open">FS.Open</a>.<a href="/pkg/io/fs/#File.Stat">Stat</a></code>
677       will return a type that now implements a <code>String</code>
678       method that calls
679       <a href="/pkg/io/fs/#FormatFileInfo"><code>io/fs.FormatFileInfo</code></a>.
680     </p>
681   </dd>
682 </dl><!-- embed -->
683
684 <dl id="errors"><dt><a href="/pkg/errors/">errors</a></dt>
685   <dd>
686     <p><!-- https://go.dev/issue/41198, CL 473935 -->
687       The new
688       <a href="/pkg/errors/#ErrUnsupported"><code>ErrUnsupported</code></a>
689       error provides a standardized way to indicate that a requested
690       operation may not be performed because it is unsupported.
691       For example, a call to
692       <a href="/pkg/os/#Link"><code>os.Link</code></a> when using a
693       file system that does not support hard links.
694     </p>
695   </dd>
696 </dl><!-- errors -->
697
698 <dl id="flag"><dt><a href="/pkg/flag/">flag</a></dt>
699   <dd>
700     <p><!-- https://go.dev/issue/53747, CL 476015 -->
701       The new <a href="/pkg/flag/#BoolFunc"><code>BoolFunc</code></a>
702       function and
703       <a href="/pkg/flag/#FlagSet.BoolFunc"><code>FlagSet.BoolFunc</code></a>
704       method define a flag that does not require an argument and calls
705       a function when the flag is used. This is similar to
706       <a href="/pkg/flag/#Func"><code>Func</code></a> but for a
707       boolean flag.
708     </p>
709
710     <p><!-- CL 480215 -->
711       A flag definition
712       (via <a href="/pkg/flag/#Bool"><code>Bool</code></a>,
713       <a href="/pkg/flag/#BoolVar"><code>BoolVar</code></a>,
714       <a href="/pkg/flag/#Int"><code>Int</code></a>,
715       <a href="/pkg/flag/#IntVar"><code>IntVar</code></a>, etc.)
716       will panic if <a href="/pkg/flag/#Set"><code>Set</code></a> has
717       already been called on a flag with the same name. This change is
718       intended to detect cases where <a href="#language">changes in
719       initialization order</a> cause flag operations to occur in a
720       different order than expected. In many cases the fix to this
721       problem is to introduce a explicit package dependence to
722       correctly order the definition before any
723       <a href="/pkg/flag/#Set"><code>Set</code></a> operations.
724     </p>
725   </dd>
726 </dl><!-- flag -->
727
728 <dl id="go/ast"><dt><a href="/pkg/go/ast/">go/ast</a></dt>
729   <dd>
730     <p><!-- https://go.dev/issue/28089, CL 487935 -->
731       The new <a href="/pkg/go/ast/#IsGenerated"><code>IsGenerated</code></a> predicate
732       reports whether a file syntax tree contains the
733       <a href="https://go.dev/s/generatedcode">special comment</a>
734       that conventionally indicates that the file was generated by a tool.
735     </p>
736   </dd>
737
738   <dd>
739     <p><!-- https://go.dev/issue/59033, CL 476276 -->
740       The new
741       <a href="/pkg/go/ast/#File.GoVersion"><code>File.GoVersion</code></a>
742       field records the minimum Go version required by
743       any <code>//go:build</code> or <code>// +build</code>
744       directives.
745     </p>
746   </dd>
747 </dl><!-- go/ast -->
748
749 <dl id="go/build"><dt><a href="/pkg/go/build/">go/build</a></dt>
750   <dd>
751     <p><!-- https://go.dev/issue/56986, CL 453603 -->
752       The package now parses build directives (comments that start
753       with <code>//go:</code>) in file headers (before
754       the <code>package</code> declaration). These directives are
755       available in the new
756       <a href="/pkg/go/build#Package"><code>Package</code></a> fields
757       <a href="/pkg/go/build#Package.Directives"><code>Directives</code></a>,
758       <a href="/pkg/go/build#Package.TestDirectives"><code>TestDirectives</code></a>,
759       and
760       <a href="/pkg/go/build#Package.XTestDirectives"><code>XTestDirectives</code></a>.
761     </p>
762   </dd>
763 </dl><!-- go/build -->
764
765 <dl id="go/build/constraint"><dt><a href="/pkg/go/build/constraint/">go/build/constraint</a></dt>
766   <dd>
767     <p><!-- https://go.dev/issue/59033, CL 476275 -->
768       The new
769       <a href="/pkg/go/build/constraint/#GoVersion"><code>GoVersion</code></a>
770       function returns the minimum Go version implied by a build
771       expression.
772     </p>
773   </dd>
774 </dl><!-- go/build/constraint -->
775
776 <dl id="go/token"><dt><a href="/pkg/go/token/">go/token</a></dt>
777   <dd>
778     <p><!-- https://go.dev/issue/57708, CL 464515 -->
779       The new <a href="/pkg/go/token/#File.Lines"><code>File.Lines</code></a> method
780       returns the file's line-number table in the same form as accepted by
781       <code>File.SetLines</code>.
782     </p>
783   </dd>
784 </dl><!-- go/token -->
785
786 <dl id="go/types"><dt><a href="/pkg/go/types/">go/types</a></dt>
787   <dd>
788     <p><!-- https://go.dev/issue/61175, CL 507975 -->
789       The new <a href="/pkg/go/types/#Package.GoVersion"><code>Package.GoVersion</code></a>
790       method returns the Go language version used to check the package.
791     </p>
792   </dd>
793 </dl><!-- go/types -->
794
795 <dl id="hash/maphash"><dt><a href="/pkg/hash/maphash/">hash/maphash</a></dt>
796   <dd>
797     <p><!-- https://go.dev/issue/47342, CL 468795 -->
798       The <code>hash/maphash</code> package now has a pure Go implementation, selectable with the <code>purego</code> build tag.
799     </p>
800   </dd>
801 </dl><!-- hash/maphash -->
802
803 <dl id="html/template"><dt><a href="/pkg/html/template/">html/template</a></dt>
804   <dd>
805     <p><!-- https://go.dev/issue/59584, CL 496395 -->
806       The new error
807       <a href="/pkg/html/template/#ErrJSTemplate"><code>ErrJSTemplate</code></a>
808       is returned when an action appears in a JavaScript template
809       literal. Previously an unexported error was returned.
810     </p>
811   </dd>
812 </dl><!-- html/template -->
813
814 <dl id="io/fs"><dt><a href="/pkg/io/fs/">io/fs</a></dt>
815   <dd>
816     <p><!-- https://go.dev/issue/54451, CL 489555 -->
817       The new
818       <a href="/pkg/io/fs/#FormatFileInfo"><code>FormatFileInfo</code></a>
819       function returns a formatted version of a
820       <a href="/pkg/io/fs/#FileInfo"><code>FileInfo</code></a>.
821       The new
822       <a href="/pkg/io/fs/#FormatDirEntry"><code>FormatDirEntry</code></a>
823       function returns a formatted version of a
824       <a href="/pkg/io/fs/#FileInfo"><code>DirEntry</code></a>.
825       The implementation of
826       <a href="/pkg/io/fs/#DirEntry"><code>DirEntry</code></a>
827       returned by
828       <a href="/pkg/io/fs/#ReadDir"><code>ReadDir</code></a> now
829       implements a <code>String</code> method that calls
830       <a href="/pkg/io/fs/#FormatDirEntry"><code>FormatDirEntry</code></a>,
831       and the same is true for
832       the <a href="/pkg/io/fs/#DirEntry"><code>DirEntry</code></a>
833       value passed to
834       <a href="/pkg/io/fs/#WalkDirFunc"><code>WalkDirFunc</code></a>.
835     </p>
836   </dd>
837 </dl><!-- io/fs -->
838
839 <!-- https://go.dev/issue/56491 rolled back by https://go.dev/issue/60519 -->
840 <!-- CL 459435 reverted by CL 467255 -->
841 <!-- CL 467515 reverted by CL 499416 -->
842
843 <dl id="math/big"><dt><a href="/pkg/math/big/">math/big</a></dt>
844   <dd>
845     <p><!-- https://go.dev/issue/56984, CL 453115, CL 500116 -->
846       The new <a href="/pkg/math/big/#Int.Float64"><code>Int.Float64</code></a>
847       method returns the nearest floating-point value to a
848       multi-precision integer, along with an indication of any
849       rounding that occurred.
850     </p>
851   </dd>
852 </dl><!-- math/big -->
853
854 <dl id="net"><dt><a href="/pkg/net/">net</a></dt>
855   <dd>
856     <p>
857       <!-- https://go.dev/issue/59166, https://go.dev/issue/56539 -->
858       <!-- CL 471136, CL 471137, CL 471140 -->
859       On Linux, the <a href="/pkg/net/">net</a> package can now use
860       Multipath TCP when the kernel supports it. It is not used by
861       default. To use Multipath TCP when available on a client, call
862       the
863       <a href="/pkg/net/#Dialer.SetMultipathTCP"><code>Dialer.SetMultipathTCP</code></a>
864       method before calling the
865       <a href="/pkg/net/#Dialer.Dial"><code>Dialer.Dial</code></a> or
866       <a href="/pkg/net/#Dialer.DialContext"><code>Dialer.DialContext</code></a>
867       methods. To use Multipath TCP when available on a server, call
868       the
869       <a href="/pkg/net/#ListenConfig.SetMultipathTCP"><code>ListenConfig.SetMultipathTCP</code></a>
870       method before calling the
871       <a href="/pkg/net/#ListenConfig.Listen"><code>ListenConfig.Listen</code></a>
872       method. Specify the network as <code>"tcp"</code> or
873       <code>"tcp4"</code> or <code>"tcp6"</code> as usual. If
874       Multipath TCP is not supported by the kernel or the remote host,
875       the connection will silently fall back to TCP. To test whether a
876       particular connection is using Multipath TCP, use the
877       <a href="/pkg/net/#TCPConn.MultipathTCP"><code>TCPConn.MultipathTCP</code></a>
878       method.
879     </p>
880     <p>
881       In a future Go release we may enable Multipath TCP by default on
882       systems that support it.
883     </p>
884   </dd>
885 </dl><!-- net -->
886
887 <dl id="net/http"><dt><a href="/pkg/net/http/">net/http</a></dt>
888   <dd>
889     <p><!-- CL 472636 -->
890       The new <a href="/pkg/net/http#ResponseController.EnableFullDuplex"><code>ResponseController.EnableFullDuplex</code></a>
891       method allows server handlers to concurrently read from an HTTP/1
892       request body while writing the response. Normally, the HTTP/1 server
893       automatically consumes any remaining request body before starting to
894       write the response, to avoid deadlocking clients which attempt to
895       write a complete request before reading the response. The
896       <code>EnableFullDuplex</code> method disables this behavior.
897     </p>
898
899     <p><!-- https://go.dev/issue/44855, CL 382117 -->
900       The new <a href="/pkg/net/http/#ErrSchemeMismatch"><code>ErrSchemeMismatch</code></a> error is returned by <a href="/pkg/net/http/#Client"><code>Client</code></a> and <a href="/pkg/net/http/#Transport"><code>Transport</code></a> when the server responds to an HTTPS request with an HTTP response.
901     </p>
902
903     <p><!-- CL 494122 -->
904       The <a href="/pkg/net/http/">net/http</a> package now supports
905       <a href="/pkg/errors/#ErrUnsupported"><code>errors.ErrUnsupported</code></a>,
906       in that the expression
907       <code>errors.Is(http.ErrNotSupported, errors.ErrUnsupported)</code>
908       will return true.
909     </p>
910   </dd>
911 </dl><!-- net/http -->
912
913 <dl id="os"><dt><a href="/pkg/os/">os</a></dt>
914   <dd>
915     <p><!-- https://go.dev/issue/32558, CL 219638 -->
916       Programs may now pass an empty <code>time.Time</code> value to
917       the <a href="/pkg/os/#Chtimes"><code>Chtimes</code></a> function
918       to leave either the access time or the modification time unchanged.
919     </p>
920
921     <p><!-- CL 480135 -->
922       On Windows the
923       <a href="/pkg/os#File.Chdir"><code>File.Chdir</code></a> method
924       now changes the current directory to the file, rather than
925       always returning an error.
926     </p>
927
928     <p><!-- CL 495079 -->
929       On Unix systems, if a non-blocking descriptor is passed
930       to <a href="/pkg/os/#NewFile"><code>NewFile</code></a>, calling
931       the <a href="/pkg/os/#File.Fd"><code>File.Fd</code></a> method
932       will now return a non-blocking descriptor. Previously the
933       descriptor was converted to blocking mode.
934     </p>
935
936     <p><!-- CL 477215 -->
937       On Windows calling
938       <a href="/pkg/os/#Truncate"><code>Truncate</code></a> on a
939       non-existent file used to create an empty file. It now returns
940       an error indicating that the file does not exist.
941     </p>
942
943     <p><!-- https://go.dev/issue/56899, CL 463219 -->
944       On Windows calling
945       <a href="/pkg/os/#TempDir"><code>TempDir</code></a> now uses
946       GetTempPath2W when available, instead of GetTempPathW. The
947       new behavior is a security hardening measure that prevents
948       temporary files created by processes running as SYSTEM to
949       be accessed by non-SYSTEM processes.
950     </p>
951
952     <p><!-- CL 493036 -->
953       On Windows the os package now supports working with files whose
954       names, stored as UTF-16, can't be represented as valid UTF-8.
955     </p>
956
957     <p><!-- CL 463177 -->
958       On Windows <a href="/pkg/os/#Lstat"><code>Lstat</code></a> now resolves
959       symbolic links for paths ending with a path separator, consistent with its
960       behavior on POSIX platforms.
961     </p>
962
963     <p><!-- https://go.dev/issue/54451, CL 491175 -->
964       The implementation of the
965       <a href="/pkg/io/fs/#DirEntry"><code>io/fs.DirEntry</code></a>
966       interface returned by the
967       <a href="/pkg/os/#ReadDir"><code>ReadDir</code></a> function and
968       the <a href="/pkg/os/#File.ReadDir"><code>File.ReadDir</code></a>
969       method now implements a <code>String</code> method that calls
970       <a href="/pkg/io/fs/#FormatDirEntry"><code>io/fs.FormatDirEntry</code></a>.
971     </p>
972
973     <p><!-- https://go.dev/issue/53761, CL 416775, CL 498015-->
974     The implementation of the
975     <a href="/pkg/io/fs/#FS"><code>io/fs.FS</code></a> interface returned by
976     the <a href="/pkg/os/#DirFS"><code>DirFS</code></a> function now implements
977     the <a href="/pkg/io/fs/#ReadFileFS"><code>io/fs.ReadFileFS</code></a> and
978     the <a href="/pkg/io/fs/#ReadDirFS"><code>io/fs.ReadDirFS</code></a>
979     interfaces.
980     </p>
981   </dd>
982 </dl><!-- os -->
983
984 <dl id="path/filepath"><dt><a href="/pkg/path/filepath/">path/filepath</a></dt>
985   <dd>
986     <p>
987       The implementation of the
988       <a href="/pkg/io/fs/#DirEntry"><code>io/fs.DirEntry</code></a>
989       interface passed to the function argument of
990       <a href="/pkg/path/filepath/#WalkDir"><code>WalkDir</code></a>
991       now implements a <code>String</code> method that calls
992       <a href="/pkg/io/fs/#FormatDirEntry"><code>io/fs.FormatDirEntry</code></a>.
993     </p>
994   </dd>
995 </dl><!-- path/filepath -->
996
997 <!-- CL 459455 reverted -->
998
999 <dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt>
1000   <dd>
1001     <p><!-- CL 408826, CL 413474 -->
1002       In Go 1.21, <a href="/pkg/reflect/#ValueOf"><code>ValueOf</code></a>
1003       no longer forces its argument to be allocated on the heap, allowing
1004       a <code>Value</code>'s content to be allocated on the stack. Most
1005       operations on a <code>Value</code> also allow the underlying value
1006       to be stack allocated.
1007     </p>
1008
1009     <p><!-- https://go.dev/issue/55002 -->
1010       The new <a href="/pkg/reflect/#Value"><code>Value</code></a>
1011       method <a href="/pkg/reflect/#Value.Clear"><code>Value.Clear</code></a>
1012       clears the contents of a map or zeros the contents of a slice.
1013       This corresponds to the new <code>clear</code> built-in
1014       <a href="#language">added to the language</a>.
1015     </p>
1016
1017     <p><!-- https://go.dev/issue/56906, CL 452762 -->
1018       The <a href="/pkg/reflect/#SliceHeader"><code>SliceHeader</code></a>
1019       and <a href="/pkg/reflect/#StringHeader"><code>StringHeader</code></a>
1020       types are now deprecated. In new code
1021       prefer <a href="/pkg/unsafe/#Slice"><code>unsafe.Slice</code></a>,
1022       <a href="/pkg/unsafe/#SliceData"><code>unsafe.SliceData</code></a>,
1023       <a href="/pkg/unsafe/#String"><code>unsafe.String</code></a>,
1024       or <a href="/pkg/unsafe/#StringData"><code>unsafe.StringData</code></a>.
1025     </p>
1026   </dd>
1027 </dl><!-- reflect -->
1028
1029 <dl id="regexp"><dt><a href="/pkg/regexp/">regexp</a></dt>
1030   <dd>
1031     <p><!-- https://go.dev/issue/46159, CL 479401 -->
1032       <a href="/pkg/regexp#Regexp"><code>Regexp</code></a> now defines
1033       <a href="/pkg/regexp#Regexp.MarshalText"><code>MarshalText</code></a>
1034       and <a href="/pkg/regexp#Regexp.UnmarshalText"><code>UnmarshalText</code></a>
1035       methods. These implement
1036       <a href="/pkg/encoding#TextMarshaler"><code>encoding.TextMarshaler</code></a>
1037       and
1038       <a href="/pkg/encoding#TextUnmarshaler"><code>encoding.TextUnmarshaler</code></a>
1039       and will be used by packages such as
1040       <a href="/pkg/encoding/json">encoding/json</a>.
1041     </p>
1042   </dd>
1043 </dl><!-- regexp -->
1044
1045 <dl id="runtime"><dt><a href="/pkg/runtime/">runtime</a></dt>
1046   <dd>
1047     <p><!-- https://go.dev/issue/38651, CL 435337 -->
1048       Textual stack traces produced by Go programs, such as those
1049       produced when crashing, calling <code>runtime.Stack</code>, or
1050       collecting a goroutine profile with <code>debug=2</code>, now
1051       include the IDs of the goroutines that created each goroutine in
1052       the stack trace.
1053     </p>
1054
1055     <p><!-- https://go.dev/issue/57441, CL 474915 -->
1056       Crashing Go applications can now opt-in to Windows Error Reporting (WER) by setting the environment variable
1057       <code>GOTRACEBACK=wer</code> or calling <a href="/pkg/runtime/debug/#SetTraceback"><code>debug.SetTraceback("wer")</code></a>
1058       before the crash. Other than enabling WER, the runtime will behave as with <code>GOTRACEBACK=crash</code>.
1059       On non-Windows systems, <code>GOTRACEBACK=wer</code> is ignored.
1060     </p>
1061
1062     <p><!-- CL 447778 -->
1063       <code>GODEBUG=cgocheck=2</code>, a thorough checker of cgo pointer passing rules,
1064       is no longer available as a <a href="/pkg/runtime#hdr-Environment_Variables">debug option</a>.
1065       Instead, it is available as an experiment using <code>GOEXPERIMENT=cgocheck2</code>.
1066       In particular this means that this mode has to be selected at build time instead of startup time.
1067     </p>
1068
1069     <p>
1070       <code>GODEBUG=cgocheck=1</code> is still available (and is still the default).
1071     </p>
1072
1073     <p><!-- https://go.dev/issue/46787, CL 367296 -->
1074       A new type <code>Pinner</code> has been added to the runtime
1075       package. <code>Pinner</code>s may be used to "pin" Go memory
1076       such that it may be used more freely by non-Go code. For instance,
1077       passing Go values that reference pinned Go memory to C code is
1078       now allowed. Previously, passing any such nested reference was
1079       disallowed by the
1080       <a href="https://pkg.go.dev/cmd/cgo#hdr-Passing_pointers">cgo pointer passing rules.</a>
1081
1082       See <a href="/pkg/runtime#Pinner">the docs</a> for more details.
1083     </p>
1084
1085     <!-- CL 472195 no release note needed -->
1086   </dd>
1087 </dl><!-- runtime -->
1088
1089 <dl id="runtime/metrics"><dt><a href="/pkg/runtime/metrics/">runtime/metrics</a></dt>
1090   <dd>
1091     <p><!-- https://go.dev/issue/56857, CL 497315 -->
1092       A few previously-internal GC metrics, such as live heap size, are
1093       now available.
1094
1095       <code>GOGC</code> and <code>GOMEMLIMIT</code> are also now
1096       available as metrics.
1097     </p>
1098   </dd>
1099 </dl><!-- runtime/metrics -->
1100
1101 <dl id="runtime/trace"><dt><a href="/pkg/runtime/trace/">runtime/trace</a></dt>
1102   <dd>
1103     <p><!-- https://go.dev/issue/16638 -->
1104       Collecting traces on amd64 and arm64 now incurs a substantially
1105       smaller CPU cost: up to a 10x improvement over the previous release.
1106     </p>
1107
1108     <p><!-- CL 494495 -->
1109       Traces now contain explicit stop-the-world events for every reason
1110       the Go runtime might stop-the-world, not just garbage collection.
1111     </p>
1112   </dd>
1113 </dl><!-- runtime/trace -->
1114
1115 <dl id="sync"><dt><a href="/pkg/sync/">sync</a></dt>
1116   <dd>
1117     <p><!-- https://go.dev/issue/56102, CL 451356 -->
1118       The new <a href="/pkg/sync/#OnceFunc"><code>OnceFunc</code></a>,
1119       <a href="/pkg/sync/#OnceValue"><code>OnceValue</code></a>, and
1120       <a href="/pkg/sync/#OnceValues"><code>OnceValues</code></a>
1121       functions capture a common use of <a href="/pkg/sync/#Once">Once</a> to
1122       lazily initialize a value on first use.
1123     </p>
1124   </dd>
1125 </dl>
1126
1127 <dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt>
1128   <dd>
1129     <p><!-- CL 480135 -->
1130       On Windows the
1131       <a href="/pkg/syscall#Fchdir"><code>Fchdir</code></a> function
1132       now changes the current directory to its argument, rather than
1133       always returning an error.
1134     </p>
1135
1136     <p><!-- https://go.dev/issue/46259, CL 458335 -->
1137       On FreeBSD
1138       <a href="/pkg/syscall#SysProcAttr"><code>SysProcAttr</code></a>
1139       has a new field <code>Jail</code> that may be used to put the
1140       newly created process in a jailed environment.
1141     </p>
1142
1143     <p><!-- CL 493036 -->
1144       On Windows the syscall package now supports working with files whose
1145       names, stored as UTF-16, can't be represented as valid UTF-8.
1146       The <a href="/pkg/syscall#UTF16ToString"><code>UTF16ToString</code></a>
1147       and <a href="/pkg/syscall#UTF16FromString"><code>UTF16FromString</code></a>
1148       functions now convert between UTF-16 data and
1149       <a href="https://simonsapin.github.io/wtf-8/">WTF-8</a> strings.
1150       This is backward compatible as WTF-8 is a superset of the UTF-8
1151       format that was used in earlier releases.
1152     </p>
1153
1154     <p><!-- CL 476578, CL 476875, CL 476916 -->
1155       Several error values match the new
1156       <a href="/pkg/errors/#ErrUnsupported"><code>errors.ErrUnsupported</code></a>,
1157       such that <code>errors.Is(err, errors.ErrUnsupported)</code>
1158       returns true.
1159       <ul>
1160         <li><code>ENOSYS</code></li>
1161         <li><code>ENOTSUP</code></li>
1162         <li><code>EOPNOTSUPP</code></li>
1163         <li><code>EPLAN9</code> (Plan 9 only)</li>
1164         <li><code>ERROR_CALL_NOT_IMPLEMENTED</code> (Windows only)</li>
1165         <li><code>ERROR_NOT_SUPPORTED</code> (Windows only)</li>
1166         <li><code>EWINDOWS</code> (Windows only)</li>
1167       </ul>
1168     </p>
1169   </dd>
1170 </dl><!-- syscall -->
1171
1172 <dl id="testing"><dt><a href="/pkg/testing/">testing</a></dt>
1173   <dd>
1174     <p><!-- https://go.dev/issue/37708, CL 463837 -->
1175       The new <code>-test.fullpath</code> option will print full path
1176       names in test log messages, rather than just base names.
1177     </p>
1178
1179     <p><!-- https://go.dev/issue/52600, CL 475496 -->
1180       The new <a href="/pkg/testing/#Testing"><code>Testing</code></a> function reports whether the program is a test created by <code>go</code> <code>test</code>.
1181     </p>
1182   </dd>
1183 </dl><!-- testing -->
1184
1185 <dl id="testing/fstest"><dt><a href="/pkg/testing/fstest/">testing/fstest</a></dt>
1186   <dd>
1187     <p><!-- https://go.dev/issue/54451, CL 491175 -->
1188       Calling <code><a href="/pkg/testing/fstest/MapFS.Open">Open</a>.<a href="/pkg/io/fs/#File.Stat">Stat</a></code>
1189       will return a type that now implements a <code>String</code>
1190       method that calls
1191       <a href="/pkg/io/fs/#FormatFileInfo"><code>io/fs.FormatFileInfo</code></a>.
1192     </p>
1193   </dd>
1194 </dl><!-- testing/fstest -->
1195
1196 <dl id="unicode"><dt><a href="/pkg/unicode/">unicode</a></dt>
1197   <dd>
1198     <p><!-- CL 456837 -->
1199       The <a href="/pkg/unicode/"><code>unicode</code></a> package and
1200       associated support throughout the system has been upgraded to
1201       <a href="https://www.unicode.org/versions/Unicode15.0.0/">Unicode 15.0.0</a>.
1202     </p>
1203   </dd>
1204 </dl><!-- unicode -->
1205
1206 <h2 id="ports">Ports</h2>
1207
1208 <h3 id="darwin">Darwin</h3>
1209
1210 <p><!-- https://go.dev/issue/57125 -->
1211   As <a href="go1.20#darwin">announced</a> in the Go 1.20 release notes,
1212   Go 1.21 requires macOS 10.15 Catalina or later;
1213   support for previous versions has been discontinued.
1214 </p>
1215
1216 <h3 id="windows">Windows</h3>
1217
1218 <p><!-- https://go.dev/issue/57003, https://go.dev/issue/57004 -->
1219   As <a href="go1.20#windows">announced</a> in the Go 1.20 release notes,
1220   Go 1.21 requires at least Windows 10 or Windows Server 2016;
1221   support for previous versions has been discontinued.
1222 </p>
1223
1224 <!-- CL 470695 -->
1225 <p>
1226   <!-- cmd/dist: default to GOARM=7 on all non-arm systems -->
1227 </p>
1228
1229 <h3 id="wasm">WebAssembly</h3>
1230
1231 <p><!-- https://go.dev/issue/38248, https://go.dev/issue/59149, CL 489255 -->
1232   The new <code>go:wasmimport</code> directive can now be used in Go programs
1233   to import functions from the WebAssembly host.
1234 </p>
1235
1236 <!-- https://go.dev/issue/56100 -->
1237 <p>
1238   The Go scheduler now interacts much more efficiently with the
1239   JavaScript event loop, especially in applications that block
1240   frequently on asynchronous events.
1241 </p>
1242
1243
1244 <h3 id="wasip1">WebAssembly System Interface</h3>
1245
1246 <p><!-- https://go.dev/issue/58141 -->
1247   Go 1.21 adds an experimental port to the <a href="https://wasi.dev/">
1248   WebAssembly System Interface (WASI)</a>, Preview 1
1249   (<code>GOOS=wasip1</code>, <code>GOARCH=wasm</code>).
1250 </p>
1251
1252 <p>
1253   As a result of the addition of the new <code>GOOS</code> value
1254   "<code>wasip1</code>", Go files named <code>*_wasip1.go</code>
1255   will now be <a href="/pkg/go/build/#hdr-Build_Constraints">ignored
1256   by Go tools</a> except when that <code>GOOS</code> value is being
1257   used.
1258   If you have existing filenames matching that pattern, you will
1259   need to rename them.
1260 </p>
1261
1262 <h3 id="PPC64">ppc64/ppc64le</h3>
1263
1264 <p><!-- go.dev/issue/44549 -->
1265   On Linux, <code>GOPPC64=power10</code> now generates PC-relative instructions, prefixed
1266   instructions, and other new Power10 instructions. On AIX, <code>GOPPC64=power10</code>
1267   generates Power10 instructions, but does not generate PC-relative instructions.
1268 </p>
1269
1270 <p>
1271   When building position-independent binaries for <code>GOPPC64=power10</code>
1272   <code>GOOS=linux</code> <code>GOARCH=ppc64le</code>, users can expect reduced binary
1273   sizes in most cases, in some cases 3.5%. Position-independent binaries are built for
1274   ppc64le with the following <code>-buildmode</code> values:
1275   <code>c-archive</code>, <code>c-shared</code>, <code>shared</code>, <code>pie</code>, <code>plugin</code>.
1276 </p>
1277
1278 <h3 id="loong64">loong64</h3>
1279
1280 <p><!-- go.dev/issue/53301, CL 455075, CL 425474, CL 425476, CL 425478, CL 489576 -->
1281   The <code>linux/loong64</code> port now supports <code>-buildmode=c-archive</code>,
1282   <code>-buildmode=c-shared</code> and <code>-buildmode=pie</code>.
1283 </p>
1284
1285 <!-- proposals for x repos that don't need to be mentioned here but
1286      are picked up by the relnote tool. -->
1287 <!-- https://go.dev/issue/54232 -->
1288 <!-- https://go.dev/issue/57051 -->
1289 <!-- https://go.dev/issue/57792 -->
1290 <!-- https://go.dev/issue/57906 -->
1291 <!-- https://go.dev/issue/58668 -->
1292 <!-- https://go.dev/issue/59016 -->
1293 <!-- https://go.dev/issue/59676 -->
1294 <!-- https://go.dev/issue/60409 -->
1295 <!-- https://go.dev/issue/61176 -->
1296
1297 <!-- changes to cmd/api that don't need release notes. -->
1298 <!-- CL 469115, CL 469135, CL 499981 -->
1299
1300 <!-- proposals that don't need release notes. -->
1301 <!-- https://go.dev/issue/10275 -->
1302 <!-- https://go.dev/issue/59719 -->