golang.org/x/build@v0.0.0-20240506185731-218518f32b70/relnote/testdata/merge/go121.txt (about) 1 -- 00-preface.md -- 2 <!-- 3 NOTE: In this document and others in this directory, the convention is to 4 set fixed-width phrases with non-fixed-width spaces, as in 5 `hello` `world`. 6 Do not send CLs removing the interior tags from such phrases. 7 --> 8 9 <style> 10 main ul li { margin: 0.5em 0; } 11 </style> 12 -- 1-intro.md -- 13 ## Introduction to Go 1.21 {#introduction} 14 15 The latest Go release, version 1.21, arrives six months after [Go 1.20](/doc/go1.20). 16 17 -- 2-language/-heading.md -- 18 ## Changes to the language {#language} 19 -- 2-language/1-built-ins.md -- 20 Go 1.21 adds three new built-ins to the language. 21 22 -- 2-language/2-init.md -- 23 <!-- https://go.dev/issue/57411 --> 24 Package initialization order is now specified more precisely. The 25 new algorithm is: 26 27 - Sort all packages by import path. 28 - Repeat until the list of packages is empty: 29 - Find the first package in the list for which all imports are 30 already initialized. 31 - Initialize that package and remove it from the list. 32 33 -- 2-language/3-inference.md -- 34 Multiple improvements that increase the power and precision of type inference have been made. 35 36 -- 2-language/4-loopvar.md -- 37 Go 1.21 includes a preview of a language change we are considering for a future version of Go: 38 making for loop variables per-iteration instead of per-loop, to avoid accidental sharing bugs. 39 40 -- 3-tools/-heading.md -- 41 ## Tools {#tools} 42 -- 3-tools/1-compat.md -- 43 Go 1.21 adds improved support for backwards compatibility and forwards compatibility 44 in the Go toolchain. 45 46 -- 3-tools/2-go-cmd/-heading.md -- 47 ### Go command {#go-command} 48 49 -- 3-tools/2-go-cmd/c.md -- 50 The `-C` `dir` flag must now be the first 51 flag on the command-line when used. 52 53 -- 3-tools/2-go-cmd/fullpath.md -- 54 <!-- https://go.dev/issue/37708, CL 463837 --> 55 The new `go` `test` option 56 `-fullpath` prints full path names in test log messages, 57 rather than just base names. 58 59 -- 3-tools/3-cgo.md -- 60 ### Cgo {#cgo} 61 62 <!-- CL 490819 --> 63 In files that `import "C"`, the Go toolchain now 64 correctly reports errors for attempts to declare Go methods on C types. 65 66 -- 4-runtime/-heading.md -- 67 ## Runtime {#runtime-changes} 68 -- 4-runtime/misc.md -- 69 <!-- https://go.dev/issue/7181 --> 70 When printing very deep stacks, the runtime now prints the first 50 71 (innermost) frames followed by the bottom 50 (outermost) frames, 72 rather than just printing the first 100 frames. This makes it easier 73 to see how deeply recursive stacks started, and is especially 74 valuable for debugging stack overflows. 75 76 -- 5-compiler.md -- 77 ## Compiler {#compiler} 78 79 Profile-guide optimization (PGO), added as a preview in Go 1.20, is now ready 80 for general use. 81 82 -- 6-assembler.md -- 83 ## Assembler {#assembler} 84 85 86 <!-- https://go.dev/issue/58378 --> 87 88 On amd64, frameless nosplit assembly functions are no longer automatically marked as `NOFRAME`. 89 Instead, the `NOFRAME` attribute must be explicitly specified if desired, 90 which is already the behavior on other architectures supporting frame pointers. 91 With this, the runtime now maintains the frame pointers for stack transitions. 92 93 -- 7-stdlib/-heading.md -- 94 ## Core library {#library} 95 -- 7-stdlib/1-slog.md -- 96 ### New log/slog package {#slog} 97 98 The new [log/slog](/pkg/log/slog) package provides structured logging with levels. 99 100 ### New testing/slogtest package {#slogtest} 101 102 The new [testing/slogtest](/pkg/testing/slogtest) package can help 103 to validate [slog.Handler](/pkg/log/slog#Handler) implementations. 104 105 -- 7-stdlib/2-slices.md -- 106 ### New slices package {#slices} 107 108 The new [slices](/pkg/slices) package provides many common 109 operations on slices, using generic functions that work with slices 110 of any element type. 111 112 -- 7-stdlib/99-minor/-heading.md -- 113 ### Minor changes to the library {#minor_library_changes} 114 115 As always, there are various minor changes and updates to the library, 116 made with the Go 1 [promise of compatibility](/doc/go1compat) 117 in mind. 118 There are also various performance improvements, not enumerated here. 119 120 -- 7-stdlib/99-minor/archive/tar/54451.md -- 121 122 <!-- https://go.dev/issue/54451, CL 491175 --> 123 The implementation of the 124 [`io/fs.FileInfo`](/pkg/io/fs/#FileInfo) 125 interface returned by 126 [`Header.FileInfo`](/pkg/archive/tar/#Header.FileInfo) 127 now implements a `String` method that calls 128 [`io/fs.FormatFileInfo`](/pkg/io/fs/#FormatFileInfo). 129 130 -- 7-stdlib/99-minor/archive/zip/54451.md -- 131 132 <!-- https://go.dev/issue/54451, CL 491175 --> 133 The implementation of the 134 [`io/fs.FileInfo`](/pkg/io/fs/#FileInfo) 135 interface returned by 136 [`FileHeader.FileInfo`](/pkg/archive/zip/#FileHeader.FileInfo) 137 now implements a `String` method that calls 138 [`io/fs.FormatFileInfo`](/pkg/io/fs/#FormatFileInfo). 139 140 -- 7-stdlib/99-minor/bytes/53685.md -- 141 142 <!-- https://go.dev/issue/53685, CL 474635 --> 143 The [`Buffer`](/pkg/bytes/#Buffer) type 144 has two new methods: 145 [`Available`](/pkg/bytes/#Buffer.Available) 146 and [`AvailableBuffer`](/pkg/bytes/#Buffer.AvailableBuffer). 147 These may be used along with the 148 [`Write`](/pkg/bytes/#Buffer.Write) 149 method to append directly to the `Buffer`. 150 ways different. 151 152 -- 7-stdlib/99-minor/debug/elf/56887.md -- 153 154 <!-- https://go.dev/issue/56887, CL 452496 --> 155 The constant flags permitted in a `DT_FLAGS_1` 156 dynamic tag are now defined with type 157 [`DynFlag1`](/pkg/debug/elf/#DynFlag1). These 158 tags have names starting with `DF_1`. 159 160 <!-- CL 473256 --> 161 The package now defines the constant 162 [`COMPRESS_ZSTD`](/pkg/debug/elf/#COMPRESS_ZSTD). 163 164 -- 7-stdlib/99-minor/debug/elf/56892.md -- 165 166 <!-- https://go.dev/issue/56892, CL 452617 --> 167 The new 168 [`File.DynValue`](/pkg/debug/elf/#File.DynValue) 169 method may be used to retrieve the numeric values listed with a 170 given dynamic tag. 171 172 -- 7-stdlib/99-minor/debug/elf/60348.md -- 173 174 <!-- https://go.dev/issue/60348, CL 496918 --> 175 The package now defines the constant 176 [`R_PPC64_REL24_P9NOTOC`](/pkg/debug/elf/#R_PPC64_REL24_P9NOTOC). 177 178 179 -- 7-stdlib/99-minor/net/59166.md -- 180 181 <!-- https://go.dev/issue/59166, https://go.dev/issue/56539 --> 182 <!-- CL 471136, CL 471137, CL 471140 --> 183 On Linux, the [net](/pkg/net/) package can now use 184 Multipath TCP when the kernel supports it. 185 186 -- 7-stdlib/99-minor/net/http/123.md -- 187 188 189 <!-- CL 472636 --> 190 The new [`ResponseController.EnableFullDuplex`](/pkg/net/http#ResponseController.EnableFullDuplex) 191 method allows server handlers to concurrently read from an HTTP/1 192 request body while writing the response. Normally, the HTTP/1 server 193 automatically consumes any remaining request body before starting to 194 write the response, to avoid deadlocking clients which attempt to 195 write a complete request before reading the response. The 196 `EnableFullDuplex` method disables this behavior. 197 198 -- 8-ports/-heading.md -- 199 ## Ports {#ports} 200 -- 8-ports/darwin.md -- 201 202 ### Darwin {#darwin} 203 204 <!-- https://go.dev/issue/57125 --> 205 As [announced](go1.20#darwin) in the Go 1.20 release notes, 206 Go 1.21 requires macOS 10.15 Catalina or later; 207 support for previous versions has been discontinued. 208 -- 8-ports/windows.md -- 209 ### Windows {#windows} 210 211 <!-- https://go.dev/issue/57003, https://go.dev/issue/57004 --> 212 As [announced](go1.20#windows) in the Go 1.20 release notes, 213 Go 1.21 requires at least Windows 10 or Windows Server 2016; 214 support for previous versions has been discontinued. 215 216 <!-- CL 470695 --> 217 218 <!-- cmd/dist: default to GOARM=7 on all non-arm systems --> 219 -- 8-ports/wasm.md -- 220 ### WebAssembly {#wasm} 221 222 <!-- https://go.dev/issue/38248, https://go.dev/issue/59149, CL 489255 --> 223 The new `go:wasmimport` directive can now be used in Go programs 224 to import functions from the WebAssembly host. 225 226 <!-- https://go.dev/issue/56100 --> 227 228 The Go scheduler now interacts much more efficiently with the 229 JavaScript event loop, especially in applications that block 230 frequently on asynchronous events. 231 232 ### WebAssembly System Interface {#wasip1} 233 234 <!-- https://go.dev/issue/58141 --> 235 Go 1.21 adds an experimental port to the [ 236 WebAssembly System Interface (WASI)](https://wasi.dev/), Preview 1 237 (`GOOS=wasip1`, `GOARCH=wasm`). 238 239 As a result of the addition of the new `GOOS` value 240 "`wasip1`", Go files named `*_wasip1.go` 241 will now be [ignored 242 by Go tools](/pkg/go/build/#hdr-Build_Constraints) except when that `GOOS` value is being 243 used. 244 If you have existing filenames matching that pattern, you will 245 need to rename them. 246 -- want -- 247 <!-- 248 NOTE: In this document and others in this directory, the convention is to 249 set fixed-width phrases with non-fixed-width spaces, as in 250 `hello` `world`. 251 Do not send CLs removing the interior tags from such phrases. 252 --> 253 254 <style> 255 main ul li { margin: 0.5em 0; } 256 </style> 257 258 ## Introduction to Go 1.21 {#introduction} 259 260 The latest Go release, version 1.21, arrives six months after [Go 1.20](/doc/go1.20). 261 262 ## Changes to the language {#language} 263 264 Go 1.21 adds three new built-ins to the language. 265 266 <!-- https://go.dev/issue/57411 --> 267 Package initialization order is now specified more precisely. The 268 new algorithm is: 269 270 - Sort all packages by import path. 271 - Repeat until the list of packages is empty: 272 - Find the first package in the list for which all imports are 273 already initialized. 274 - Initialize that package and remove it from the list. 275 276 Multiple improvements that increase the power and precision of type inference have been made. 277 278 Go 1.21 includes a preview of a language change we are considering for a future version of Go: 279 making for loop variables per-iteration instead of per-loop, to avoid accidental sharing bugs. 280 281 ## Tools {#tools} 282 283 Go 1.21 adds improved support for backwards compatibility and forwards compatibility 284 in the Go toolchain. 285 286 ### Go command {#go-command} 287 288 The `-C` `dir` flag must now be the first 289 flag on the command-line when used. 290 291 <!-- https://go.dev/issue/37708, CL 463837 --> 292 The new `go` `test` option 293 `-fullpath` prints full path names in test log messages, 294 rather than just base names. 295 296 ### Cgo {#cgo} 297 298 <!-- CL 490819 --> 299 In files that `import "C"`, the Go toolchain now 300 correctly reports errors for attempts to declare Go methods on C types. 301 302 ## Runtime {#runtime-changes} 303 304 <!-- https://go.dev/issue/7181 --> 305 When printing very deep stacks, the runtime now prints the first 50 306 (innermost) frames followed by the bottom 50 (outermost) frames, 307 rather than just printing the first 100 frames. This makes it easier 308 to see how deeply recursive stacks started, and is especially 309 valuable for debugging stack overflows. 310 311 ## Compiler {#compiler} 312 313 Profile-guide optimization (PGO), added as a preview in Go 1.20, is now ready 314 for general use. 315 316 ## Assembler {#assembler} 317 318 319 <!-- https://go.dev/issue/58378 --> 320 321 On amd64, frameless nosplit assembly functions are no longer automatically marked as `NOFRAME`. 322 Instead, the `NOFRAME` attribute must be explicitly specified if desired, 323 which is already the behavior on other architectures supporting frame pointers. 324 With this, the runtime now maintains the frame pointers for stack transitions. 325 326 ## Core library {#library} 327 328 ### New log/slog package {#slog} 329 330 The new [log/slog](/pkg/log/slog) package provides structured logging with levels. 331 332 ### New testing/slogtest package {#slogtest} 333 334 The new [testing/slogtest](/pkg/testing/slogtest) package can help 335 to validate [slog.Handler](/pkg/log/slog#Handler) implementations. 336 337 ### New slices package {#slices} 338 339 The new [slices](/pkg/slices) package provides many common 340 operations on slices, using generic functions that work with slices 341 of any element type. 342 343 ### Minor changes to the library {#minor_library_changes} 344 345 As always, there are various minor changes and updates to the library, 346 made with the Go 1 [promise of compatibility](/doc/go1compat) 347 in mind. 348 There are also various performance improvements, not enumerated here. 349 350 #### [`archive/tar`](/pkg/archive/tar/) 351 352 <!-- https://go.dev/issue/54451, CL 491175 --> 353 The implementation of the 354 [`io/fs.FileInfo`](/pkg/io/fs/#FileInfo) 355 interface returned by 356 [`Header.FileInfo`](/pkg/archive/tar/#Header.FileInfo) 357 now implements a `String` method that calls 358 [`io/fs.FormatFileInfo`](/pkg/io/fs/#FormatFileInfo). 359 360 #### [`archive/zip`](/pkg/archive/zip/) 361 362 <!-- https://go.dev/issue/54451, CL 491175 --> 363 The implementation of the 364 [`io/fs.FileInfo`](/pkg/io/fs/#FileInfo) 365 interface returned by 366 [`FileHeader.FileInfo`](/pkg/archive/zip/#FileHeader.FileInfo) 367 now implements a `String` method that calls 368 [`io/fs.FormatFileInfo`](/pkg/io/fs/#FormatFileInfo). 369 370 #### [`bytes`](/pkg/bytes/) 371 372 <!-- https://go.dev/issue/53685, CL 474635 --> 373 The [`Buffer`](/pkg/bytes/#Buffer) type 374 has two new methods: 375 [`Available`](/pkg/bytes/#Buffer.Available) 376 and [`AvailableBuffer`](/pkg/bytes/#Buffer.AvailableBuffer). 377 These may be used along with the 378 [`Write`](/pkg/bytes/#Buffer.Write) 379 method to append directly to the `Buffer`. 380 ways different. 381 382 #### [`debug/elf`](/pkg/debug/elf/) 383 384 <!-- https://go.dev/issue/56887, CL 452496 --> 385 The constant flags permitted in a `DT_FLAGS_1` 386 dynamic tag are now defined with type 387 [`DynFlag1`](/pkg/debug/elf/#DynFlag1). These 388 tags have names starting with `DF_1`. 389 390 <!-- CL 473256 --> 391 The package now defines the constant 392 [`COMPRESS_ZSTD`](/pkg/debug/elf/#COMPRESS_ZSTD). 393 394 <!-- https://go.dev/issue/56892, CL 452617 --> 395 The new 396 [`File.DynValue`](/pkg/debug/elf/#File.DynValue) 397 method may be used to retrieve the numeric values listed with a 398 given dynamic tag. 399 400 <!-- https://go.dev/issue/60348, CL 496918 --> 401 The package now defines the constant 402 [`R_PPC64_REL24_P9NOTOC`](/pkg/debug/elf/#R_PPC64_REL24_P9NOTOC). 403 404 #### [`net`](/pkg/net/) 405 406 <!-- https://go.dev/issue/59166, https://go.dev/issue/56539 --> 407 <!-- CL 471136, CL 471137, CL 471140 --> 408 On Linux, the [net](/pkg/net/) package can now use 409 Multipath TCP when the kernel supports it. 410 411 #### [`net/http`](/pkg/net/http/) 412 413 <!-- CL 472636 --> 414 The new [`ResponseController.EnableFullDuplex`](/pkg/net/http#ResponseController.EnableFullDuplex) 415 method allows server handlers to concurrently read from an HTTP/1 416 request body while writing the response. Normally, the HTTP/1 server 417 automatically consumes any remaining request body before starting to 418 write the response, to avoid deadlocking clients which attempt to 419 write a complete request before reading the response. The 420 `EnableFullDuplex` method disables this behavior. 421 422 ## Ports {#ports} 423 424 ### Darwin {#darwin} 425 426 <!-- https://go.dev/issue/57125 --> 427 As [announced](go1.20#darwin) in the Go 1.20 release notes, 428 Go 1.21 requires macOS 10.15 Catalina or later; 429 support for previous versions has been discontinued. 430 431 ### WebAssembly {#wasm} 432 433 <!-- https://go.dev/issue/38248, https://go.dev/issue/59149, CL 489255 --> 434 The new `go:wasmimport` directive can now be used in Go programs 435 to import functions from the WebAssembly host. 436 437 <!-- https://go.dev/issue/56100 --> 438 439 The Go scheduler now interacts much more efficiently with the 440 JavaScript event loop, especially in applications that block 441 frequently on asynchronous events. 442 443 ### WebAssembly System Interface {#wasip1} 444 445 <!-- https://go.dev/issue/58141 --> 446 Go 1.21 adds an experimental port to the [ 447 WebAssembly System Interface (WASI)](https://wasi.dev/), Preview 1 448 (`GOOS=wasip1`, `GOARCH=wasm`). 449 450 As a result of the addition of the new `GOOS` value 451 "`wasip1`", Go files named `*_wasip1.go` 452 will now be [ignored 453 by Go tools](/pkg/go/build/#hdr-Build_Constraints) except when that `GOOS` value is being 454 used. 455 If you have existing filenames matching that pattern, you will 456 need to rename them. 457 458 ### Windows {#windows} 459 460 <!-- https://go.dev/issue/57003, https://go.dev/issue/57004 --> 461 As [announced](go1.20#windows) in the Go 1.20 release notes, 462 Go 1.21 requires at least Windows 10 or Windows Server 2016; 463 support for previous versions has been discontinued. 464 465 <!-- CL 470695 --> 466 467 <!-- cmd/dist: default to GOARM=7 on all non-arm systems -->