Dmitri Shuralyov | ed6d739 | 2024-07-22 14:33:50 -0400 | [diff] [blame] | 1 | --- |
| 2 | title: Go 1.24 Release Notes |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 3 | template: false |
Dmitri Shuralyov | ed6d739 | 2024-07-22 14:33:50 -0400 | [diff] [blame] | 4 | --- |
| 5 | |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 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 | `hello` `world`. |
| 10 | --> |
Dmitri Shuralyov | ed6d739 | 2024-07-22 14:33:50 -0400 | [diff] [blame] | 11 | |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 12 | <style> |
| 13 | main ul li { margin: 0.5em 0; } |
| 14 | </style> |
| 15 | |
| 16 | ## DRAFT RELEASE NOTES — Introduction to Go 1.24 {#introduction} |
| 17 | |
| 18 | **Go 1.24 is not yet released. These are work-in-progress release notes. |
| 19 | Go 1.24 is expected to be released in February 2025.** |
| 20 | |
| 21 | ## Changes to the language {#language} |
| 22 | |
| 23 | <!-- go.dev/issue/46477 --> |
| 24 | Go 1.24 now fully supports [generic type aliases](/issue/46477): a type alias |
| 25 | may be parameterized like a defined type. |
| 26 | See the [language spec](/ref/spec#Alias_declarations) for details. |
| 27 | For now, the feature can be disabled by setting `GOEXPERIMENT=noaliastypeparams`; |
| 28 | but the `aliastypeparams` setting will be removed for Go 1.25. |
| 29 | |
| 30 | ## Tools {#tools} |
| 31 | |
| 32 | ### Go command {#go-command} |
| 33 | |
| 34 | <!-- go.dev/issue/48429 --> |
| 35 | |
| 36 | Go modules can now track executable dependencies using `tool` directives in |
| 37 | go.mod. This removes the need for the previous workaround of adding tools as |
| 38 | blank imports to a file conventionally named "tools.go". The `go tool` |
| 39 | command can now run these tools in addition to tools shipped with the Go |
| 40 | distribution. For more information see [the |
| 41 | documentation](/doc/modules/managing-dependencies#tools). |
| 42 | |
| 43 | The new `-tool` flag for `go get` causes a tool directive to be added to the |
| 44 | current module for named packages in addition to adding require directives. |
| 45 | |
| 46 | The new [`tool` meta-pattern](/cmd/go#hdr-Package_lists_and_patterns) refers to |
| 47 | all tools in the current module. This can be used to upgrade them all with `go get -u tool` or to install them into your GOBIN directory with `go install tool`. |
| 48 | |
| 49 | <!-- go.dev/issue/69290 --> |
| 50 | |
Filippo Valsorda | 278ac22 | 2024-12-12 17:12:39 +0100 | [diff] [blame] | 51 | Executables created by `go run` and the new behavior of `go tool` are now |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 52 | cached in the Go build cache. This makes repeated executions faster at the |
| 53 | expense of making the cache larger. See [#69290](/issue/69290). |
| 54 | |
| 55 | <!-- go.dev/issue/62067 --> |
| 56 | |
| 57 | The `go build` and `go install` commands now accept a `-json` flag that reports |
| 58 | build output and failures as structured JSON output on standard output. |
| 59 | For details of the reporting format, see `go help buildjson`. |
| 60 | |
| 61 | Furthermore, `go test -json` now reports build output and failures in JSON, |
| 62 | interleaved with test result JSON. |
| 63 | These are distinguished by new `Action` types, but if they cause problems in |
Filippo Valsorda | 4cfc485 | 2024-12-12 17:12:40 +0100 | [diff] [blame] | 64 | a test integration system, you can revert to the text build output with |
| 65 | [GODEBUG setting](/doc/godebug) `gotestjsonbuildtext=1`. |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 66 | |
Sam Thanawalla | 6046253 | 2024-12-06 15:48:31 +0000 | [diff] [blame] | 67 | <!-- go.dev/issue/26232 --> |
| 68 | |
Dan Peterson | 48fe618 | 2024-12-11 17:00:01 -0400 | [diff] [blame] | 69 | The new `GOAUTH` environment variable provides a flexible way to authenticate |
Filippo Valsorda | 278ac22 | 2024-12-12 17:12:39 +0100 | [diff] [blame] | 70 | private module fetches. See `go help goauth` for more information. |
Sam Thanawalla | 6046253 | 2024-12-06 15:48:31 +0000 | [diff] [blame] | 71 | |
Sam Thanawalla | a379667 | 2024-12-06 13:44:18 +0000 | [diff] [blame] | 72 | <!-- go.dev/issue/50603 --> |
| 73 | |
Filippo Valsorda | 2a8b895 | 2024-12-12 17:12:41 +0100 | [diff] [blame^] | 74 | The `go build` command now sets the |
| 75 | [main module's version](/pkg/runtime/debug#BuildInfo.Main) in the compiled |
| 76 | binary based on the version control system tag and/or commit. |
| 77 | A `+dirty` suffix will be appended if there are uncommitted changes. |
Sam Thanawalla | a379667 | 2024-12-06 13:44:18 +0000 | [diff] [blame] | 78 | Use the `-buildvcs=false` flag to omit version control information from the binary. |
| 79 | |
Sam Thanawalla | 6ec293f | 2024-12-06 19:37:37 +0000 | [diff] [blame] | 80 | <!-- go.dev/issue/63939 --> |
| 81 | |
| 82 | The new [GODEBUG setting](/doc/godebug) [`toolchaintrace=1`](/doc/toolchain#select) |
| 83 | can be used to trace the `go` command's toolchain selection process. |
| 84 | |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 85 | ### Cgo {#cgo} |
| 86 | |
| 87 | <!-- go.dev/issue/56378, CL 579955 --> |
| 88 | Cgo supports new annotations for C functions to improve run time |
| 89 | performance. |
| 90 | `#cgo noescape cFunctionName` tells the compiler that memory passed to |
| 91 | the C function `cFunctionname` does not escape. |
| 92 | `#cgo nocallback cFunctionName` tells the compiler that the C function |
| 93 | `cFunctionName` does not call back to any Go functions. |
| 94 | For more information, see [the cgo documentation](/pkg/cmd/cgo#hdr-Optimizing_calls_of_C_code). |
| 95 | |
| 96 | <!-- go.dev/issue/67699 --> |
| 97 | Cgo currently refuses to compile calls to a C function which has multiple |
| 98 | incompatible declarations. For instance, if `f` is declared as both `void f(int)` |
| 99 | and `void f(double)`, cgo will report an error instead of possibly generating an |
| 100 | incorrect call sequence for `f(0)`. New in this release is a better detector for |
| 101 | this error condition when the incompatible declarations appear in different |
| 102 | files. See [#67699](/issue/67699). |
| 103 | |
| 104 | ### Vet |
| 105 | |
| 106 | <!-- go.dev/issue/44251 --> |
| 107 | The new `tests` analyzer reports common mistakes in declarations of |
| 108 | tests, fuzzers, benchmarks, and examples in test packages, such as |
| 109 | malformed names, incorrect signatures, or examples that document |
| 110 | non-existent identifiers. Some of these mistakes may cause tests not |
| 111 | to run. |
| 112 | This analyzer is among the subset of analyzers that are run by `go test`. |
| 113 | |
| 114 | <!-- go.dev/issue/60529 --> |
| 115 | The existing `printf` analyzer now reports a diagnostic for calls of |
| 116 | the form `fmt.Printf(s)`, where `s` is a non-constant format string, |
| 117 | with no other arguments. Such calls are nearly always a mistake |
| 118 | as the value of `s` may contain the `%` symbol; use `fmt.Print` instead. |
| 119 | See [#60529](/issue/60529). |
| 120 | |
| 121 | <!-- go.dev/issue/64127 --> |
| 122 | The existing `buildtag` analyzer now reports a diagnostic when |
| 123 | there is an invalid Go [major version build constraint](/pkg/cmd/go#hdr-Build_constraints) |
| 124 | within a `//go:build` directive. For example, `//go:build go1.23.1` refers to |
| 125 | a point release; use `//go:build go1.23` instead. |
| 126 | See [#64127](/issue/64127). |
| 127 | |
| 128 | <!-- go.dev/issue/66387 --> |
| 129 | The existing `copylock` analyzer now reports a diagnostic when a |
| 130 | variable declared in a 3-clause "for" loop such as |
| 131 | `for i := iter(); done(i); i = next(i) { ... }` contains a `sync.Locker`, |
| 132 | such as a `sync.Mutex`. [Go 1.22](/doc/go1.22#language) changed the behavior |
| 133 | of these loops to create a new variable for each iteration, copying the |
| 134 | value from the previous iteration; this copy operation is not safe for locks. |
| 135 | See [#66387](/issue/66387). |
| 136 | |
| 137 | ### GOCACHEPROG |
| 138 | |
| 139 | <!-- go.dev/issue/64876 --> |
| 140 | The `cmd/go` internal binary and test caching mechanism can now be implemented |
| 141 | by child processes implementing a JSON protocol between the `cmd/go` tool |
| 142 | and the child process named by the `GOCACHEPROG` environment variable. |
| 143 | This was previously behind a GOEXPERIMENT. |
| 144 | For protocol details, see [#59719](/issue/59719). |
| 145 | |
| 146 | ## Runtime {#runtime} |
| 147 | |
| 148 | <!-- go.dev/issue/54766 --> |
| 149 | <!-- go.dev/cl/614795 --> |
| 150 | <!-- go.dev/issue/68578 --> |
| 151 | |
| 152 | Several performance improvements to the runtime have decreased CPU overheads by |
| 153 | 2—3% on average across a suite of representative benchmarks. |
| 154 | Results may vary by application. |
| 155 | These improvements include a new builtin `map` implementation based on |
| 156 | [Swiss Tables](https://abseil.io/about/design/swisstables), more efficient |
| 157 | memory allocation of small objects, and a new runtime-internal mutex |
| 158 | implementation. |
| 159 | |
| 160 | The new builtin `map` implementation and new runtime-internal mutex may be |
| 161 | disabled by setting `GOEXPERIMENT=noswissmap` and `GOEXPERIMENT=nospinbitmutex` |
| 162 | at build time respectively. |
| 163 | |
Carlos Amedee | 41b60ae | 2024-12-11 11:16:57 -0500 | [diff] [blame] | 164 | The new [`AddCleanup`](/pkg/runtime#AddCleanup) function attaches a cleanup |
| 165 | function to a pointer. Once the object that the pointer points to is no longer |
| 166 | reachable, the runtime will call the function. |
| 167 | [`AddCleanup`](/pkg/runtime#AddCleanup) is a finalization mechanism that is |
| 168 | more flexible and less error-prone than [`SetFinalizer`](/pkg/runtime#SetFinalizer). |
| 169 | Unlike [`SetFinalizer`](/pkg/runtime#SetFinalizer), it does not resurrect the |
| 170 | object it is attached to for finalization and multiple cleanups may be attached |
| 171 | to a single object. New code should prefer [`AddCleanup`](/pkg/runtime#AddCleanup) |
| 172 | over [`SetFinalizer`](/pkg/runtime#SetFinalizer). |
| 173 | |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 174 | ## Compiler {#compiler} |
| 175 | |
| 176 | <!-- go.dev/issue/60725, go.dev/issue/57926 --> |
| 177 | The compiler already disallowed defining new methods with receiver types that were |
| 178 | cgo-generated, but it was possible to circumvent that restriction via an alias type. |
| 179 | Go 1.24 now always reports an error if a receiver denotes a cgo-generated type, |
| 180 | whether directly or indirectly (through an alias type). |
| 181 | |
| 182 | ## Linker {#linker} |
| 183 | |
| 184 | <!-- go.dev/issue/68678, go.dev/issue/68652, CL 618598, CL 618601 --> |
| 185 | The linker now generates a GNU build ID (the ELF `NT_GNU_BUILD_ID` note) on ELF platforms |
| 186 | and a UUID (the Mach-O `LC_UUID` load command) on macOS by default. |
| 187 | The build ID or UUID is derived from the Go build ID. |
| 188 | It can be disabled by the `-B none` linker flag, or overridden by the `-B 0xNNNN` linker |
| 189 | flag with a user-specified hexadecimal value. |
| 190 | |
| 191 | ## Bootstrap {#bootstrap} |
| 192 | |
| 193 | <!-- go.dev/issue/64751 --> |
| 194 | As mentioned in the [Go 1.22 release notes](/doc/go1.22#bootstrap), Go 1.24 now requires |
| 195 | Go 1.22.6 or later for bootstrap. |
| 196 | We expect that Go 1.26 will require a point release of Go 1.24 or later for bootstrap. |
| 197 | |
| 198 | ## Standard library {#library} |
| 199 | |
| 200 | ### Directory-limited filesystem access |
| 201 | |
| 202 | <!-- go.dev/issue/67002 --> |
| 203 | The new [`os.Root`](/pkg/os#Root) type provides the ability to perform filesystem |
| 204 | operations within a specific directory. |
| 205 | |
| 206 | The [`os.OpenRoot`](/pkg/os#OpenRoot) function opens a directory and returns an [`os.Root`](/pkg/os#Root). |
| 207 | Methods on [`os.Root`](/pkg/os#Root) operate within the directory and do not permit |
| 208 | paths that refer to locations outside the directory, including |
| 209 | ones that follow symbolic links out of the directory. |
| 210 | |
| 211 | - [`os.Root.Open`](/pkg/os#Root.Open) opens a file for reading. |
| 212 | - [`os.Root.Create`](/pkg/os#Root.Create) creates a file. |
| 213 | - [`os.Root.OpenFile`](/pkg/os#Root.OpenFile) is the generalized open call. |
| 214 | - [`os.Root.Mkdir`](/pkg/os#Root.Mkdir) creates a directory. |
| 215 | |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 216 | ### New benchmark function |
| 217 | |
Junyang Shao | f18c77d | 2024-12-06 01:02:38 +0000 | [diff] [blame] | 218 | Benchmarks may now use the faster and less error-prone [`testing.B.Loop`](/pkg/testing#B.Loop) method to perform benchmark iterations like `for b.Loop() { ... }` in place of the typical loop structures involving `b.N` like `for range b.N`. This offers two significant advantages: |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 219 | - The benchmark function will execute exactly once per -count, so expensive setup and cleanup steps execute only once. |
| 220 | - Function call parameters and results are kept alive, preventing the compiler from fully optimizing away the loop body. |
| 221 | |
Dmitri Shuralyov | d0767cd | 2024-12-05 18:14:18 -0500 | [diff] [blame] | 222 | ### New crypto/mlkem package {#crypto-mlkem} |
| 223 | |
| 224 | <!-- go.dev/issue/70122 --> |
Dmitri Shuralyov | d0767cd | 2024-12-05 18:14:18 -0500 | [diff] [blame] | 225 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 226 | The new [`crypto/mlkem`](/pkg/crypto/mlkem/) package implements |
| 227 | ML-KEM-768 and ML-KEM-1024. |
Dmitri Shuralyov | d0767cd | 2024-12-05 18:14:18 -0500 | [diff] [blame] | 228 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 229 | ML-KEM is a post-quantum key exchange mechanism formerly known as Kyber and |
| 230 | specified in [FIPS 203](https://doi.org/10.6028/NIST.FIPS.203). |
Dmitri Shuralyov | d0767cd | 2024-12-05 18:14:18 -0500 | [diff] [blame] | 231 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 232 | ### New crypto/hkdf, crypto/pbkdf2, and crypto/sha3 packages {#crypto-packages} |
Dmitri Shuralyov | d0767cd | 2024-12-05 18:14:18 -0500 | [diff] [blame] | 233 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 234 | <!-- go.dev/issue/61477, go.dev/issue/69488, go.dev/issue/69982, go.dev/issue/65269, CL 629176 --> |
| 235 | |
| 236 | The new [`crypto/hkdf`](/pkg/crypto/hkdf/) package implements |
| 237 | the HMAC-based Extract-and-Expand key derivation function HKDF, |
| 238 | as defined in [RFC 5869](https://www.rfc-editor.org/rfc/rfc5869.html). |
| 239 | |
| 240 | The new [`crypto/pbkdf2`](/pkg/crypto/pbkdf2/) package implements |
| 241 | the password-based key derivation function PBKDF2, |
| 242 | as defined in [RFC 8018](https://www.rfc-editor.org/rfc/rfc8018.html). |
| 243 | |
| 244 | The new [`crypto/sha3`](/pkg/crypto/sha3/) package implements |
| 245 | the SHA-3 hash function and SHAKE and cSHAKE extendable-output functions, |
| 246 | as defined in [FIPS 202](http://doi.org/10.6028/NIST.FIPS.202). |
| 247 | |
| 248 | All three packages are based on pre-existing `golang.org/x/crypto/...` packages. |
Dmitri Shuralyov | d0767cd | 2024-12-05 18:14:18 -0500 | [diff] [blame] | 249 | |
| 250 | ### New weak package {#weak} |
| 251 | |
| 252 | The new [`weak`](/pkg/weak/) package provides weak pointers. |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 253 | |
| 254 | Weak pointers are a low-level primitive provided to enable the |
| 255 | creation of memory-efficient structures, such as weak maps for |
| 256 | associating values, canonicalization maps for anything not |
Dmitri Shuralyov | d0767cd | 2024-12-05 18:14:18 -0500 | [diff] [blame] | 257 | covered by package [`unique`](/pkg/unique/), and various kinds |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 258 | of caches. |
| 259 | For supporting these use-cases, this release also provides |
Dmitri Shuralyov | d0767cd | 2024-12-05 18:14:18 -0500 | [diff] [blame] | 260 | [`runtime.AddCleanup`](/pkg/runtime/#AddCleanup) and |
| 261 | [`maphash.Comparable`](/pkg/maphash/#Comparable). |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 262 | |
Damien Neil | 4827ea8 | 2024-12-10 15:29:47 -0800 | [diff] [blame] | 263 | ### New experimental testing/synctest package {#testing-synctest} |
| 264 | |
| 265 | The new experimental [`testing/synctest`](/pkg/testing/synctest/) package |
| 266 | provides support for testing concurrent code. |
| 267 | - The [`synctest.Run`](/pkg/testing/synctest/#Run) function starts a |
| 268 | group of goroutines in an isolated "bubble". |
| 269 | Within the bubble, [`time`](/pkg/time) package functions operate on a |
| 270 | fake clock. |
| 271 | - The [`synctest.Wait`](/pkg/testing/synctest#Wait) function waits for |
| 272 | all goroutines in the current bubble to block. |
| 273 | |
| 274 | See the package documentation for more details. |
| 275 | |
| 276 | The `synctest` package is experimental and must be enabled by |
| 277 | setting `GOEXPERIMENT=synctest` at build time. |
| 278 | The package API is subject to change in future releases. |
Damien Neil | 9382220 | 2024-12-11 09:53:11 -0800 | [diff] [blame] | 279 | See [issue #67434](/issue/67434) for more information and |
| 280 | to provide feeback. |
Damien Neil | 4827ea8 | 2024-12-10 15:29:47 -0800 | [diff] [blame] | 281 | |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 282 | ### Minor changes to the library {#minor_library_changes} |
| 283 | |
| 284 | #### [`archive`](/pkg/archive/) |
| 285 | |
| 286 | The `(*Writer).AddFS` implementations in both `archive/zip` and `archive/tar` |
| 287 | now write a directory header for an empty directory. |
| 288 | |
| 289 | #### [`bytes`](/pkg/bytes/) |
| 290 | |
| 291 | The [`bytes`](/pkg/bytes) package adds several functions that work with iterators: |
| 292 | - [`Lines`](/pkg/bytes#Lines) returns an iterator over the |
| 293 | newline-terminated lines in the byte slice s. |
| 294 | - [`SplitSeq`](/pkg/bytes#SplitSeq) returns an iterator over |
| 295 | all substrings of s separated by sep. |
| 296 | - [`SplitAfterSeq`](/pkg/bytes#SplitAfterSeq) returns an iterator |
| 297 | over substrings of s split after each instance of sep. |
| 298 | - [`FieldsSeq`](/pkg/bytes#FieldsSeq) returns an iterator over |
| 299 | substrings of s split around runs of whitespace characters, |
| 300 | as defined by unicode.IsSpace. |
| 301 | - [`FieldsFuncSeq`](/pkg/bytes#FieldsFuncSeq) returns an iterator |
| 302 | over substrings of s split around runs of Unicode code points satisfying f(c). |
| 303 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 304 | #### [`crypto/aes`](/pkg/crypto/aes/) |
| 305 | |
| 306 | The value returned by [`NewCipher`](/pkg/crypto/aes#NewCipher) no longer |
| 307 | implements the `NewCTR`, `NewGCM`, `NewCBCEncrypter`, and `NewCBCDecrypter` |
| 308 | methods. These methods were undocumented and not available on all architectures. |
| 309 | Instead, the [`Block`](/pkg/crypto/cipher#Block) value should be passed |
| 310 | directly to the relevant [`crypto/cipher`](/pkg/crypto/cipher/) functions. |
| 311 | For now, `crypto/cipher` still checks for those methods on `Block` values, |
| 312 | even if they are not used by the standard library anymore. |
| 313 | |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 314 | #### [`crypto/cipher`](/pkg/crypto/cipher/) |
| 315 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 316 | The new [`NewGCMWithRandomNonce`](/pkg/crypto/cipher#NewGCMWithRandomNonce) |
| 317 | function returns an [`AEAD`](/pkg/crypto/cipher#AEAD) that implements AES-GCM by |
| 318 | generating a random nonce during Seal and prepending it to the ciphertext. |
| 319 | |
| 320 | The [`Stream`](/pkg/crypto/cipher#Stream) implementation returned by |
| 321 | [`NewCTR`](/pkg/crypto/cipher#NewCTR) when used with |
| 322 | [`crypto/aes`](/pkg/crypto/aes/) is now several times faster on amd64 and arm64. |
| 323 | |
| 324 | [`NewOFB`](/pkg/crypto/cipher#NewOFB), |
| 325 | [`NewCFBEncrypter`](/pkg/crypto/cipher#NewCFBEncrypter), and |
| 326 | [`NewCFBDecrypter`](/pkg/crypto/cipher#NewCFBDecrypter) are now deprecated. |
| 327 | OFB and CFB mode are not authenticated, which generally enables active attacks to |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 328 | manipulate and recover the plaintext. It is recommended that applications use |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 329 | [`AEAD`](/pkg/crypto/cipher#AEAD) modes instead. If an unauthenticated |
| 330 | [`Stream`](/pkg/crypto/cipher#Stream) mode is required, use |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 331 | [`NewCTR`](/pkg/crypto/cipher#NewCTR) instead. |
| 332 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 333 | #### [`crypto/ecdsa`](/pkg/crypto/ecdsa/) |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 334 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 335 | <!-- go.dev/issue/64802 --> |
| 336 | [`PrivateKey.Sign`](/pkg/crypto/ecdsa#PrivateKey.Sign) now produces a |
| 337 | deterministic signature according to |
| 338 | [RFC 6979](https://www.rfc-editor.org/rfc/rfc6979.html) if rand is nil. |
| 339 | |
| 340 | <!-- #### [`crypto/fips140`](/pkg/crypto/fips140/) |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 341 | |
Dmitri Shuralyov | d0767cd | 2024-12-05 18:14:18 -0500 | [diff] [blame] | 342 | TODO: FIPS 140 will be covered in its own section. |
Dmitri Shuralyov | 193b880 | 2024-12-11 13:46:39 -0500 | [diff] [blame] | 343 | TODO: accepted [proposal #70200](/issue/70200) (from [CL 629196](/cl/629196), [CL 629198](/cl/629198), [CL 629201](/cl/629201), [CL 629996](/cl/629996)) |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 344 | TODO: crypto/tls FIPS mode from CL 629675. --> |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 345 | |
| 346 | #### [`crypto/md5`](/pkg/crypto/md5/) |
| 347 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 348 | The value returned by [`md5.New`](/pkg/md5#New) now also implements the |
| 349 | [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface. |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 350 | |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 351 | #### [`crypto/rand`](/pkg/crypto/rand/) |
| 352 | |
Dmitri Shuralyov | 193b880 | 2024-12-11 13:46:39 -0500 | [diff] [blame] | 353 | <!-- go.dev/issue/66821 --> |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 354 | The [`Read`](/pkg/crypto/rand#Read) function is now guaranteed not to fail. |
| 355 | It will always return `nil` as the `error` result. |
| 356 | If `Read` were to encounter an error while reading from |
| 357 | [`Reader`](/pkg/crypto/rand#Reader), the program will irrecoverably crash. |
| 358 | Note that the platform APIs used by the default `Reader` are documented to |
| 359 | always succeed, so this change should only affect programs that override the |
| 360 | `Reader` variable. One exception are Linux kernels before version 3.17, where |
| 361 | the default `Reader` still opens `/dev/urandom` and may fail. |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 362 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 363 | <!-- go.dev/issue/69577 --> |
| 364 | On Linux 6.11 and later, `Reader` now uses the `getrandom` vDSO. |
| 365 | This is several times faster, especially for small reads. |
| 366 | |
| 367 | <!-- CL 608395 --> |
| 368 | On OpenBSD, `Reader` now uses `arc4random_buf(3)`. |
| 369 | |
| 370 | <!-- go.dev/issue/67057 --> |
| 371 | The new [`Text`](/pkg/crypto/rand#Text) function can be used to generate |
| 372 | cryptographically secure random text strings. |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 373 | |
| 374 | #### [`crypto/rsa`](/pkg/crypto/rsa/) |
| 375 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 376 | [`GenerateKey`](/pkg/crypto/rsa#GenerateKey) now returns an error if a key of |
| 377 | less than 1024 bits is requested. |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 378 | All Sign, Verify, Encrypt, and Decrypt methods now return an error if used with |
| 379 | a key smaller than 1024 bits. Such keys are insecure and should not be used. |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 380 | [GODEBUG setting](/doc/godebug) `rsa1024min=0` restores the old behavior, but we |
| 381 | recommend doing so only if necessary and only in tests, for example by adding a |
| 382 | `//go:debug rsa1024min=0` line to a test file. |
| 383 | A new [`GenerateKey`](/pkg/crypto/rsa#GenerateKey) example provides an |
| 384 | easy-to-use standard 2048-bit test key. |
| 385 | |
| 386 | It is now safe and more efficient to call |
| 387 | [`PrivateKey.Precompute`](/pkg/crypto/rsa#PrivateKey.Precompute) before |
| 388 | [`PrivateKey.Validate`](/pkg/crypto/rsa#PrivateKey.Validate). |
| 389 | |
| 390 | The package now rejects more invalid keys, and |
| 391 | [`GenerateKey`](/pkg/crypto/rsa#GenerateKey) may return new errors for broken |
| 392 | random sources. See also the changes to [`crypto/x509`](#cryptox509pkgcryptox509) below. |
| 393 | |
| 394 | <!-- go.dev/issue/43923 --> |
| 395 | [`SignPKCS1v15`](/pkg/crypto/rsa#SignPKCS1v15) and |
| 396 | [`VerifyPKCS1v15`](/pkg/crypto/rsa#VerifyPKCS1v15) now support |
| 397 | SHA-512/224, SHA-512/256, and SHA-3. |
| 398 | |
| 399 | <!-- CL 626957 --> |
| 400 | Public and private key operations are now up to two times faster on wasm. |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 401 | |
| 402 | #### [`crypto/sha1`](/pkg/crypto/sha1/) |
| 403 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 404 | The value returned by [`sha1.New`](/pkg/sha1#New) now also implements |
| 405 | the [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface. |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 406 | |
| 407 | #### [`crypto/sha256`](/pkg/crypto/sha256/) |
| 408 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 409 | The values returned by [`sha256.New`](/pkg/sha256#New) and |
| 410 | [`sha256.New224`](/pkg/sha256#New224) now also implement the |
| 411 | [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 412 | |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 413 | #### [`crypto/sha512`](/pkg/crypto/sha512/) |
| 414 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 415 | The values returned by [`sha512.New`](/pkg/sha512#New), |
| 416 | [`sha512.New384`](/pkg/sha512#New384), |
| 417 | [`sha512.New512_224`](/pkg/sha512#New512_224) and |
| 418 | [`sha512.New512_256`](/pkg/sha512#New512_256) now also implement the |
| 419 | [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface. |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 420 | |
| 421 | #### [`crypto/subtle`](/pkg/crypto/subtle/) |
| 422 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 423 | The new [`WithDataIndependentTiming`](/pkg/crypto/subtle#WithDataIndependentTiming) |
| 424 | function allows the user to run a function with architecture specific features |
| 425 | enabled which guarantee specific instructions are data value timing invariant. |
| 426 | This can be used to make sure that code designed to run in constant time is not |
| 427 | optimized by CPU-level features such that it operates in variable time. |
| 428 | Currently, `WithDataIndependentTiming` uses the PSTATE.DIT bit on arm64, and is |
| 429 | a no-op on all other architectures. [GODEBUG setting](/doc/godebug) |
| 430 | `dataindependenttiming=1` enables the DIT mode for the entire Go program. |
| 431 | |
| 432 | <!-- CL 622276 --> |
| 433 | The [`XORBytes`](/pkg/crypto/subtle#XORBytes) output must overlap exactly or not |
| 434 | at all with the inputs. Previously, the behavior was otherwise undefined, while |
| 435 | now `XORBytes` will panic. |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 436 | |
| 437 | #### [`crypto/tls`](/pkg/crypto/tls/) |
| 438 | |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 439 | The TLS server now supports Encrypted Client Hello (ECH). This feature can be |
| 440 | enabled by populating the [`Config.EncryptedClientHelloKeys`](/pkg/crypto/tls#Config.EncryptedClientHelloKeys) field. |
| 441 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 442 | The new post-quantum [`X25519MLKEM768`](/pkg/crypto/tls#X25519MLKEM768) key |
| 443 | exchange mechanism is now supported and is enabled by default when |
| 444 | [`Config.CurvePreferences`](/pkg/crypto/tls#Config.CurvePreferences) is nil. |
| 445 | [GODEBUG setting](/doc/godebug) `tlsmlkem=0` reverts the default. |
| 446 | |
| 447 | Support for the experimental `X25519Kyber768Draft00` key exchange has been removed. |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 448 | |
Dmitri Shuralyov | 193b880 | 2024-12-11 13:46:39 -0500 | [diff] [blame] | 449 | <!-- go.dev/issue/69393, CL 630775 --> |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 450 | Key exchange ordering is now handled entirely by the `crypto/tls` package. The |
| 451 | order of [`Config.CurvePreferences`](/pkg/crypto/tls#Config.CurvePreferences) is |
| 452 | now ignored, and the contents are only used to determine which key exchanges to |
| 453 | enable when the field is populated. |
| 454 | |
| 455 | <!-- go.dev/issue/32936 --> |
| 456 | The new [`ClientHelloInfo.Extensions`](/pkg/crypto/tls#ClientHelloInfo.Extensions) |
| 457 | field lists the IDs of the extensions received in the Client Hello message. |
| 458 | This can be useful for fingerprinting TLS clients. |
Roland Shoemaker | ed80a58 | 2024-12-05 14:53:55 -0800 | [diff] [blame] | 459 | |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 460 | #### [`crypto/x509`](/pkg/crypto/x509/) |
| 461 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 462 | <!-- go.dev/issue/41682 --> |
| 463 | The `x509sha1` [GODEBUG setting](/doc/godebug) has been removed. |
| 464 | [`Certificate.Verify`](/pkg/crypto/x509#Certificate.Verify) no longer |
| 465 | supports SHA-1 based signatures. |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 466 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 467 | [`OID`](/pkg/crypto/x509#OID) now implements the |
| 468 | [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) and |
| 469 | [`encoding.TextAppender`](/pkg/encoding#TextAppender) interfaces. |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 470 | |
| 471 | The default certificate policies field has changed from |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 472 | [`Certificate.PolicyIdentifiers`](/pkg/crypto/x509#Certificate.PolicyIdentifiers) |
| 473 | to [`Certificate.Policies`](/pkg/crypto/x509#Certificate.Policies). When parsing |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 474 | certificates, both fields will be populated, but when creating certificates |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 475 | policies will now be taken from the `Certificate.Policies` field instead of |
| 476 | the `Certificate.PolicyIdentifiers` field. This change can be reverted with |
| 477 | [GODEBUG setting](/doc/godebug) `x509usepolicies=0`. |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 478 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 479 | <!-- go.dev/issue/67675 --> |
| 480 | [`CreateCertificate`](/pkg/crypto/x509#CreateCertificate) will now generate a |
| 481 | serial number using a RFC 5280 compliant method when passed a template with a |
| 482 | nil [`Certificate.SerialNumber`](/pkg/crypto/x509#Certificate.SerialNumber) |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 483 | field, instead of failing. |
| 484 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 485 | [`Certificate.Verify`](/pkg/crypto/x509#Certificate.Verify) now supports policy |
| 486 | validation, as defined in RFC 5280 and RFC 9618. The new |
| 487 | [`VerifyOptions.CertificatePolicies`](/pkg/crypto/x509#VerifyOptions.CertificatePolicies) |
| 488 | field can be set to an acceptable set of policy [`OIDs`](/pkg/crypto/x509#OID). |
| 489 | Only certificate chains with valid policy graphs will be returned from |
| 490 | [`Certificate.Verify`](/pkg/crypto/x509#Certificate.Verify). |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 491 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 492 | [`MarshalPKCS8PrivateKey`](/pkg/crypto/x509#MarshalPKCS8PrivateKey) now returns |
| 493 | an error instead of marshaling an invalid RSA key. |
| 494 | ([`MarshalPKCS1PrivateKey`](/pkg/crypto/x509#MarshalPKCS1PrivateKey) doesn't |
| 495 | have an error return, and its behavior when provided invalid keys continues to |
| 496 | be undefined.) |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 497 | |
Filippo Valsorda | 22adbef | 2024-12-12 17:12:36 +0100 | [diff] [blame] | 498 | [`ParsePKCS1PrivateKey`](/pkg/crypto/x509#ParsePKCS1PrivateKey) and |
| 499 | [`ParsePKCS8PrivateKey`](/pkg/crypto/x509#ParsePKCS8PrivateKey) now use and |
| 500 | validate the encoded CRT values, so might reject invalid RSA keys that were |
| 501 | previously accepted. Use [GODEBUG setting](/doc/godebug) `x509rsacrt=0` to |
| 502 | revert to recomputing the CRT values. |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 503 | |
| 504 | #### [`debug/elf`](/pkg/debug/elf/) |
| 505 | |
| 506 | The [`debug/elf`](/pkg/debug/elf) package adds several new constants, types, and methods to add support for handling dynamic versions and version flags in ELF (Executable and Linkable Format) files: |
| 507 | |
| 508 | Several new types have been introduced: |
| 509 | - [`DynamicVersion`](/pkg/debug/elf#DynamicVersion) struct represents a dynamic version entry in the ELF file. |
| 510 | - [`DynamicVersionDep`](/pkg/debug/elf#DynamicVersionDep) struct represents a dependency of a dynamic version. |
| 511 | - [`DynamicVersionNeed`](/pkg/debug/elf#DynamicVersionNeed) struct represents a required dynamic version in the ELF file. |
| 512 | - [`DynamicVersionFlag`](/pkg/debug/elf#DynamicVersionFlag) is a new type defined as uint16, representing flags for dynamic versions. |
| 513 | - [`VER_FLG_BASE`](/pkg/debug/elf#VER_FLG_BASE) version definition of the file. |
| 514 | - [`VER_FLG_WEAK`](/pkg/debug/elf#VER_FLG_WEAK) weak version identifier. |
| 515 | - [`VER_FLG_INFO`](/pkg/debug/elf#VER_FLG_INFO) reference exists for informational purposes. |
| 516 | - [`SymbolVersionFlag`](/pkg/debug/elf#SymbolVersionFlag) is a new type defined as uint8, representing version flags for ELF symbols. |
| 517 | - [`VerFlagNone`](/pkg/debug/elf#VerFlagNone) no flags. |
| 518 | - [`VerFlagLocal`](/pkg/debug/elf#VerFlagLocal) symbol has local scope. |
| 519 | - [`VerFlagGlobal`](/pkg/debug/elf#VerFlagGlobal) symbol has global scope. |
| 520 | - [`VerFlagHidden`](/pkg/debug/elf#VerFlagHidden) symbol is hidden. |
| 521 | |
| 522 | The following methods have been added: |
| 523 | - [`File.DynamicVersionNeeds`](/pkg/debug/elf#File.DynamicVersionNeeds) method returns a list of dynamic version needs in the ELF file, representing dependencies required by the executable. |
| 524 | - [`File.DynamicVersions`](/pkg/debug/elf#File.DynamicVersions) retrieves a list of dynamic versions defined in the ELF file. |
| 525 | <!-- go.dev/issue/63952 --> |
| 526 | |
| 527 | #### [`encoding`](/pkg/encoding/) |
| 528 | |
| 529 | Two new interfaces, [`TextAppender`](/pkg/encoding#TextAppender) and [`BinaryAppender`](/pkg/encoding#BinaryAppender), have been |
| 530 | introduced to append the textual or binary representation of an object |
| 531 | to a byte slice. These interfaces provide the same functionality as |
| 532 | [`TextMarshaler`](/pkg/encoding#TextMarshaler) and [`BinaryMarshaler`](/pkg/encoding#BinaryMarshaler), but instead of allocating a new slice |
| 533 | each time, they append the data directly to an existing slice. |
| 534 | |
| 535 | #### [`encoding/json`](/pkg/encoding/json/) |
| 536 | |
| 537 | When marshaling, a struct field with the new `omitzero` option in the struct field |
| 538 | tag will be omitted if its value is zero. If the field type has an `IsZero() bool` |
| 539 | method, that will be used to determine whether the value is zero. Otherwise, the |
| 540 | value is zero if it is [the zero value for its type](/ref/spec#The_zero_value). |
| 541 | |
| 542 | If both `omitempty` and `omitzero` are specified, the field will be omitted if the |
| 543 | value is either empty or zero (or both). |
| 544 | |
| 545 | [`UnmarshalTypeError.Field`](/pkg/encoding/json#UnmarshalTypeError.Field) now includes embedded structs to provide more detailed error messages. |
| 546 | |
| 547 | #### [`go/types`](/pkg/go/types/) |
| 548 | |
| 549 | All `go/types` data structures that expose sequences using a pair of |
| 550 | methods such as `Len() int` and `At(int) T` now also have methods that |
| 551 | return iterators, allowing you to simplify code such as this: |
| 552 | |
| 553 | ``` |
| 554 | params := fn.Type.(*types.Signature).Params() |
| 555 | for i := 0; i < params.Len(); i++ { |
| 556 | use(params.At(i)) |
| 557 | } |
| 558 | ``` |
| 559 | |
| 560 | to this: |
| 561 | |
| 562 | ``` |
| 563 | for param := range fn.Signature().Params().Variables() { |
| 564 | use(param) |
| 565 | } |
| 566 | ``` |
| 567 | |
| 568 | The methods are: |
| 569 | [`Interface.EmbeddedTypes`](/pkg/go/types#Interface.EmbeddedTypes), |
| 570 | [`Interface.ExplicitMethods`](/pkg/go/types#Interface.ExplicitMethods), |
| 571 | [`Interface.Methods`](/pkg/go/types#Interface.Methods), |
| 572 | [`MethodSet.Methods`](/pkg/go/types#MethodSet.Methods), |
| 573 | [`Named.Methods`](/pkg/go/types#Named.Methods), |
| 574 | [`Scope.Children`](/pkg/go/types#Scope.Children), |
| 575 | [`Struct.Fields`](/pkg/go/types#Struct.Fields), |
| 576 | [`Tuple.Variables`](/pkg/go/types#Tuple.Variables), |
| 577 | [`TypeList.Types`](/pkg/go/types#TypeList.Types), |
| 578 | [`TypeParamList.TypeParams`](/pkg/go/types#TypeParamList.TypeParams), |
| 579 | [`Union.Terms`](/pkg/go/types#Union.Terms). |
| 580 | |
| 581 | #### [`hash/adler32`](/pkg/hash/adler32/) |
| 582 | |
| 583 | The value returned by [`New`](/pkg/hash/adler32#New) now also implements the [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface. |
| 584 | |
| 585 | #### [`hash/crc32`](/pkg/hash/crc32/) |
| 586 | |
| 587 | The values returned by [`New`](/pkg/hash/crc32#New) and [`NewIEEE`](/pkg/hash/crc32#NewIEEE) now also implement the [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface. |
| 588 | |
| 589 | #### [`hash/crc64`](/pkg/hash/crc64/) |
| 590 | |
| 591 | The value returned by [`New`](/pkg/hash/crc64#New) now also implements the [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface. |
| 592 | |
| 593 | #### [`hash/fnv`](/pkg/hash/fnv/) |
| 594 | |
| 595 | The values returned by [`New32`](/pkg/hash/fnv#New32), [`New32a`](/pkg/hash/fnv#New32a), [`New64`](/pkg/hash/fnv#New64), [`New64a`](/pkg/hash/fnv#New64a), [`New128`](/pkg/hash/fnv#New128) and [`New128a`](/pkg/hash/fnv#New128a) now also implement the [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface. |
| 596 | |
| 597 | #### [`hash/maphash`](/pkg/hash/maphash/) |
| 598 | |
Cherry Mui | 6a17f90 | 2024-12-09 22:17:05 -0500 | [diff] [blame] | 599 | New function [`Comparable`](/pkg/hash/maphash#Comparable) returns the hash of a comparable value. |
| 600 | New function [`WriteComparable`](/pkg/hash/maphash#WriteComparable) adds a comparable value to the data hashed by a [`Hash`](/pkg/hash/maphash#Hash). |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 601 | |
| 602 | #### [`log/slog`](/pkg/log/slog/) |
| 603 | |
| 604 | The new [`DiscardHandler`](/pkg/log/slog#DiscardHandler) is a handler that is never enabled and always discards its output. |
| 605 | |
| 606 | [`Level`](/pkg/log/slog#Level) and [`LevelVar`](/pkg/log/slog#LevelVar) now implement the [`encoding.TextAppender`](/pkg/encoding#TextAppender) interface. |
| 607 | |
| 608 | #### [`math/big`](/pkg/math/big/) |
| 609 | |
| 610 | [`Float`](/pkg/math/big#Float), [`Int`](/pkg/math/big#Int) and [`Rat`](/pkg/math/big#Rat) now implement the [`encoding.TextAppender`](/pkg/encoding#TextAppender) interface. |
| 611 | |
| 612 | #### [`math/rand`](/pkg/math/rand/) |
| 613 | |
| 614 | Calls to the deprecated top-level [`Seed`](/pkg/math/rand#Seed) function no longer have any effect. To |
Filippo Valsorda | 4cfc485 | 2024-12-12 17:12:40 +0100 | [diff] [blame] | 615 | restore the old behavior use [GODEBUG setting](/doc/godebug) `randseednop=0`. For more background see |
Filippo Valsorda | 278ac22 | 2024-12-12 17:12:39 +0100 | [diff] [blame] | 616 | [proposal #67273](/issue/67273). |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 617 | |
| 618 | #### [`math/rand/v2`](/pkg/math/rand/v2/) |
| 619 | |
| 620 | [`ChaCha8`](/pkg/math/rand/v2#ChaCha8) and [`PCG`](/pkg/math/rand/v2#PCG) now implement the [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface. |
| 621 | |
| 622 | #### [`net`](/pkg/net/) |
| 623 | |
| 624 | [`ListenConfig`](/pkg/net#ListenConfig) now uses MPTCP by default on systems where it is supported |
| 625 | (currently on Linux only). |
| 626 | |
| 627 | [`IP`](/pkg/net#IP) now implements the [`encoding.TextAppender`](/pkg/encoding#TextAppender) interface. |
| 628 | |
| 629 | #### [`net/http`](/pkg/net/http/) |
| 630 | |
| 631 | [`Transport`](/pkg/net/http#Transport)'s limit on 1xx informational responses received |
| 632 | in response to a request has changed. |
| 633 | It previously aborted a request and returned an error after |
| 634 | receiving more than 5 1xx responses. |
| 635 | It now returns an error if the total size of all 1xx responses |
| 636 | exceeds the [`Transport.MaxResponseHeaderBytes`](/pkg/net/http#Transport.MaxResponseHeaderBytes) configuration setting. |
| 637 | |
| 638 | In addition, when a request has a |
| 639 | [`net/http/httptrace.ClientTrace.Got1xxResponse`](/pkg/net/http/httptrace#ClientTrace.Got1xxResponse) |
| 640 | trace hook, there is now no limit on the total number of 1xx responses. |
| 641 | The `Got1xxResponse` hook may return an error to abort a request. |
| 642 | |
| 643 | [`Transport`](/pkg/net/http#Transport) and [`Server`](/pkg/net/http#Server) now have an HTTP2 field which permits |
| 644 | configuring HTTP/2 protocol settings. |
| 645 | |
| 646 | The new [`Server.Protocols`](/pkg/net/http#Server.Protocols) and [`Transport.Protocols`](/pkg/net/http#Transport.Protocols) fields provide |
| 647 | a simple way to configure what HTTP protocols a server or client use. |
| 648 | |
| 649 | The server and client may be configured to support unencrypted HTTP/2 |
| 650 | connections. |
| 651 | |
| 652 | When [`Server.Protocols`](/pkg/net/http#Server.Protocols) contains UnencryptedHTTP2, the server will accept |
| 653 | HTTP/2 connections on unencrypted ports. The server can accept both |
| 654 | HTTP/1 and unencrypted HTTP/2 on the same port. |
| 655 | |
| 656 | When [`Transport.Protocols`](/pkg/net/http#Transport.Protocols) contains UnencryptedHTTP2 and does not contain |
| 657 | HTTP1, the transport will use unencrypted HTTP/2 for http:// URLs. |
| 658 | If the transport is configured to use both HTTP/1 and unencrypted HTTP/2, |
| 659 | it will use HTTP/1. |
| 660 | |
| 661 | Unencrypted HTTP/2 support uses "HTTP/2 with Prior Knowledge" |
| 662 | (RFC 9113, section 3.3). The deprecated "Upgrade: h2c" header |
| 663 | is not supported. |
| 664 | |
| 665 | #### [`net/netip`](/pkg/net/netip/) |
| 666 | |
| 667 | [`Addr`](/pkg/net/netip#Addr), [`AddrPort`](/pkg/net/netip#AddrPort) and [`Prefix`](/pkg/net/netip#Prefix) now implement the [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) and |
| 668 | [`encoding.TextAppender`](/pkg/encoding#TextAppender) interfaces. |
| 669 | |
| 670 | #### [`net/url`](/pkg/net/url/) |
| 671 | |
| 672 | [`URL`](/pkg/net/url#URL) now also implements the [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) interface. |
| 673 | |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 674 | #### [`os/user`](/pkg/os/user/) |
| 675 | |
| 676 | On Windows, [`Current`](/pkg/os/user#Current) can now be used in Windows Nano Server. |
| 677 | The implementation has been updated to avoid using functions |
| 678 | from the `NetApi32` library, which is not available in Nano Server. |
| 679 | |
Cherry Mui | 8e64cd8 | 2024-12-09 22:19:37 -0500 | [diff] [blame] | 680 | On Windows, [`Current`](/pkg/os/user#Current), [`Lookup`](/pkg/os/user#Lookup) and [`LookupId`](/pkg/os/user#LookupId) now support the |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 681 | following built-in service user accounts: |
| 682 | - `NT AUTHORITY\SYSTEM` |
| 683 | - `NT AUTHORITY\LOCAL SERVICE` |
| 684 | - `NT AUTHORITY\NETWORK SERVICE` |
| 685 | |
| 686 | On Windows, [`Current`](/pkg/os/user#Current) has been made considerably faster when |
| 687 | the current user is joined to a slow domain, which is the |
| 688 | usual case for many corporate users. The new implementation |
| 689 | performance is now in the order of milliseconds, compared to |
| 690 | the previous implementation which could take several seconds, |
| 691 | or even minutes, to complete. |
| 692 | |
| 693 | On Windows, [`Current`](/pkg/os/user#Current) now returns the process owner user when |
| 694 | the current thread is impersonating another user. Previously, |
| 695 | it returned an error. |
| 696 | |
| 697 | #### [`regexp`](/pkg/regexp/) |
| 698 | |
| 699 | [`Regexp`](/pkg/regexp#Regexp) now implements the [`encoding.TextAppender`](/pkg/encoding#TextAppender) interface. |
| 700 | |
| 701 | #### [`runtime`](/pkg/runtime/) |
| 702 | |
| 703 | The [`GOROOT`](/pkg/runtime#GOROOT) function is now deprecated. |
| 704 | In new code prefer to use the system path to locate the “go” binary, |
| 705 | and use `go env GOROOT` to find its GOROOT. |
| 706 | |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 707 | #### [`strings`](/pkg/strings/) |
| 708 | |
| 709 | The [`strings`](/pkg/strings) package adds several functions that work with iterators: |
| 710 | - [`Lines`](/pkg/strings#Lines) returns an iterator over |
| 711 | the newline-terminated lines in the string s. |
| 712 | - [`SplitSeq`](/pkg/strings#SplitSeq) returns an iterator over |
| 713 | all substrings of s separated by sep. |
| 714 | - [`SplitAfterSeq`](/pkg/strings#SplitAfterSeq) returns an iterator |
| 715 | over substrings of s split after each instance of sep. |
| 716 | - [`FieldsSeq`](/pkg/strings#FieldsSeq) returns an iterator over |
| 717 | substrings of s split around runs of whitespace characters, |
| 718 | as defined by unicode.IsSpace. |
| 719 | - [`FieldsFuncSeq`](/pkg/strings#FieldsFuncSeq) returns an iterator |
| 720 | over substrings of s split around runs of Unicode code points satisfying f(c). |
| 721 | |
| 722 | #### [`sync`](/pkg/sync/) |
| 723 | |
| 724 | The implementation of [`sync.Map`](/pkg/sync#Map) has been changed, improving overall performance |
| 725 | and resolving some long-standing issues. |
| 726 | If you encounter any problems, set `GOEXPERIMENT=nosynchashtriemap` at build |
| 727 | time to switch back to the old implementation and please [file an |
| 728 | issue](/issue/new). |
| 729 | |
| 730 | #### [`testing`](/pkg/testing/) |
| 731 | |
| 732 | The new [`T.Context`](/pkg/testing#T.Context) and [`B.Context`](/pkg/testing#B.Context) methods return a context that's canceled |
| 733 | after the test completes and before test cleanup functions run. |
| 734 | |
| 735 | <!-- testing.B.Loop mentioned in 6-stdlib/6-testing-bloop.md. --> |
| 736 | |
| 737 | The new [`T.Chdir`](/pkg/testing#T.Chdir) and [`B.Chdir`](/pkg/testing#B.Chdir) methods can be used to change the working |
| 738 | directory for the duration of a test or benchmark. |
| 739 | |
| 740 | #### [`text/template`](/pkg/text/template/) |
| 741 | |
| 742 | Templates now support range-over-func and range-over-int. |
| 743 | |
| 744 | #### [`time`](/pkg/time/) |
| 745 | |
| 746 | [`Time`](/pkg/time#Time) now implements the [`encoding.BinaryAppender`](/pkg/encoding#BinaryAppender) and [`encoding.TextAppender`](/pkg/encoding#TextAppender) interfaces. |
| 747 | |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 748 | ## Ports {#ports} |
| 749 | |
| 750 | ### Linux {#linux} |
| 751 | |
| 752 | <!-- go.dev/issue/67001 --> |
| 753 | As [announced](go1.23#linux) in the Go 1.23 release notes, Go 1.24 requires Linux |
| 754 | kernel version 3.2 or later. |
| 755 | |
| 756 | ### Darwin {#darwin} |
| 757 | |
| 758 | <!-- go.dev/issue/69839 --> |
| 759 | Go 1.24 is the last release that will run on macOS 11 Big Sur. |
| 760 | Go 1.25 will require macOS 12 Monterey or later. |
| 761 | |
| 762 | ### WebAssembly {#wasm} |
| 763 | |
| 764 | <!-- go.dev/issue/65199, CL 603055 --> |
| 765 | The `go:wasmexport` directive is added for Go programs to export functions to the WebAssembly host. |
| 766 | |
Cherry Mui | 8e64cd8 | 2024-12-09 22:19:37 -0500 | [diff] [blame] | 767 | On WebAssembly System Interface Preview 1 (`GOOS=wasip1`, `GOARCH=wasm`), Go 1.24 supports |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 768 | building a Go program as a |
| 769 | [reactor/library](https://github.com/WebAssembly/WASI/blob/63a46f61052a21bfab75a76558485cf097c0dbba/legacy/application-abi.md#current-unstable-abi), |
| 770 | by specifying the `-buildmode=c-shared` build flag. |
| 771 | |
| 772 | <!-- go.dev/issue/66984, CL 626615 --> |
| 773 | More types are now permitted as argument or result types for `go:wasmimport` functions. |
| 774 | Specifically, `bool`, `string`, `uintptr`, and pointers to certain types are allowed |
| 775 | (see the [proposal](/issue/66984) for detail), |
| 776 | along with 32-bit and 64-bit integer and float types, and `unsafe.Pointer`, which |
| 777 | are already allowed. |
| 778 | These types are also permitted as argument or result types for `go:wasmexport` functions. |
| 779 | |
| 780 | <!-- go.dev/issue/68024 --> |
| 781 | The support files for WebAssembly have been moved to `lib/wasm` from `misc/wasm`. |
| 782 | |
Dmitri Shuralyov | 1f1be51 | 2024-12-05 18:20:57 -0500 | [diff] [blame] | 783 | ### Windows {#windows} |
| 784 | |
| 785 | <!-- go.dev/issue/70705 --> |
| 786 | The windows/arm port (`GOOS=windows` `GOARCH=arm`) has been marked broken. |
Dmitri Shuralyov | 193b880 | 2024-12-11 13:46:39 -0500 | [diff] [blame] | 787 | See [issue #70705](/issue/70705) for details. |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 788 | |
| 789 | <!-- Maybe worth including or maybe fine not to include in Go 1.24 release notes. Someone more familiar with the change makes the call. |
| 790 | |
| 791 | accepted proposal https://go.dev/issue/64802 (from https://go.dev/cl/628681) - a crypto/ecdsa change when rand is nil; commented at https://go.dev/issue/64802#issuecomment-2502019212 for next steps |
| 792 | accepted proposal https://go.dev/issue/25309 (from https://go.dev/cl/594018, https://go.dev/cl/595120, https://go.dev/cl/595564, https://go.dev/cl/601778) - new x/crypto package; doesn't seem to need to be mentioned but asked anyway in https://go.dev/issue/25309#issuecomment-2498747653 |
| 793 | accepted proposal https://go.dev/issue/43744 (from https://go.dev/cl/357530) - unclear if Go 1.24 release notes need anything; pinged it in https://go.dev/issue/43744#issuecomment-2498773718 |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 794 | accepted proposal https://go.dev/issue/60905 (from https://go.dev/cl/610195) - CL 610195 seems like a small performance enhancement that builds on the Go 1.23 proposal to add GOARM64; probably okay without being mentioned in Go 1.24 release notes (also probably okay to mention) |
| 795 | accepted proposal https://go.dev/issue/61395 (from https://go.dev/cl/594738, https://go.dev/cl/594976) - CL 594738 made sync/atomic AND/OR operations intrinsic on amd64, but the API was already added in Go 1.23; CL 594976 is a fix; probably doesn't require a Go 1.24 release note |
| 796 | --> |
| 797 | |
| 798 | <!-- Items that don't need to be mentioned in Go 1.24 release notes but are picked up by relnote todo. |
| 799 | |
Dmitri Shuralyov | 193b880 | 2024-12-11 13:46:39 -0500 | [diff] [blame] | 800 | accepted proposal https://go.dev/issue/51269 (from https://go.dev/cl/627035) - may be worth mentioning in Go 1.24 release notes, or may be fine to leave out; commented at https://go.dev/issue/51269#issuecomment-2501802763; Ian confirmed it's fine to leave out |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 801 | accepted proposal https://go.dev/issue/66540 (from https://go.dev/cl/603958) - a Go language spec clarification; might not need to be mentioned in Go 1.24 release notes; left a comment at https://go.dev/issue/66540#issuecomment-2502051684; Robert confirmed it indeed doesn't |
| 802 | accepted proposal https://go.dev/issue/34208 (from https://go.dev/cl/586241) - CL 586241 implements a fix for a Go 1.23 feature, doesn't seem to be need anything in Go 1.24 release notes |
| 803 | accepted proposal https://go.dev/issue/43993 (from https://go.dev/cl/626116) - CL 626116 prepares the tree towards the vet change but the vet change itself isn't implemented in Go 1.24, so nothing to say in Go 1.24 release notes |
| 804 | accepted proposal https://go.dev/issue/44505 (from https://go.dev/cl/609955) - CL 609955 is an internal cleanup in x/tools, no need for Go 1.24 release note |
| 805 | accepted proposal https://go.dev/issue/61476 (from https://go.dev/cl/608255) - CL 608255 builds on GORISCV64 added in Go 1.23; nothing to mention in Go 1.24 release notes |
| 806 | accepted proposal https://go.dev/issue/66315 (from https://go.dev/cl/577996) - adding Pass.Module field to x/tools/go/analysis doesn't seem like something that needs to be mentioned in Go 1.24 release notes |
| 807 | accepted proposal https://go.dev/issue/57786 (from https://go.dev/cl/472717) - CL 472717 is in x/net/http2 and mentions a Go 1.21 proposal; it doesn't seem to need anything in Go 1.24 release notes |
| 808 | accepted proposal https://go.dev/issue/54265 (from https://go.dev/cl/609915, https://go.dev/cl/610675) - CLs that refer to a Go 1.22 proposal, nothing more is needed in Go 1.24 release notes |
| 809 | accepted proposal https://go.dev/issue/53021 (from https://go.dev/cl/622276) - CL 622276 improves docs; proposal 53021 was in Go 1.20 so nothing more is needed in Go 1.24 release notes |
| 810 | accepted proposal https://go.dev/issue/51430 (from https://go.dev/cl/613375) - CL 613375 is an internal documentation comment; proposal 51430 happened in Go 1.20/1.21 so nothing more is needed in Go 1.24 release notes |
| 811 | accepted proposal https://go.dev/issue/38445 (from https://go.dev/cl/626495) - CL 626495 works on proposal 38445, which is about x/tools/go/package, doesn't need anything in Go 1.24 release notes |
| 812 | accepted proposal https://go.dev/issue/56986 (from https://go.dev/cl/618115) - CL 618115 adds documentation; it doesn't need to be mentioned in Go 1.24 release notes |
| 813 | accepted proposal https://go.dev/issue/60061 (from https://go.dev/cl/612038) - CL 612038 is a CL that deprecates something in x/tools/go/ast and mentions a Go 1.22 proposal; doesn't need anything in Go 1.24 release notes |
| 814 | accepted proposal https://go.dev/issue/61324 (from https://go.dev/cl/411907) - CL 411907 is an x/tools CL that implements a proposal for a new package there; doesn't need anything in Go 1.24 release notes |
| 815 | accepted proposal https://go.dev/issue/61777 (from https://go.dev/cl/601496) - CL 601496 added a WriteByteTimeout field to x/net/http2.Server; doesn't need a Go 1.24 release note |
| 816 | accepted proposal https://go.dev/issue/61940 (from https://go.dev/cl/600997) - CL 600997 deleted obsolete code in x/build and mentioned an accepted proposal; doesn't need a Go 1.24 release note |
| 817 | accepted proposal https://go.dev/issue/62113 (from https://go.dev/cl/594195) - CL 594195 made iterator-related additions in x/net/html; doesn't need a Go 1.24 release note |
| 818 | accepted proposal https://go.dev/issue/62484 (from https://go.dev/cl/600775) - CL 600775 documents CopyFS symlink behavior and mentions the Go 1.23 proposal; doesn't need a Go 1.24 release note |
| 819 | accepted proposal https://go.dev/issue/64207 (from https://go.dev/cl/605875) - an x/website CL that follows up on a Go 1.23 proposal; doesn't need a Go 1.24 release note |
| 820 | accepted proposal https://go.dev/issue/65236 (from https://go.dev/cl/596135) - CL 596135 adds tests for the Go 1.23 proposal 65236; doesn't need a Go 1.24 release note |
| 821 | accepted proposal https://go.dev/issue/67795 (from https://go.dev/cl/616218) - iteratior support for x/tools/go/ast/inspector; doesn't need a Go 1.24 release note |
| 822 | accepted proposal https://go.dev/issue/67812 (from https://go.dev/cl/601497) - configurable server pings for x/net/http2.Server; doesn't need a Go 1.24 release note |
| 823 | accepted proposal https://go.dev/issue/68232 (from https://go.dev/cl/595676) - x/sys/unix additions; doesn't need a Go 1.24 release note |
| 824 | accepted proposal https://go.dev/issue/68898 (from https://go.dev/cl/607495, https://go.dev/cl/620036, https://go.dev/cl/620135, https://go.dev/cl/623638) - a proposal for x/tools/go/gcexportdata to document 2 releases + tip support policy; since the change is in x/tools it doesn't need a Go 1.24 release note |
| 825 | accepted proposal https://go.dev/issue/69095 (from https://go.dev/cl/593683, https://go.dev/cl/608955, https://go.dev/cl/610716) - a proposal that affects maintenance and support of golang.org/x repositories; doesn't need to be mentioned in Go 1.24 release notes |
| 826 | accepted proposal https://go.dev/issue/68384 (from https://go.dev/cl/611875) - expanding the scope of Go Telemetry to include Delve isn't directly tied to Go 1.24 and doesn't seem to need to be mentioned in Go 1.24 release notes |
| 827 | accepted proposal https://go.dev/issue/69291 (from https://go.dev/cl/610939) - CL 610939 refactors code in x/tools and mentions the still-open proposal #69291 to add Reachable to x/tools/go/ssa/ssautil; doesn't need a Go 1.24 release note |
| 828 | accepted proposal https://go.dev/issue/69360 (from https://go.dev/cl/614158, https://go.dev/cl/614159, https://go.dev/cl/614635, https://go.dev/cl/614675) - proposal 69360 is to tag and delete gorename from x/tools; doesn't need a Go 1.24 release note |
| 829 | accepted proposal https://go.dev/issue/61417 (from https://go.dev/cl/605955) - a new field in x/oauth2; nothing to mention in Go 1.24 release notes |
Dmitri Shuralyov | 193b880 | 2024-12-11 13:46:39 -0500 | [diff] [blame] | 830 | accepted proposal https://go.dev/issue/29266 (from https://go.dev/cl/632897) - a documentation-only proposal for go.dev/doc/contribute; doesn't need a Go 1.24 release note |
Gopher Robot | 4ccfb99 | 2024-12-05 21:15:57 +0000 | [diff] [blame] | 831 | --> |