2 "Title": "Go 1.21 Release Notes",
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.
14 main ul li { margin: 0.5em 0; }
17 <h2 id="introduction">DRAFT RELEASE NOTES — Introduction to Go 1.21</h2>
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.
26 <h2 id="language">Changes to the language</h2>
29 Go 1.21 adds three new built-ins to the language.
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
36 See the language spec for
37 <a href="https://tip.golang.org/ref/spec#Min_and_max">details</a>.
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>.
48 <p><!-- https://go.dev/issue/57411 -->
49 Package initialization order is now specified more precisely. The
53 Sort all packages by import path.
55 <li>Repeat until the list of packages is empty:
58 Find the first package in the list for which all imports are
62 Initialize that package and remove it from the list.
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.
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)
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
81 <!-- https://go.dev/issue/57969 -->
83 <!-- add GOEXPERIMENT=loopvar -->
88 TODO: complete this section
91 <h2 id="ports">Ports</h2>
95 <!-- cmd/dist: default to GOARM=7 on all non-arm systems -->
98 <!-- https://go.dev/issue/38248 -->
100 <!-- replace CallImport with go:wasmimport directive -->
103 <h3 id="wasm">WebAssembly</h3>
105 <!-- https://go.dev/issue/59149 -->
107 <!-- allow the use of go:wasmimport globally -->
112 <!-- cmd/compile: remove go:wasmimport restriction -->
115 <!-- https://go.dev/issue/56100 -->
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.
123 <h3 id="wasip1">WebAssembly System Interface</h3>
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>).
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
137 If you have existing filenames matching that pattern, you will
141 <h2 id="tools">Tools</h2>
143 <!-- https://go.dev/issue/15513 -->
145 <!-- support compiling all tests without running -->
148 <h3 id="go-command">Go command</h3>
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
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.
165 <p><!-- CL 453603 -->
166 TODO: <a href="https://go.dev/cl/453603">https://go.dev/cl/453603</a>: cmd/go, go/build: parse directives in file headers; modified api/next/56986.txt
171 <!-- cmd/go: make go test build multiple executables; The go test command now supports using the -c flag with multiple packages. -->
174 <h2 id="runtime-changes">Runtime</h2>
177 TODO: complete this section, or delete if not needed
180 <p><!-- https://go.dev/issue/7181 -->
181 When printing very deep stacks, the runtime now prints the first 50
182 (innermost) frames followed by the bottom 50 (outermost) frames,
183 rather than just printing the first 100 frames. This makes it easier
184 to see how deeply recursive stacks started, and is especially
185 valuable for debugging stack overflows.
188 <p><!-- https://go.dev/issue/59960 -->
189 On Linux platforms that support transparent huge pages, the Go runtime
190 now manages which parts of the heap may be backed by huge pages more
191 explicitly. This leads to better utilization of memory: small heaps
192 should see less memory used (up to 50% in pathological cases) while
193 large heaps should see fewer broken huge pages for dense parts of the
194 heap, improving CPU usage and latency by up to 1%.
197 <p><!-- https://go.dev/issue/57069, https://go.dev/issue/56966 -->
198 As a result of runtime-internal garbage collection tuning,
199 applications may see up to a 40% reduction in application tail latency
200 and a small decrease in memory use. Some applications may also observe
201 a small loss in throughput.
203 The memory use decrease should be proportional to the loss in
204 throughput, such that the previous release's throughput/memory
205 tradeoff may be recovered (with little change to latency) by
206 increasing <code>GOGC</code> and/or <code>GOMEMLIMIT</code> slightly.
209 <h2 id="compiler">Compiler</h2>
213 <!-- cmd/cgo: reject attempts to declare methods on C types -->
218 <!-- cmd/compile: enable deadcode of unreferenced large global maps -->
222 TODO: complete this section, or delete if not needed
225 <h2 id="linker">Linker</h2>
229 <!-- cmd/link: generate .xdata PE section -->
233 In Go 1.21 the linker (with help from the compiler) is now capable of
234 deleting dead (unreferenced) global map variables, if the number of
235 entries in the variable initializer is sufficiently large, and if the
236 initializer expressions are side-effect free.
239 TODO: complete this section, or delete if not needed
242 <h2 id="library">Core library</h2>
244 <h3 id="slog">New log/slog package</h3>
247 The new <a href="/pkg/log/slog">log/slog</a> package provides structured logging with levels.
248 Structured logging emits key-value pairs
249 to enable fast, accurate processing of large amounts of log data.
250 The package supports integration with popular log analysis tools and services.
253 <h3 id="slices">New slices package</h3>
255 <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 -->
256 The new <a href="/pkg/slices">slices</a> package provides many common
257 operations on slices, using generic functions that work with slices
261 <h3 id="maps">New maps package</h3>
263 <p><!-- https://go.dev/issue/57436, CL 464343 -->
264 The new <a href="/pkg/maps/">maps</a> package provides several
265 common operations on maps, using generic functions that work with
266 maps of any key or element type.
269 <h3 id="minor_library_changes">Minor changes to the library</h3>
272 As always, there are various minor changes and updates to the library,
273 made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a>
275 There are also various performance improvements, not enumerated here.
278 <p><!-- CL 456837 -->
279 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
283 TODO: complete this section
286 <dl id="bytes"><dt><a href="/pkg/bytes/">bytes</a></dt>
288 <p><!-- https://go.dev/issue/53685 -->
289 TODO: <a href="https://go.dev/issue/53685">https://go.dev/issue/53685</a>: add Buffer.Available and Buffer.AvailableBuffer
292 <p><!-- CL 474635 -->
293 TODO: <a href="https://go.dev/cl/474635">https://go.dev/cl/474635</a>: bytes: add Buffer.Available and Buffer.AvailableBuffer; modified api/next/53685.txt
298 <dl id="context"><dt><a href="/pkg/context/">context</a></dt>
300 <p><!-- https://go.dev/issue/40221, CL 479918 -->
301 The new <a href="/pkg/context/#WithoutCancel"><code>WithoutCancel</code></a>
302 function returns a copy of a context that is not canceled when the original
305 <p><!-- https://go.dev/issue/56661, CL 449318 -->
306 The new <a href="/pkg/context/#WithDeadlineCause"><code>WithDeadlineCause</code></a>
307 and <a href="/pkg/context/#WithTimeoutCause"><code>WithTimeoutCause</code></a>
308 functions provide a way to set a context cancellation cause when a deadline or
309 timer expires. The cause may be retrieved with the
310 <a href="/pkg/context/#Cause"><code>Cause</code></a> function.
312 <p><!-- https://go.dev/issue/57928, CL 482695 -->
313 The new <a href="/pkg/context/#AfterFunc"><code>AfterFunc</code></a>
314 function registers a function to run after a context has been cancelled.
319 <dl id="crypto/elliptic"><dt><a href="/pkg/crypto/elliptic/">crypto/elliptic</a></dt>
321 <p><!-- CL 459977 -->
322 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
325 </dl><!-- crypto/elliptic -->
327 <dl id="crypto/rsa"><dt><a href="/pkg/crypto/rsa/">crypto/rsa</a></dt>
329 <p><!-- https://go.dev/issue/56921 -->
330 TODO: <a href="https://go.dev/issue/56921">https://go.dev/issue/56921</a>: deprecate GenerateMultiPrimeKey and PrecomputedValues.CRTValues
333 <p><!-- CL 459976 -->
334 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
337 </dl><!-- crypto/rsa -->
339 <dl id="crypto/sha1"><dt><a href="/pkg/crypto/sha1/">crypto/sha1</a></dt>
341 <p><!-- CL 483815 -->
342 TODO: <a href="https://go.dev/cl/483815">https://go.dev/cl/483815</a>: crypto/sha1: add WriteString and WriteByte method
345 </dl><!-- crypto/sha1 -->
347 <dl id="crypto/sha256"><dt><a href="/pkg/crypto/sha256/">crypto/sha256</a></dt>
349 <p><!-- https://go.dev/issue/50543 -->
350 TODO: <a href="https://go.dev/issue/50543">https://go.dev/issue/50543</a>: add native SHA256 instruction implementation for AMD64
353 <p><!-- CL 408795 -->
354 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.
357 <p><!-- CL 481478 -->
358 TODO: <a href="https://go.dev/cl/481478">https://go.dev/cl/481478</a>: crypto/sha256: add WriteString and WriteByte method
361 </dl><!-- crypto/sha256 -->
363 <dl id="crypto/sha512"><dt><a href="/pkg/crypto/sha512/">crypto/sha512</a></dt>
365 <p><!-- CL 483816 -->
366 TODO: <a href="https://go.dev/cl/483816">https://go.dev/cl/483816</a>: crypto/sha512: add WriteString and WriteByte method
369 </dl><!-- crypto/sha512 -->
371 <dl id="crypto/x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt>
373 <p><!-- https://go.dev/issue/53573 -->
374 TODO: <a href="https://go.dev/issue/53573">https://go.dev/issue/53573</a>: surface ReasonCode inside x509.RevocationList entries
377 <p><!-- CL 468875 -->
378 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
381 </dl><!-- crypto/x509 -->
383 <dl id="debug/elf"><dt><a href="/pkg/debug/elf/">debug/elf</a></dt>
385 <p><!-- https://go.dev/issue/56887 -->
386 TODO: <a href="https://go.dev/issue/56887">https://go.dev/issue/56887</a>: add DT_FLAGS_1 (dynamic flags) constants
389 <p><!-- https://go.dev/issue/56892 -->
390 TODO: <a href="https://go.dev/issue/56892">https://go.dev/issue/56892</a>: add (*File).DynValue
393 <p><!-- CL 452496 -->
394 TODO: <a href="https://go.dev/cl/452496">https://go.dev/cl/452496</a>: debug/elf: add DT_FLAGS_1 constants; modified api/next/56887.txt
397 <p><!-- CL 452617 -->
398 TODO: <a href="https://go.dev/cl/452617">https://go.dev/cl/452617</a>: debug/elf: retrieve values for dynamic section tags; modified api/next/56892.txt
401 <p><!-- CL 473256 -->
402 TODO: <a href="https://go.dev/cl/473256">https://go.dev/cl/473256</a>: debug/elf: support zstd compression; modified api/next/55107.txt
405 </dl><!-- debug/elf -->
407 <dl id="debug/pe"><dt><a href="/pkg/debug/pe/">debug/pe</a></dt>
409 <p><!-- CL 488475 -->
410 TODO: <a href="https://go.dev/cl/488475">https://go.dev/cl/488475</a>: debug/pe: return error on reading from section with uninitialized data
413 </dl><!-- debug/pe -->
415 <dl id="embed"><dt><a href="/pkg/embed/">embed</a></dt>
417 <p><!-- https://go.dev/issue/57803 -->
418 TODO: <a href="https://go.dev/issue/57803">https://go.dev/issue/57803</a>: openFile should implement ReaderAt
421 <p><!-- CL 483235 -->
422 TODO: <a href="https://go.dev/cl/483235">https://go.dev/cl/483235</a>: embed: implement openFile.ReadAt
427 <dl id="errors"><dt><a href="/pkg/errors/">errors</a></dt>
429 <p><!-- https://go.dev/issue/41198 -->
430 TODO: <a href="https://go.dev/issue/41198">https://go.dev/issue/41198</a>: add ErrUnsupported
433 <p><!-- CL 473935 -->
434 TODO: <a href="https://go.dev/cl/473935">https://go.dev/cl/473935</a>: errors: add ErrUnsupported; modified api/next/41198.txt
439 <dl id="flag"><dt><a href="/pkg/flag/">flag</a></dt>
441 <p><!-- https://go.dev/issue/53747 -->
442 TODO: <a href="https://go.dev/issue/53747">https://go.dev/issue/53747</a>: add BoolFunc(name, usage string, fn func(string)error)
445 <p><!-- CL 476015 -->
446 TODO: <a href="https://go.dev/cl/476015">https://go.dev/cl/476015</a>: flag: add BoolFunc; FlagSet.BoolFunc; modified api/next/53747.txt
449 <p><!-- CL 480215 -->
450 TODO: <a href="https://go.dev/cl/480215">https://go.dev/cl/480215</a>: flag: panic if a flag is defined after being set
455 <dl id="fs"><dt><a href="/pkg/fs/">fs</a></dt>
457 <p><!-- https://go.dev/issue/54451 -->
458 TODO: <a href="https://go.dev/issue/54451">https://go.dev/issue/54451</a>: standard implementations of FileInfo and DirEntry should implement fmt.Stringer
463 <dl id="go/ast"><dt><a href="/pkg/go/ast/">go/ast</a></dt>
465 <p><!-- https://go.dev/issue/28089, CL 487935 -->
466 The new <a href="/pkg/go/ast/#IsGenerated"><code>IsGenerated</code></a> predicate
467 reports whether a file syntax tree contains the
468 <a href="https://go.dev/s/generatedcode">special comment</a>
469 that conventionally indicates that the file was generated by a tool.
474 <p><!-- CL 476276 -->
475 TODO: <a href="https://go.dev/cl/476276">https://go.dev/cl/476276</a>: go/ast: add File.GoVersion; modified api/next/59033.txt
480 <dl id="go/build"><dt><a href="/pkg/go/build/">go/build</a></dt>
482 <p><!-- CL 453603 -->
483 TODO: <a href="https://go.dev/cl/453603">https://go.dev/cl/453603</a>: cmd/go, go/build: parse directives in file headers; modified api/next/56986.txt
486 </dl><!-- go/build -->
488 <dl id="go/build/constraint"><dt><a href="/pkg/go/build/constraint/">go/build/constraint</a></dt>
490 <p><!-- CL 476275 -->
491 TODO: <a href="https://go.dev/cl/476275">https://go.dev/cl/476275</a>: go/build/constraint: add GoVersion; modified api/next/59033.txt
494 </dl><!-- go/build/constraint -->
496 <dl id="go/token"><dt><a href="/pkg/go/token/">go/token</a></dt>
498 <p><!-- https://go.dev/issue/57708, CL 464515 -->
499 The new <a href="/pkg/go/token/#File.Lines"><code>File.Lines</code></a> method
500 returns the file's line-number table in the same form as accepted by
501 <code>File.SetLines</code>.
504 </dl><!-- go/token -->
506 <dl id="hash/maphash"><dt><a href="/pkg/hash/maphash/">hash/maphash</a></dt>
508 <p><!-- https://go.dev/issue/47342 -->
509 TODO: <a href="https://go.dev/issue/47342">https://go.dev/issue/47342</a>: Provide a `purego` implementation
512 <p><!-- CL 468795 -->
513 TODO: <a href="https://go.dev/cl/468795">https://go.dev/cl/468795</a>: hash/maphash: add purego implementation
516 </dl><!-- hash/maphash -->
518 <dl id="io/fs"><dt><a href="/pkg/io/fs/">io/fs</a></dt>
520 <p><!-- CL 489555 -->
521 TODO: <a href="https://go.dev/cl/489555">https://go.dev/cl/489555</a>: io/fs: add FormatFileInfo and FormatDirEntry functions; modified api/next/54451.txt
526 <dl id="log/slog"><dt><a href="/pkg/log/slog/">log/slog</a></dt>
528 <p><!-- https://go.dev/issue/59060 -->
529 TODO: <a href="https://go.dev/issue/59060">https://go.dev/issue/59060</a>: arg to Record.Attrs should return bool
532 <p><!-- https://go.dev/issue/59141 -->
533 TODO: <a href="https://go.dev/issue/59141">https://go.dev/issue/59141</a>: handle panics in LogValuer.LogValue
536 <p><!-- https://go.dev/issue/59204 -->
537 TODO: <a href="https://go.dev/issue/59204">https://go.dev/issue/59204</a>: change slog.Group signature to ...any
540 <p><!-- https://go.dev/issue/59280 -->
541 TODO: <a href="https://go.dev/issue/59280">https://go.dev/issue/59280</a>: ReplaceAttr gets Source struct instead of file:line
544 <p><!-- https://go.dev/issue/59282 -->
545 TODO: <a href="https://go.dev/issue/59282">https://go.dev/issue/59282</a>: drop only completely empty Attrs
548 <p><!-- https://go.dev/issue/59339 -->
549 TODO: <a href="https://go.dev/issue/59339">https://go.dev/issue/59339</a>: change constructors to NewXXXHandler(io.Writer, *HandlerOptions)
552 <p><!-- https://go.dev/issue/59345 -->
553 TODO: <a href="https://go.dev/issue/59345">https://go.dev/issue/59345</a>: JSONHandler should format everything like json.Marshal
556 <p><!-- CL 477295 -->
557 TODO: <a href="https://go.dev/cl/477295">https://go.dev/cl/477295</a>: log/slog: initial commit; modified api/next/56345.txt
560 <p><!-- CL 484096 -->
561 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
564 <p><!-- CL 486376 -->
565 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
568 <p><!-- CL 486415 -->
569 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
572 <p><!-- CL 487855 -->
573 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
576 </dl><!-- log/slog -->
578 <dl id="math"><dt><a href="/pkg/math/">math</a></dt>
580 <p><!-- https://go.dev/issue/56491 -->
581 TODO: <a href="https://go.dev/issue/56491">https://go.dev/issue/56491</a>: add Compare and Compare32
584 <p><!-- CL 459435 -->
585 TODO: <a href="https://go.dev/cl/459435">https://go.dev/cl/459435</a>: math: add Compare and Compare32; modified api/next/56491.txt
588 <p><!-- CL 467515 -->
589 TODO: <a href="https://go.dev/cl/467515">https://go.dev/cl/467515</a>: math: add Compare and Compare32; modified api/next/56491.txt
594 <dl id="math/big"><dt><a href="/pkg/math/big/">math/big</a></dt>
596 <p><!-- https://go.dev/issue/56984, CL 453115 -->
597 The new <a href="/pkg/math/big/#Int.ToFloat64"><code>Int.ToFloat64</code></a>
598 method returns the nearest floating-point value to a
599 multi-precision integer, along with an indication of any
600 rounding that occurred.
603 </dl><!-- math/big -->
605 <dl id="net"><dt><a href="/pkg/net/">net</a></dt>
608 <!-- https://go.dev/issue/59166, https://go.dev/issue/56539 -->
609 <!-- CL 471136, CL 471137, CL 471140 -->
610 On Linux, the <a href="/pkg/net/">net</a> package can now use
611 Multipath TCP when the kernel supports it. It is not used by
612 default. To use Multipath TCP when available on a client, call
614 <a href="/pkg/net/#Dialer.SetMultipathTCP"><code>Dialer.SetMultipathTCP</code></a>
615 method before calling the
616 <a href="/pkg/net/#Dialer.Dial"><code>Dialer.Dial</code></a> or
617 <a href="/pkg/net/#Dialer.DialContext"><code>Dialer.DialContext</code></a>
618 methods. To use Multipath TCP when available on a server, call
620 <a href="/pkg/net/#ListenConfig.SetMultipathTCP"><code>ListenConfig.SetMultipathTCP</code></a>
621 method before calling the
622 <a href="/pkg/net/#ListenConfig.Listen"><code>ListenConfig.Listen</code></a>
623 method. Specify the network as <code>"tcp"</code> or
624 <code>"tcp4"</code> or <code>"tcp6"</code> as usual. If
625 Multipath TCP is not supported by the kernel or the remote host,
626 the connection will silently fall back to TCP. To test whether a
627 particular connection is using Multipath TCP, use the
628 <a href="/pkg/net/#TCPConn.MultipathTCP"><code>TCPConn.MultipathTCP</code></a>
632 In a future Go release we may enable Multipath TCP by default on
633 systems that support it.
638 <dl id="net/http"><dt><a href="/pkg/net/http/">net/http</a></dt>
640 <p><!-- https://go.dev/issue/44855, CL 382117 -->
641 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.
644 <p><!-- CL 472636 -->
645 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
648 <p><!-- CL 494122 -->
649 TODO: <a href="https://go.dev/cl/494122">https://go.dev/cl/494122</a>: net/http: let ErrNotSupported match errors.ErrUnsupported; modified api/next/41198.txt
652 </dl><!-- net/http -->
654 <dl id="os"><dt><a href="/pkg/os/">os</a></dt>
656 <p><!-- https://go.dev/issue/32558, CL 219638 -->
657 Programs may now pass an empty <code>time.Time</code> value to
658 the <a href="/pkg/os/#Chtimes"><code>Chtimes</code></a> function
659 to leave either the access time or the modification time unchanged.
662 <p><!-- CL 480135 -->
664 <a href="/pkg/os#File.Chdir"><code>File.Chdir></a> method
665 now changes the current directory to the file, rather than
666 always returning an error.
669 <p><!-- CL 477215 -->
671 <a href="/pkg/os/#Truncate"><code>Truncate</code></a> on a
672 non-existent file used to create an empty file. It now returns
673 an error indicating that the file does not exist.
676 <p><!-- CL 493036 -->
677 On Windows the os package now supports working with files whose
678 names, stored as UTF-16, can't be represented as valid UTF-8.
683 <!-- CL 459455 reverted -->
685 <dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt>
687 <p><!-- CL 408826, CL 413474 -->
688 In Go 1.21, <a href="/pkg/reflect/#ValueOf"><code>ValueOf</code></a>
689 no longer forces its argument to be allocated on the heap, allowing
690 a <code>Value</code>'s content to be allocated on the stack. Most
691 operations on a <code>Value</code> also allow the underlying value
692 to be stack allocated.
695 <p><!-- https://go.dev/issue/55002 -->
696 The new <a href="/pkg/reflect/#Value"><code>Value</code></a>
697 method <a href="/pkg/reflect/#Value.Clear"><code>Value.Clear</code></a>
698 clears the contents of a map or zeros the contents of a slice.
699 This corresponds to the new <code>clear</code> built-in
700 <a href="#language">added to the language</a>.
703 <p><!-- https://go.dev/issue/56906, CL 452762 -->
704 The <a href="/pkg/reflect/#SliceHeader"><code>SliceHeader</code></a>
705 and <a href="/pkg/reflect/#StringHeader"><code>StringHeader</code></a>
706 types are now deprecated. In new code
707 prefer <a href="/pkg/unsafe/#Slice"><code>unsafe.Slice</code></a>,
708 <a href="/pkg/unsafe/#SliceData"><code>unsafe.SliceData</code></a>,
709 <a href="/pkg/unsafe/#String"><code>unsafe.String</code></a>,
710 or <a href="/pkg/unsafe/#StringData"><code>unsafe.StringData</code></a>.
713 </dl><!-- reflect -->
715 <dl id="regexp"><dt><a href="/pkg/regexp/">regexp</a></dt>
717 <p><!-- https://go.dev/issue/46159, CL 479401 -->
718 <a href="/pkg/regexp#Regexp"><code>Regexp</code></a> now defines
719 <a href="/pkg/regexp#Regexp.MarshalText"><code>MarshalText</code></a>
720 and <a href="/pkg/regexp#Regexp.UnmarshalText"><code>UnmarshalText</code></a>
721 methods. These implement
722 <a href="/pkg/encoding#TextMarshaler"><code>encoding.TextMarshaler</code></a>
724 <a href="/pkg/encoding#TextUnmarshaler"><code>encoding.TextUnmarshaler</code></a>
725 and will be used by packages such as
726 <a href="/pkg/encoding/json">encoding/json</a>.
731 <dl id="runtime"><dt><a href="/pkg/runtime/">runtime</a></dt>
733 <p><!-- https://go.dev/issue/38651 -->
734 TODO: <a href="https://go.dev/issue/38651">https://go.dev/issue/38651</a>: add 'created by goroutine number' to stack traces
737 <p><!-- https://go.dev/issue/57441 -->
738 TODO: <a href="https://go.dev/issue/57441">https://go.dev/issue/57441</a>: use WER for GOTRACEBACK=wer on Windows
741 <p><!-- CL 447778 -->
742 TODO: <a href="https://go.dev/cl/447778">https://go.dev/cl/447778</a>: runtime: reimplement GODEBUG=cgocheck=2 as a GOEXPERIMENT
745 <p><!-- CL 472195 -->
746 TODO: <a href="https://go.dev/cl/472195">https://go.dev/cl/472195</a>: runtime: remove NOFRAME from asmcgocall, systemstack and mcall
749 <p><!-- CL 474915 -->
750 TODO: <a href="https://go.dev/cl/474915">https://go.dev/cl/474915</a>: runtime: support GOTRACEBACK=wer on Windows
753 <p><!-- https://go.dev/issue/46787 -->
754 A new type <code>Pinner</code> has been added to the runtime
755 package. <code>Pinner</code>s may be used to "pin" Go memory
756 such that it may be used more freely by non-Go code. For instance,
757 passing Go values that reference pinned Go memory to C code is
758 now allowed. Previously, passing any such nested reference was
760 <a href="https://pkg.go.dev/cmd/cgo#hdr-Passing_pointers">cgo pointer passing rules.</a>
762 See <a href="/pkg/runtime#Pinner">the docs</a> for more details.
765 </dl><!-- runtime -->
767 <dl id="runtime/trace"><dt><a href="/pkg/runtime/trace/">runtime/trace</a></dt>
769 <p><!-- https://go.dev/issue/16638 -->
770 Collecting traces on amd64 and arm64 now incurs a substantially
771 smaller CPU cost: up to a 10x improvement over the previous release.
774 <p><!-- CL 494495 -->
775 Traces now contain explicit stop-the-world events for every reason
776 the Go runtime might stop-the-world, not just garbage collection.
779 </dl><!-- runtime/trace -->
781 <dl id="runtime/metrics"><dt><a href="/pkg/runtime/metrics/">runtime/metrics</a></dt>
783 <p><!-- https://go.dev/issue/56857 -->
784 A few previously-internal GC metrics, such as live heap size, are
787 <code>GOGC</code> and <code>GOMEMLIMIT</code> are also now
788 available as metrics.
791 </dl><!-- runtime/metrics -->
793 <dl id="sync"><dt><a href="/pkg/sync/">sync</a></dt>
795 <p><!-- https://go.dev/issue/56102, CL 451356 -->
796 The new <a href="/pkg/sync/#OnceFunc"><code>OnceFunc</code></a>,
797 <a href="/pkg/sync/#OnceValue"><code>OnceValue</code></a>, and
798 <a href="/pkg/sync/#OnceValues"><code>OnceValues</code></a>
799 functions capture a common use of <a href="/pkg/sync/#Once">Once</a> to
800 lazily initialize a value on first use.
805 <dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt>
807 <p><!-- CL 480135 -->
809 <a href="/pkg/syscall#Fchdir"><code>Fchdir</code></a> function
810 now changes the current directory to its argument, rather than
811 always returning an error.
814 <p><!-- https://go.dev/issue/46259, CL 458335 -->
816 <a href="/pkg/syscall#SysProcAttr"><code>SysProcAttr</code></a>
817 has a new field <code>Jail</code> that may be used to put the
818 newly created process in a jailed environment.
821 <p><!-- CL 493036 -->
822 On Windows the syscall package now supports working with files whose
823 names, stored as UTF-16, can't be represented as valid UTF-8.
824 The <a href="/pkg/syscall#UTF16ToString"><code>UTF16ToString</code></a>
825 and <a href="/pkg/syscall#UTF16FromString"><code>UTF16FromString</code></a>
826 functions now convert between UTF-16 data and
827 <a href=http://simonsapin.github.io/wtf-8/"">WTF-8</a> strings.
828 This is backward compatible as WTF-8 is a superset of the UTF-8
829 format that was used in earlier releases.
832 </dl><!-- syscall -->
834 <dl id="testing"><dt><a href="/pkg/testing/">testing</a></dt>
836 <p><!-- https://go.dev/issue/37708, CL 463837 -->
837 The new <code>-test.fullpath</code> option will print full path
838 names in test log messages, rather than just base names.
841 <p><!-- https://go.dev/issue/52600, CL 475496 -->
842 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>.
845 </dl><!-- testing -->
847 <dl id="testing/slogtest"><dt><a href="/pkg/testing/slogtest/">testing/slogtest</a></dt>
849 <p><!-- CL 487895 -->
850 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
853 </dl><!-- testing/slogtest -->
855 <!-- proposals for x repos that don't need to be mentioned here but
856 are picked up by the relnote tool. -->
857 <!-- https://go.dev/issue/54232 -->
858 <!-- https://go.dev/issue/57906 -->
859 <!-- https://go.dev/issue/58668 -->