]> Cypherpunks.ru repositories - gostls13.git/blob - doc/go1.21.html
doc/go1.21: document new bytes.Buffer methods
[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 <h2 id="language">Changes to the language</h2>
27
28 <p>
29   Go 1.21 adds three new built-ins to the language.
30
31   <ul>
32     <li><!-- https://go.dev/issue/59488 -->
33       The new functions <code>min</code> and <code>max</code> compute the
34       smallest (or largest, for <code>max</code>) value of a fixed number
35       of given arguments.
36       See the language spec for
37       <a href="https://tip.golang.org/ref/spec#Min_and_max">details</a>.
38     </li>
39     <li><!-- https://go.dev/issue/56351 -->
40       The new function <code>clear</code> deletes all elements from a
41       map or zeroes all elements of a slice.
42       See the language spec for
43       <a href="https://tip.golang.org/ref/spec#Clear">details</a>.
44     </li>
45   </ul>
46 </p>
47
48 <p><!-- https://go.dev/issue/57411 -->
49   Package initialization order is now specified more precisely. The
50   new algorithm is:
51   <ul>
52     <li>
53       Sort all packages by import path.
54     </li>
55     <li>Repeat until the list of packages is empty:
56       <ul>
57         <li>
58           Find the first package in the list for which all imports are
59           already initialized.
60         </li>
61         <li>
62           Initialize that package and remove it from the list.
63         </li>
64       </ul>
65     </li>
66   </ul>
67   This may change the behavior of some programs that rely on a
68   specific initialization ordering that was not expressed by explicit
69   imports. The behavior of such programs was not well defined by the
70   spec in past releases. The new rule provides an unambiguous definition.
71 </p>
72
73 <p><!-- https://go.dev/issue/59338 -->
74   TODO: <a href="https://go.dev/issue/59338">https://go.dev/issue/59338</a>: infer type arguments from assignments of generic functions (reverse type inference)
75 </p>
76
77 <p><!-- https://go.dev/issue/56986 -->
78   TODO: <a href="https://go.dev/issue/56986">https://go.dev/issue/56986</a>: extended backwards compatibility for Go
79 </p>
80
81 <!-- https://go.dev/issue/57969 -->
82 <p>
83   <!-- add GOEXPERIMENT=loopvar -->
84 </p>
85
86
87 <p>
88   TODO: complete this section
89 </p>
90
91 <h2 id="ports">Ports</h2>
92
93 <!-- CL 470695 -->
94 <p>
95   <!-- cmd/dist: default to GOARM=7 on all non-arm systems -->
96 </p>
97
98 <!-- https://go.dev/issue/38248 -->
99 <p>
100   <!-- replace CallImport with go:wasmimport directive -->
101 </p>
102
103 <h3 id="wasm">WebAssembly</h3>
104
105 <!-- https://go.dev/issue/59149 -->
106 <p>
107   <!-- allow the use of go:wasmimport globally -->
108 </p>
109
110 <!-- CL 489255 -->
111 <p>
112   <!-- cmd/compile: remove go:wasmimport restriction -->
113 </p>
114
115 <!-- https://go.dev/issue/56100 -->
116 <p>
117   The Go scheduler now interacts much more efficiently with the
118   JavaScript event loop, especially in applications that block
119   frequently on asynchronous events.
120 </p>
121
122
123 <h3 id="wasip1">WebAssembly System Interface</h3>
124
125 <p><!-- https://go.dev/issue/58141 -->
126   Go 1.21 adds an experimental port to the <a href="https://wasi.dev/">
127   WebAssembly System Interface (WASI)</a>, Preview 1
128   (<code>GOOS=wasip1</code>, <code>GOARCH=wasm</code>).
129 </p>
130
131 <p>
132   As a result of the addition of the new <code>GOOS</code> value
133   "<code>wasip1</code>", Go files named <code>*_wasip1.go</code>
134   will now be <a href="/pkg/go/build/#hdr-Build_Constraints">ignored
135   by Go tools</a> except when that <code>GOOS</code> value is being
136   used.
137   If you have existing filenames matching that pattern, you will
138   need to rename them.
139 </p>
140
141 <h2 id="tools">Tools</h2>
142
143 <!-- https://go.dev/issue/15513 -->
144 <p>
145   <!-- support compiling all tests without running -->
146 </p>
147
148 <h3 id="go-command">Go command</h3>
149
150 <p><!-- https://go.dev/issue/58099, CL 474236 -->
151   The <code>-pgo</code> build flag now defaults to <code>-pgo=auto</code>,
152   and the restriction of specifying a single main package on the command
153   line is now removed. If a file named <code>default.pgo</code> is present
154   in the main package's directory, the <code>go</code> command will use
155   it to enable profile-guided optimization for building the corresponding
156   program.
157 </p>
158
159 <p><!-- https://go.dev/issue/37708, CL 463837 -->
160   The new <code>go</code> <code>test</code> option
161   <code>-fullpath</code> prints full path names in test log messages,
162   rather than just base names.
163 </p>
164
165 <!-- CL 466397 -->
166 <p>
167   <!-- cmd/go: make go test build multiple executables; The go test command now supports using the -c flag with multiple packages. -->
168 </p>
169
170 <h2 id="runtime-changes">Runtime</h2>
171
172 <p>
173   TODO: complete this section, or delete if not needed
174 </p>
175
176 <p><!-- https://go.dev/issue/7181 -->
177   When printing very deep stacks, the runtime now prints the first 50
178   (innermost) frames followed by the bottom 50 (outermost) frames,
179   rather than just printing the first 100 frames. This makes it easier
180   to see how deeply recursive stacks started, and is especially
181   valuable for debugging stack overflows.
182 </p>
183
184 <p><!-- https://go.dev/issue/59960 -->
185   On Linux platforms that support transparent huge pages, the Go runtime
186   now manages which parts of the heap may be backed by huge pages more
187   explicitly. This leads to better utilization of memory: small heaps
188   should see less memory used (up to 50% in pathological cases) while
189   large heaps should see fewer broken huge pages for dense parts of the
190   heap, improving CPU usage and latency by up to 1%.
191 </p>
192
193 <p><!-- https://go.dev/issue/57069, https://go.dev/issue/56966 -->
194   As a result of runtime-internal garbage collection tuning,
195   applications may see up to a 40% reduction in application tail latency
196   and a small decrease in memory use. Some applications may also observe
197   a small loss in throughput.
198
199   The memory use decrease should be proportional to the loss in
200   throughput, such that the previous release's throughput/memory
201   tradeoff may be recovered (with little change to latency) by
202   increasing <code>GOGC</code> and/or <code>GOMEMLIMIT</code> slightly.
203 </p>
204
205 <h2 id="compiler">Compiler</h2>
206
207 <!-- CL 490819 -->
208 <p>
209   <!-- cmd/cgo: reject attempts to declare methods on C types -->
210 </p>
211
212 <!-- CL 461315 -->
213 <p>
214   <!-- cmd/compile: enable deadcode of unreferenced large global maps -->
215 </p>
216
217 <p>
218   TODO: complete this section, or delete if not needed
219 </p>
220
221 <h2 id="assembler">Assembler</h2>
222
223 <!-- CL 476295 -->
224 <p>
225   The verifier that checks for incorrect uses of <code>R15</code> when dynamic linking on amd64 has been improved.
226 </p>
227
228 <h2 id="linker">Linker</h2>
229
230 <p><!-- https://go.dev/issue/57302, CL 461749 -->
231   On Windows AMD64, the linker (with help from the compiler) now emits
232   SEH unwinding data by default, which improves the integration
233   of Go applications with Windows debuggers and other tools.
234 </p>
235
236 <!-- CL 457455 -->
237 <p>
238   <!-- cmd/link: generate .xdata PE section -->
239 </p>
240 <!-- CL 463395 -->
241 <p>
242   In Go 1.21 the linker (with help from the compiler) is now capable of
243   deleting dead (unreferenced) global map variables, if the number of
244   entries in the variable initializer is sufficiently large, and if the
245   initializer expressions are side-effect free.
246 </p>
247 <p>
248   TODO: complete this section, or delete if not needed
249 </p>
250
251 <h2 id="library">Core library</h2>
252
253 <h3 id="slog">New log/slog package</h3>
254
255 <p>
256   The new <a href="/pkg/log/slog">log/slog</a> package provides structured logging with levels.
257   Structured logging emits key-value pairs
258   to enable fast, accurate processing of large amounts of log data.
259   The package supports integration with popular log analysis tools and services.
260 </p>
261
262 <h3 id="slices">New slices package</h3>
263
264 <p><!-- https://go.dev/issue/45955, https://go.dev/issue/54768, https://go.dev/issue/57348, https://go.dev/issue/57433, CL 467417, CL 483175 -->
265   The new <a href="/pkg/slices">slices</a> package provides many common
266   operations on slices, using generic functions that work with slices
267   of any element type.
268 </p>
269
270 <h3 id="maps">New maps package</h3>
271
272 <p><!-- https://go.dev/issue/57436, CL 464343 -->
273   The new <a href="/pkg/maps/">maps</a> package provides several
274   common operations on maps, using generic functions that work with
275   maps of any key or element type.
276 </p>
277
278 <h3 id="minor_library_changes">Minor changes to the library</h3>
279
280 <p>
281   As always, there are various minor changes and updates to the library,
282   made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a>
283   in mind.
284   There are also various performance improvements, not enumerated here.
285 </p>
286
287 <p><!-- CL 456837 -->
288   TODO: <a href="https://go.dev/cl/456837">https://go.dev/cl/456837</a>: all: upgrade Unicode from 13.0.0 to 15.0.0; modified api/except.txt, api/next/55079.txt
289 </p>
290
291 <p>
292   TODO: complete this section
293 </p>
294
295 <dl id="archive/tar"><dt><a href="/pkg/archive/tar/">archive/tar</a></dt>
296   <dd>
297     <p><!-- https://go.dev/issue/54451, CL 491175 -->
298       The implementation of the
299       <a href="/pkg/io/fs/#FileInfo"><code>io/fs.FileInfo</code></a>
300       interface returned by
301       <a href="/pkg/archive/tar/#Header.FileInfo"><code>Header.FileInfo</code></a>
302       now implements a <code>String</code> method that calls
303       <a href="/pkg/io/fs/#FormatFileInfo"><code>io/fs.FormatFileInfo</code></a>.
304     </p>
305   </dd>
306 </dl><!-- archive/tar -->
307
308 <dl id="archive/zip"><dt><a href="/pkg/archive/zip/">archive/zip</a></dt>
309   <dd>
310     <p><!-- https://go.dev/issue/54451, CL 491175 -->
311       The implementation of the
312       <a href="/pkg/io/fs/#FileInfo"><code>io/fs.FileInfo</code></a>
313       interface returned by
314       <a href="/pkg/archive/zip/#FileHeader.FileInfo"><code>FileHeader.FileInfo</code></a>
315       now implements a <code>String</code> method that calls
316       <a href="/pkg/io/fs/#FormatFileInfo"><code>io/fs.FormatFileInfo</code></a>.
317     </p>
318
319     <p><!-- https://go.dev/issue/54451, CL 491175 -->
320       The implementation of the
321       <a href="/pkg/io/fs/#DirEntry"><code>io/fs.DirEntry</code></a>
322       interface returned by the
323       <a href="/pkg/io/fs/#ReadDirFile.ReadDir"><code>io/fs.ReadDirFile.ReadDir</code></a>
324       method of the
325       <a href="/pkg/io/fs/#File"><code>io/fs.File</code></a>
326       returned by
327       <a href="/pkg/archive/zip/#Reader.Open"><code>Reader.Open</code></a>
328       now implements a <code>String</code> method that calls
329       <a href="/pkg/io/fs/#FormatDirEntry"><code>io/fs.FormatDirEntry</code></a>.
330     </p>
331   </dd>
332 </dl><!-- archive/zip -->
333
334 <dl id="bytes"><dt><a href="/pkg/bytes/">bytes</a></dt>
335   <dd>
336     <p><!-- https://go.dev/issue/53685, CL 474635 -->
337       The <a href="/pkg/bytes/#Buffer"><code>Buffer</code></a> type
338       has two new methods:
339       <a href="/pkg/bytes/#Buffer.Available"><code>Available</code></a>
340       and <a href="/pkg/bytes/#AvailableBuffer"><code>AvailableBuffer</code></a>.
341       These may be used along with the
342       <a href="/pkg/bytes/#Buffer.Write"><code>Write</code></a>
343       method to append directly to the <code>Buffer</code>.
344     </p>
345   </dd>
346 </dl><!-- bytes -->
347
348 <dl id="context"><dt><a href="/pkg/context/">context</a></dt>
349   <dd>
350     <p><!-- https://go.dev/issue/40221, CL 479918 -->
351       The new <a href="/pkg/context/#WithoutCancel"><code>WithoutCancel</code></a>
352       function returns a copy of a context that is not canceled when the original
353       context is canceled.
354     </p>
355     <p><!-- https://go.dev/issue/56661, CL 449318 -->
356       The new <a href="/pkg/context/#WithDeadlineCause"><code>WithDeadlineCause</code></a>
357       and <a href="/pkg/context/#WithTimeoutCause"><code>WithTimeoutCause</code></a>
358       functions provide a way to set a context cancellation cause when a deadline or
359       timer expires. The cause may be retrieved with the
360       <a href="/pkg/context/#Cause"><code>Cause</code></a> function.
361     </p>
362     <p><!-- https://go.dev/issue/57928, CL 482695 -->
363       The new <a href="/pkg/context/#AfterFunc"><code>AfterFunc</code></a>
364       function registers a function to run after a context has been cancelled.
365     </p>
366   </dd>
367 </dl>
368
369 <dl id="crypto/elliptic"><dt><a href="/pkg/crypto/elliptic/">crypto/elliptic</a></dt>
370   <dd>
371     <p><!-- CL 459977 -->
372       TODO: <a href="https://go.dev/cl/459977">https://go.dev/cl/459977</a>: crypto/elliptic: deprecate unsafe APIs; modified api/next/34648.txt, api/next/52221.txt
373     </p>
374   </dd>
375 </dl><!-- crypto/elliptic -->
376
377 <dl id="crypto/rsa"><dt><a href="/pkg/crypto/rsa/">crypto/rsa</a></dt>
378   <dd>
379     <p><!-- https://go.dev/issue/56921 -->
380       TODO: <a href="https://go.dev/issue/56921">https://go.dev/issue/56921</a>: deprecate GenerateMultiPrimeKey and PrecomputedValues.CRTValues
381     </p>
382
383     <p><!-- CL 459976 -->
384       TODO: <a href="https://go.dev/cl/459976">https://go.dev/cl/459976</a>: crypto/rsa: deprecate multiprime RSA support; modified api/next/56921.txt
385     </p>
386   </dd>
387 </dl><!-- crypto/rsa -->
388
389 <dl id="crypto/sha1"><dt><a href="/pkg/crypto/sha1/">crypto/sha1</a></dt>
390   <dd>
391     <p><!-- CL 483815 -->
392       TODO: <a href="https://go.dev/cl/483815">https://go.dev/cl/483815</a>: crypto/sha1: add WriteString and WriteByte method
393     </p>
394   </dd>
395 </dl><!-- crypto/sha1 -->
396
397 <dl id="crypto/sha256"><dt><a href="/pkg/crypto/sha256/">crypto/sha256</a></dt>
398   <dd>
399     <p><!-- https://go.dev/issue/50543 -->
400       TODO: <a href="https://go.dev/issue/50543">https://go.dev/issue/50543</a>: add native SHA256 instruction implementation for AMD64
401     </p>
402
403     <p><!-- CL 408795 -->
404       TODO: <a href="https://go.dev/cl/408795">https://go.dev/cl/408795</a>: crypto/sha256: add sha-ni implementation; crypto/sha256 uses Intel SHA extensions on new enough x86 processors, making it 3-4X faster.
405     </p>
406
407     <p><!-- CL 481478 -->
408       TODO: <a href="https://go.dev/cl/481478">https://go.dev/cl/481478</a>: crypto/sha256: add WriteString and WriteByte method
409     </p>
410   </dd>
411 </dl><!-- crypto/sha256 -->
412
413 <dl id="crypto/sha512"><dt><a href="/pkg/crypto/sha512/">crypto/sha512</a></dt>
414   <dd>
415     <p><!-- CL 483816 -->
416       TODO: <a href="https://go.dev/cl/483816">https://go.dev/cl/483816</a>: crypto/sha512: add WriteString and WriteByte method
417     </p>
418   </dd>
419 </dl><!-- crypto/sha512 -->
420
421 <dl id="crypto/x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt>
422   <dd>
423     <p><!-- https://go.dev/issue/53573 -->
424       TODO: <a href="https://go.dev/issue/53573">https://go.dev/issue/53573</a>: surface ReasonCode inside x509.RevocationList entries
425     </p>
426
427     <p><!-- CL 468875 -->
428       TODO: <a href="https://go.dev/cl/468875">https://go.dev/cl/468875</a>: crypto/x509: surface ReasonCode in RevocationList API; modified api/next/53573.txt
429     </p>
430   </dd>
431 </dl><!-- crypto/x509 -->
432
433 <dl id="debug/elf"><dt><a href="/pkg/debug/elf/">debug/elf</a></dt>
434   <dd>
435     <p><!-- https://go.dev/issue/56892, CL 452617 -->
436       The new
437       <a href="https:/pkg/debug/elf/#File.DynValue"><code>File.DynValue</code></a>
438       method may be used to retrieve the numeric values listed with a
439       given dynamic tag.
440     </p>
441
442     <p><!-- https://go.dev/issue/56887, CL 452496 -->
443       The constant flags permitted in a <code>DT_FLAGS_1</code>
444       dynamic tag are now defined with type
445       <a href="/pkg/debug/elf/#DynFlag1"><code>DynFlag1</code></a>. These
446       tags have names starting with <code>DF_1</code>.
447     </p>
448
449     <p><!-- CL 473256 -->
450       The package now defines the constant
451       <a href="/pkg/debug/elf/#COMPRESS_ZSTD"><code>COMPRESS_ZSTD</code></a>.
452     </p>
453   </dd>
454 </dl><!-- debug/elf -->
455
456 <dl id="debug/pe"><dt><a href="/pkg/debug/pe/">debug/pe</a></dt>
457   <dd>
458     <p><!-- CL 488475 -->
459       Attempts to read from a section containing uninitialized data
460       using
461       <a href="/pkg/debug/pe/#Section.Data"><code>Section.Data</code></a>
462       or the reader returned by <a href="/pkg/debug/pe/#Section.Open"><code>Section.Open</code></a>
463       now return an error.
464     </p>
465   </dd>
466 </dl><!-- debug/pe -->
467
468 <dl id="embed"><dt><a href="/pkg/embed/">embed</a></dt>
469   <dd>
470     <p><!-- https://go.dev/issue/57803, CL 483235 -->
471       The <a href="/pkg/io/fs/#File"><code>io/fs.File</code></a>
472       returned by
473       <a href="/pkg/embed/#FS.Open"><code>FS.Open</code></a> now
474       has a <code>ReadAt</code> method that
475       implements <a href="/pkg/io/#ReaderAt"><code>io.ReaderAt</code></a>.
476     </p>
477
478     <p><!-- https://go.dev/issue/54451, CL 491175 -->
479       Calling <code><a href="/pkg/embed/FS.Open">FS.Open</a>.<a href="/pkg/io/fs/#File.Stat">Stat</a></code>
480       will return a type that now implements a <code>String</code>
481       method that calls
482       <a href="/pkg/io/fs/#FormatFileInfo"><code>io/fs.FormatFileInfo</code></a>.
483     </p>
484   </dd>
485 </dl><!-- embed -->
486
487 <dl id="errors"><dt><a href="/pkg/errors/">errors</a></dt>
488   <dd>
489     <p><!-- https://go.dev/issue/41198, CL 473935 -->
490       The new
491       <a href="/pkg/errors/#ErrUnsupported"><code>ErrUnsupported</code></a>
492       error provides a standardized way to indicate that a requested
493       operation may not be performed because it is unsupported.
494       For example, a call to
495       <a href="/pkg/os/#Link"><code>os.Link</code></a> when using a
496       file system that does not support hard links.
497     </p>
498   </dd>
499 </dl><!-- errors -->
500
501 <dl id="flag"><dt><a href="/pkg/flag/">flag</a></dt>
502   <dd>
503     <p><!-- https://go.dev/issue/53747, CL 476015 -->
504       The new <a href="/pkg/flag/#BoolFunc"><code>BoolFunc</code></a>
505       function and
506       <a href="/pkg/flag/#FlagSet.BoolFunc"><code>FlagSet.BoolFunc</code></a>
507       method define a flag that does not require an argument and calls
508       a function when the flag is used. This is similar to
509       <a href="/pkg/flag/#Func"><code>Func</code></a> but for a
510       boolean flag.
511     </p>
512
513     <p><!-- CL 480215 -->
514       A flag definition (via <code>Bool</code>, <code>BoolVar</code>, <code>Int</code>, <code>IntVar</code>, etc.) will panic if <code>Set</code> has already been called on a flag with the same name.
515       <p>
516       This change is intended to detect cases where <a href="#language">changes in initialization order</a> cause flag operations to occur in a different order than expected. In many cases the fix to this problem is to introduce a explicit package dependence to correctly order the definition before any <code>Set</code> operations.
517     </p>
518   </dd>
519 </dl><!-- flag -->
520
521 <dl id="go/ast"><dt><a href="/pkg/go/ast/">go/ast</a></dt>
522   <dd>
523     <p><!-- https://go.dev/issue/28089, CL 487935 -->
524       The new <a href="/pkg/go/ast/#IsGenerated"><code>IsGenerated</code></a> predicate
525       reports whether a file syntax tree contains the
526       <a href="https://go.dev/s/generatedcode">special comment</a>
527       that conventionally indicates that the file was generated by a tool.
528     </p>
529   </dd>
530
531   <dd>
532     <p><!-- https://go.dev/issue/59033, CL 476276 -->
533       The new
534       <a href="/pkg/go/ast/#File.GoVersion"><code>File.GoVersion</code></a>
535       field records the minimum Go version required by
536       any <code>//go:build</code> or <code>// +build</code>
537       directives.
538     </p>
539   </dd>
540 </dl><!-- go/ast -->
541
542 <dl id="go/build"><dt><a href="/pkg/go/build/">go/build</a></dt>
543   <dd>
544     <p><!-- https://go.dev/issue/56986, CL 453603 -->
545       The package now parses build directives (comments that start
546       with <code>//go:</code>) in file headers (before
547       the <code>package</code> declaration). These directives are
548       available in the new
549       <a href="/pkg/go/build/Package"><code>Package</code></a> fields
550       <a href="/pkg/go/build/Package.Directives"><code>Directives</code></a>,
551       <a href="/pkg/go/build/Package.TestDirectives"><code>TestDirectives</code></a>,
552       and
553       <a href="/pkg/go/build/Package.XTestDirectives"><code>XTestDirectives</code></a>.
554     </p>
555   </dd>
556 </dl><!-- go/build -->
557
558 <dl id="go/build/constraint"><dt><a href="/pkg/go/build/constraint/">go/build/constraint</a></dt>
559   <dd>
560     <p><!-- https://go.dev/issue/59033, CL 476275 -->
561       The new
562       <a href="/pkg/go/build/constraint/#GoVersion"><code>GoVersion</code></a>
563       function returns the minimum Go version implied by a build
564       expression.
565     </p>
566   </dd>
567 </dl><!-- go/build/constraint -->
568
569 <dl id="go/token"><dt><a href="/pkg/go/token/">go/token</a></dt>
570   <dd>
571     <p><!-- https://go.dev/issue/57708, CL 464515 -->
572       The new <a href="/pkg/go/token/#File.Lines"><code>File.Lines</code></a> method
573       returns the file's line-number table in the same form as accepted by
574       <code>File.SetLines</code>.
575     </p>
576   </dd>
577 </dl><!-- go/token -->
578
579 <dl id="hash/maphash"><dt><a href="/pkg/hash/maphash/">hash/maphash</a></dt>
580   <dd>
581     <p><!-- https://go.dev/issue/47342, CL 468795 -->
582       The <code>hash/maphash</code> package now has a pure Go implementation, selectable with the <code>purego</code> build tag.
583     </p>
584   </dd>
585 </dl><!-- hash/maphash -->
586
587 <dl id="io/fs"><dt><a href="/pkg/io/fs/">io/fs</a></dt>
588   <dd>
589     <p><!-- https://go.dev/issue/54451, CL 489555 -->
590       The new
591       <a href="/pkg/io/fs/#FormatFileInfo"><code>FormatFileInfo</code></a>
592       function returns a formatted version of a
593       <a href="/pkg/io/fs/#FileInfo"><code>FileInfo</code></a>.
594       The new
595       <a href="/pkg/io/fs/#FormatDirEntry"><code>FormatDirEntry</code></a>
596       function returns a formatted version of a
597       <a href="/pkg/io/fs/#FileInfo"><code>DirEntry</code></a>.
598       The implementation of
599       <a href="/pkg/io/fs/#DirEntry"><code>DirEntry</code></a>
600       returned by
601       <a href="/pkg/io/fs/#ReadDir"><code>ReadDir</code></a> now
602       implements a <code>String</code> method that calls
603       <a href="/pkg/io/fs/#FormatDirEntry"><code>FormatDirEntry</code></a>,
604       and the same is true for
605       the <a href="/pkg/io/fs/#DirEntry"><code>DirEntry</code></a>
606       value passed to
607       <a href="/pkg/io/fs/#WalkDirFunc"><code>WalkDirFunc</code></a>.
608     </p>
609   </dd>
610 </dl><!-- io/fs -->
611
612 <dl id="log/slog"><dt><a href="/pkg/log/slog/">log/slog</a></dt>
613   <dd>
614     <p><!-- https://go.dev/issue/59060 -->
615       TODO: <a href="https://go.dev/issue/59060">https://go.dev/issue/59060</a>: arg to Record.Attrs should return bool
616     </p>
617
618     <p><!-- https://go.dev/issue/59141 -->
619       TODO: <a href="https://go.dev/issue/59141">https://go.dev/issue/59141</a>: handle panics in LogValuer.LogValue
620     </p>
621
622     <p><!-- https://go.dev/issue/59204 -->
623       TODO: <a href="https://go.dev/issue/59204">https://go.dev/issue/59204</a>: change slog.Group signature to ...any
624     </p>
625
626     <p><!-- https://go.dev/issue/59280 -->
627       TODO: <a href="https://go.dev/issue/59280">https://go.dev/issue/59280</a>: ReplaceAttr gets Source struct instead of file:line
628     </p>
629
630     <p><!-- https://go.dev/issue/59282 -->
631       TODO: <a href="https://go.dev/issue/59282">https://go.dev/issue/59282</a>: drop only completely empty Attrs
632     </p>
633
634     <p><!-- https://go.dev/issue/59339 -->
635       TODO: <a href="https://go.dev/issue/59339">https://go.dev/issue/59339</a>: change constructors to NewXXXHandler(io.Writer, *HandlerOptions)
636     </p>
637
638     <p><!-- https://go.dev/issue/59345 -->
639       TODO: <a href="https://go.dev/issue/59345">https://go.dev/issue/59345</a>: JSONHandler should format everything like json.Marshal
640     </p>
641
642     <p><!-- CL 477295 -->
643       TODO: <a href="https://go.dev/cl/477295">https://go.dev/cl/477295</a>: log/slog: initial commit; modified api/next/56345.txt
644     </p>
645
646     <p><!-- CL 484096 -->
647       TODO: <a href="https://go.dev/cl/484096">https://go.dev/cl/484096</a>: log/slog: function argument to Record.Attrs returns bool; modified api/next/59060.txt
648     </p>
649
650     <p><!-- CL 486376 -->
651       TODO: <a href="https://go.dev/cl/486376">https://go.dev/cl/486376</a>: log/slog: add Source type for source location; modified api/next/59280.txt
652     </p>
653
654     <p><!-- CL 486415 -->
655       TODO: <a href="https://go.dev/cl/486415">https://go.dev/cl/486415</a>: log/slog: built-in handler constructors take options as a second arg; modified api/next/56345.txt, api/next/59339.txt
656     </p>
657
658     <p><!-- CL 487855 -->
659       TODO: <a href="https://go.dev/cl/487855">https://go.dev/cl/487855</a>: log/slog: Group takes ...any; modified api/next/56345.txt, api/next/59204.txt
660     </p>
661   </dd>
662 </dl><!-- log/slog -->
663
664 <dl id="math"><dt><a href="/pkg/math/">math</a></dt>
665   <dd>
666     <p><!-- https://go.dev/issue/56491 -->
667       TODO: <a href="https://go.dev/issue/56491">https://go.dev/issue/56491</a>: add Compare and Compare32
668     </p>
669
670     <p><!-- CL 459435 -->
671       TODO: <a href="https://go.dev/cl/459435">https://go.dev/cl/459435</a>: math: add Compare and Compare32; modified api/next/56491.txt
672     </p>
673
674     <p><!-- CL 467515 -->
675       TODO: <a href="https://go.dev/cl/467515">https://go.dev/cl/467515</a>: math: add Compare and Compare32; modified api/next/56491.txt
676     </p>
677   </dd>
678 </dl><!-- math -->
679
680 <dl id="math/big"><dt><a href="/pkg/math/big/">math/big</a></dt>
681   <dd>
682     <p><!-- https://go.dev/issue/56984, CL 453115 -->
683       The new <a href="/pkg/math/big/#Int.ToFloat64"><code>Int.ToFloat64</code></a>
684       method returns the nearest floating-point value to a
685       multi-precision integer, along with an indication of any
686       rounding that occurred.
687     </p>
688   </dd>
689 </dl><!-- math/big -->
690
691 <dl id="net"><dt><a href="/pkg/net/">net</a></dt>
692   <dd>
693     <p>
694       <!-- https://go.dev/issue/59166, https://go.dev/issue/56539 -->
695       <!-- CL 471136, CL 471137, CL 471140 -->
696       On Linux, the <a href="/pkg/net/">net</a> package can now use
697       Multipath TCP when the kernel supports it. It is not used by
698       default. To use Multipath TCP when available on a client, call
699       the
700       <a href="/pkg/net/#Dialer.SetMultipathTCP"><code>Dialer.SetMultipathTCP</code></a>
701       method before calling the
702       <a href="/pkg/net/#Dialer.Dial"><code>Dialer.Dial</code></a> or
703       <a href="/pkg/net/#Dialer.DialContext"><code>Dialer.DialContext</code></a>
704       methods. To use Multipath TCP when available on a server, call
705       the
706       <a href="/pkg/net/#ListenConfig.SetMultipathTCP"><code>ListenConfig.SetMultipathTCP</code></a>
707       method before calling the
708       <a href="/pkg/net/#ListenConfig.Listen"><code>ListenConfig.Listen</code></a>
709       method. Specify the network as <code>"tcp"</code> or
710       <code>"tcp4"</code> or <code>"tcp6"</code> as usual. If
711       Multipath TCP is not supported by the kernel or the remote host,
712       the connection will silently fall back to TCP. To test whether a
713       particular connection is using Multipath TCP, use the
714       <a href="/pkg/net/#TCPConn.MultipathTCP"><code>TCPConn.MultipathTCP</code></a>
715       method.
716     </p>
717     <p>
718       In a future Go release we may enable Multipath TCP by default on
719       systems that support it.
720     </p>
721   </dd>
722 </dl><!-- net -->
723
724 <dl id="net/http"><dt><a href="/pkg/net/http/">net/http</a></dt>
725   <dd>
726     <p><!-- https://go.dev/issue/44855, CL 382117 -->
727       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.
728     </p>
729
730     <p><!-- CL 472636 -->
731       TODO: <a href="https://go.dev/cl/472636">https://go.dev/cl/472636</a>: net/http: support full-duplex HTTP/1 responses; modified api/next/57786.txt
732     </p>
733
734     <p><!-- CL 494122 -->
735       The <a href="/pkg/net/http/">net/http</a> package now supports
736       <a href="/pkg/errors/#ErrUnsupported"><code>errors.ErrUnsupported</code></a>,
737       in that the expression
738       <code>errors.Is(http.ErrNotSupported, errors.ErrUnsupported)</code>
739       will return true.
740     </p>
741   </dd>
742 </dl><!-- net/http -->
743
744 <dl id="os"><dt><a href="/pkg/os/">os</a></dt>
745   <dd>
746     <p><!-- https://go.dev/issue/32558, CL 219638 -->
747       Programs may now pass an empty <code>time.Time</code> value to
748       the <a href="/pkg/os/#Chtimes"><code>Chtimes</code></a> function
749       to leave either the access time or the modification time unchanged.
750     </p>
751
752     <p><!-- CL 480135 -->
753       On Windows the
754       <a href="/pkg/os#File.Chdir"><code>File.Chdir</code></a> method
755       now changes the current directory to the file, rather than
756       always returning an error.
757     </p>
758
759     <p><!-- CL 477215 -->
760       On Windows calling
761       <a href="/pkg/os/#Truncate"><code>Truncate</code></a> on a
762       non-existent file used to create an empty file. It now returns
763       an error indicating that the file does not exist.
764     </p>
765
766     <p><!-- CL 493036 -->
767       On Windows the os package now supports working with files whose
768       names, stored as UTF-16, can't be represented as valid UTF-8.
769     </p>
770
771     <p><!-- https://go.dev/issue/54451, CL 491175 -->
772       The implementation of the
773       <a href="/pkg/io/fs/#DirEntry"><code>io/fs.DirEntry</code></a>
774       interface returned by the
775       <a href="/pkg/os/#ReadDir"><code>ReadDir</code></a> function and
776       the <a href="/pkg/os/#File.ReadDir"><code>File.ReadDir</code>
777       method now implements a <code>String</code> method that calls
778       <a href="/pkg/io/fs/#FormatDirEntry"><code>io/fs.FormatDirEntry</code></a>.
779     </p>
780   </dd>
781 </dl><!-- os -->
782
783 <dl id="path/filepath"><dt><a href="/pkg/path/filepath/">path/filepath</a></dt>
784   <dd>
785     <p>
786       The implementation of the
787       <a href="/pkg/io/fs/#DirEntry"><code>io/fs.DirEntry</code></a>
788       interface passed to the function argument of
789       <a href="/pkg/path/filepath/#WalkDir"><code>WalkDir</code></a>
790       now implements a <code>String</code> method that calls
791       <a href="/pkg/io/fs/#FormatDirEntry"><code>io/fs.FormatDirEntry</code></a>.
792     </p>
793   </dd>
794 </dl><!-- path/filepath -->
795
796 <!-- CL 459455 reverted -->
797
798 <dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt>
799   <dd>
800     <p><!-- CL 408826, CL 413474 -->
801       In Go 1.21, <a href="/pkg/reflect/#ValueOf"><code>ValueOf</code></a>
802       no longer forces its argument to be allocated on the heap, allowing
803       a <code>Value</code>'s content to be allocated on the stack. Most
804       operations on a <code>Value</code> also allow the underlying value
805       to be stack allocated.
806     </p>
807
808     <p><!-- https://go.dev/issue/55002 -->
809       The new <a href="/pkg/reflect/#Value"><code>Value</code></a>
810       method <a href="/pkg/reflect/#Value.Clear"><code>Value.Clear</code></a>
811       clears the contents of a map or zeros the contents of a slice.
812       This corresponds to the new <code>clear</code> built-in
813       <a href="#language">added to the language</a>.
814     </p>
815
816     <p><!-- https://go.dev/issue/56906, CL 452762 -->
817       The <a href="/pkg/reflect/#SliceHeader"><code>SliceHeader</code></a>
818       and <a href="/pkg/reflect/#StringHeader"><code>StringHeader</code></a>
819       types are now deprecated. In new code
820       prefer <a href="/pkg/unsafe/#Slice"><code>unsafe.Slice</code></a>,
821       <a href="/pkg/unsafe/#SliceData"><code>unsafe.SliceData</code></a>,
822       <a href="/pkg/unsafe/#String"><code>unsafe.String</code></a>,
823       or <a href="/pkg/unsafe/#StringData"><code>unsafe.StringData</code></a>.
824     </p>
825   </dd>
826 </dl><!-- reflect -->
827
828 <dl id="regexp"><dt><a href="/pkg/regexp/">regexp</a></dt>
829   <dd>
830     <p><!-- https://go.dev/issue/46159, CL 479401 -->
831       <a href="/pkg/regexp#Regexp"><code>Regexp</code></a> now defines
832       <a href="/pkg/regexp#Regexp.MarshalText"><code>MarshalText</code></a>
833       and <a href="/pkg/regexp#Regexp.UnmarshalText"><code>UnmarshalText</code></a>
834       methods. These implement
835       <a href="/pkg/encoding#TextMarshaler"><code>encoding.TextMarshaler</code></a>
836       and
837       <a href="/pkg/encoding#TextUnmarshaler"><code>encoding.TextUnmarshaler</code></a>
838       and will be used by packages such as
839       <a href="/pkg/encoding/json">encoding/json</a>.
840     </p>
841   </dd>
842 </dl><!-- regexp -->
843
844 <dl id="runtime"><dt><a href="/pkg/runtime/">runtime</a></dt>
845   <dd>
846     <p><!-- https://go.dev/issue/38651 -->
847       TODO: <a href="https://go.dev/issue/38651">https://go.dev/issue/38651</a>: add &#39;created by goroutine number&#39; to stack traces
848     </p>
849
850     <p><!-- https://go.dev/issue/57441, CL 474915 -->
851       Crashing Go applications can now opt-in to Windows Error Reporting (WER) by setting the environment variable
852       <code>GOTRACEBACK=wer</code> or calling <a href="/pkg/runtime/debug/#SetTraceback"><code>debug.SetTraceback("wer")</code></a>
853       before the crash. Other than enabling WER, the runtime will behave as with <code>GOTRACEBACK=crash</code>.
854       On non-Windows systems, <code>GOTRACEBACK=wer</code> is ignored.
855     </p>
856
857     <p><!-- CL 447778 -->
858       <code>GODEBUG=cgocheck=2</code>, a thorough checker of cgo pointer passing rules,
859       is no longer available as a <a href="/pkg/runtime#hdr-Environment_Variables">debug option</a>.
860       Instead, it is available as an experiment using <code>GOEXPERIMENT=cgocheck2</code>.
861       In particular this means that this mode has to be selected at build time instead of startup time.
862     <p>
863       <code>GODEBUG=cgocheck=1</code> is still available (and is still the default).
864     </p>
865
866     <p><!-- https://go.dev/issue/46787 -->
867       A new type <code>Pinner</code> has been added to the runtime
868       package. <code>Pinner</code>s may be used to "pin" Go memory
869       such that it may be used more freely by non-Go code. For instance,
870       passing Go values that reference pinned Go memory to C code is
871       now allowed. Previously, passing any such nested reference was
872       disallowed by the
873       <a href="https://pkg.go.dev/cmd/cgo#hdr-Passing_pointers">cgo pointer passing rules.</a>
874
875       See <a href="/pkg/runtime#Pinner">the docs</a> for more details.
876     </p>
877   </dd>
878 </dl><!-- runtime -->
879
880 <dl id="runtime/trace"><dt><a href="/pkg/runtime/trace/">runtime/trace</a></dt>
881   <dd>
882     <p><!-- https://go.dev/issue/16638 -->
883       Collecting traces on amd64 and arm64 now incurs a substantially
884       smaller CPU cost: up to a 10x improvement over the previous release.
885     </p>
886
887     <p><!-- CL 494495 -->
888       Traces now contain explicit stop-the-world events for every reason
889       the Go runtime might stop-the-world, not just garbage collection.
890     </p>
891   </dd>
892 </dl><!-- runtime/trace -->
893
894 <dl id="runtime/metrics"><dt><a href="/pkg/runtime/metrics/">runtime/metrics</a></dt>
895   <dd>
896     <p><!-- https://go.dev/issue/56857 -->
897       A few previously-internal GC metrics, such as live heap size, are
898       now available.
899
900       <code>GOGC</code> and <code>GOMEMLIMIT</code> are also now
901       available as metrics.
902     </p>
903   </dd>
904 </dl><!-- runtime/metrics -->
905
906 <dl id="sync"><dt><a href="/pkg/sync/">sync</a></dt>
907   <dd>
908     <p><!-- https://go.dev/issue/56102, CL 451356 -->
909       The new <a href="/pkg/sync/#OnceFunc"><code>OnceFunc</code></a>,
910       <a href="/pkg/sync/#OnceValue"><code>OnceValue</code></a>, and
911       <a href="/pkg/sync/#OnceValues"><code>OnceValues</code></a>
912       functions capture a common use of <a href="/pkg/sync/#Once">Once</a> to
913       lazily initialize a value on first use.
914     </p>
915   </dd>
916 </dl>
917
918 <dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt>
919   <dd>
920     <p><!-- CL 480135 -->
921       On Windows the
922       <a href="/pkg/syscall#Fchdir"><code>Fchdir</code></a> function
923       now changes the current directory to its argument, rather than
924       always returning an error.
925     </p>
926
927     <p><!-- https://go.dev/issue/46259, CL 458335 -->
928       On FreeBSD
929       <a href="/pkg/syscall#SysProcAttr"><code>SysProcAttr</code></a>
930       has a new field <code>Jail</code> that may be used to put the
931       newly created process in a jailed environment.
932     </p>
933
934     <p><!-- CL 493036 -->
935       On Windows the syscall package now supports working with files whose
936       names, stored as UTF-16, can't be represented as valid UTF-8.
937       The <a href="/pkg/syscall#UTF16ToString"><code>UTF16ToString</code></a>
938       and <a href="/pkg/syscall#UTF16FromString"><code>UTF16FromString</code></a>
939       functions now convert between UTF-16 data and
940       <a href=http://simonsapin.github.io/wtf-8/"">WTF-8</a> strings.
941       This is backward compatible as WTF-8 is a superset of the UTF-8
942       format that was used in earlier releases.
943     </p>
944
945     <p><!-- CL 476578, CL 476875, CL 476916 -->
946       Several error values match the new
947       <a href="/pkg/errors/#ErrUnsupported"><code>errors.ErrUnsupported</code></a>,
948       such that <code>errors.Is(err, errors.ErrUnsupported)</code>
949       returns true.
950       <ul>
951         <li><code>ENOSYS</code></li>
952         <li><code>ENOTSUP</code></li>
953         <li><code>EOPNOTSUPP</code></li>
954         <li><code>EPLAN9</code> (Plan 9 only)</li>
955         <li><code>ERROR_CALL_NOT_IMPLEMENTED</code> (Windows only)</li>
956         <li><code>ERROR_NOT_SUPPORTED</code> (Windows only)</li>
957         <li><code>EWINDOWS</code> (Windows only)</li>
958       </ul>
959     </p>
960   </dd>
961 </dl><!-- syscall -->
962
963 <dl id="testing"><dt><a href="/pkg/testing/">testing</a></dt>
964   <dd>
965     <p><!-- https://go.dev/issue/37708, CL 463837 -->
966       The new <code>-test.fullpath</code> option will print full path
967       names in test log messages, rather than just base names.
968     </p>
969
970     <p><!-- https://go.dev/issue/52600, CL 475496 -->
971       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>.
972     </p>
973   </dd>
974 </dl><!-- testing -->
975
976 <dl id="testing/fstest"><dt><a href="/pkg/testing/fstest/">testing/fstest</a></dt>
977   <dd>
978     <p><!-- https://go.dev/issue/54451, CL 491175 -->
979       Calling <code><a href="/pkg/testing/fstest/MapFS.Open">Open</a>.<a href="/pkg/io/fs/#File.Stat">Stat</a></code>
980       will return a type that now implements a <code>String</code>
981       method that calls
982       <a href="/pkg/io/fs/#FormatFileInfo"><code>io/fs.FormatFileInfo</code></a>.
983     </p>
984   </dd>
985 </dl><!-- testing/fstest -->
986
987 <dl id="testing/slogtest"><dt><a href="/pkg/testing/slogtest/">testing/slogtest</a></dt>
988   <dd>
989     <p><!-- CL 487895 -->
990       TODO: <a href="https://go.dev/cl/487895">https://go.dev/cl/487895</a>: testing/slogtest: tests for slog handlers; modified api/next/56345.txt
991     </p>
992   </dd>
993 </dl><!-- testing/slogtest -->
994
995 <!-- proposals for x repos that don't need to be mentioned here but
996      are picked up by the relnote tool. -->
997 <!-- https://go.dev/issue/54232 -->
998 <!-- https://go.dev/issue/57906 -->
999 <!-- https://go.dev/issue/58668 -->