mirror of
https://github.com/golang/go
synced 2024-11-24 17:20:12 -07:00
9894ded194
CL 444277 fixed Time.UnmarshalText and Time.UnmarshalJSON to properly unmarshal timestamps according to RFC 3339 instead of according to Go's bespoke time syntax that is a superset of RFC 3339. However, this change seems to have broken an AWS S3 unit test that relies on parsing timestamps with single digit hours. It is unclear whether S3 emits these timestamps in production or whether this is simply a testing artifact that has been cargo culted across many code bases. Either way, disable strict parsing for now and re-enable later with better GODEBUG support. Updates #54580 Change-Id: Icced2c7f9a6b2fc06bbd9c7e90f90edce24c2306 Reviewed-on: https://go-review.googlesource.com/c/go/+/462286 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Joseph Tsai <joetsai@digital-static.net> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
1247 lines
55 KiB
HTML
1247 lines
55 KiB
HTML
<!--{
|
||
"Title": "Go 1.20 Release Notes",
|
||
"Path": "/doc/go1.20"
|
||
}-->
|
||
|
||
<!--
|
||
NOTE: In this document and others in this directory, the convention is to
|
||
set fixed-width phrases with non-fixed-width spaces, as in
|
||
<code>hello</code> <code>world</code>.
|
||
Do not send CLs removing the interior tags from such phrases.
|
||
-->
|
||
|
||
<style>
|
||
main ul li { margin: 0.5em 0; }
|
||
</style>
|
||
|
||
<h2 id="introduction">DRAFT RELEASE NOTES — Introduction to Go 1.20</h2>
|
||
|
||
<p>
|
||
<strong>
|
||
Go 1.20 is not yet released. These are work-in-progress
|
||
release notes. Go 1.20 is expected to be released in February 2023.
|
||
</strong>
|
||
</p>
|
||
|
||
<h2 id="language">Changes to the language</h2>
|
||
|
||
<p>
|
||
Go 1.20 includes four changes to the language.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/46505 -->
|
||
Go 1.17 added <a href="/ref/spec#Conversions_from_slice_to_array_or_array_pointer">conversions from slice to an array pointer</a>.
|
||
Go 1.20 extends this to allow conversions from a slice to an array:
|
||
given a slice <code>x</code>, <code>[4]byte(x)</code> can now be written
|
||
instead of <code>*(*[4]byte)(x)</code>.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/53003 -->
|
||
The <a href="/ref/spec/#Package_unsafe"><code>unsafe</code> package</a> defines
|
||
three new functions <code>SliceData</code>, <code>String</code>, and <code>StringData</code>.
|
||
Along with Go 1.17's <code>Slice</code>, these functions now provide the complete ability to
|
||
construct and deconstruct slice and string values, without depending on their exact representation.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/8606 -->
|
||
The specification now defines that struct values are compared one field at a time,
|
||
considering fields in the order they appear in the struct type definition,
|
||
and stopping at the first mismatch.
|
||
The specification could previously have been read as if
|
||
all fields needed to be compared beyond the first mismatch.
|
||
Similarly, the specification now defines that array values are compared
|
||
one element at a time, in increasing index order.
|
||
In both cases, the difference affects whether certain comparisons must panic.
|
||
Existing programs are unchanged: the new spec wording describes
|
||
what the implementations have always done.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/56548 -->
|
||
<a href="/ref/spec#Comparison_operators">Comparable types</a> (such as ordinary interfaces)
|
||
may now satisfy <code>comparable</code> constraints, even if the type arguments
|
||
are not strictly comparable (comparison may panic at runtime).
|
||
This makes it possible to instantiate a type parameter constrained by <code>comparable</code>
|
||
(e.g., a type parameter for a user-defined generic map key) with a non-strictly comparable type argument
|
||
such as an interface type, or a composite type containing an interface type.
|
||
</p>
|
||
|
||
<h2 id="ports">Ports</h2>
|
||
|
||
<h3 id="windows">Windows</h3>
|
||
|
||
<p><!-- https://go.dev/issue/57003, https://go.dev/issue/57004 -->
|
||
Go 1.20 is the last release that will run on any release of Windows 7, 8, Server 2008 and Server 2012.
|
||
Go 1.21 will require at least Windows 10 or Server 2016.
|
||
</p>
|
||
|
||
<h3 id="darwin">Darwin and iOS</h3>
|
||
|
||
<p><!-- https://go.dev/issue/23011 -->
|
||
Go 1.20 is the last release that will run on macOS 10.13 High Sierra or 10.14 Mojave.
|
||
Go 1.21 will require macOS 10.15 Catalina or later.
|
||
</p>
|
||
|
||
<h3 id="freebsd-riscv">FreeBSD/RISC-V</h3>
|
||
|
||
<p><!-- https://go.dev/issue/53466 -->
|
||
Go 1.20 adds experimental support for FreeBSD on RISC-V (<code>GOOS=freebsd</code>, <code>GOARCH=riscv64</code>).
|
||
</p>
|
||
|
||
<h2 id="tools">Tools</h2>
|
||
|
||
<h3 id="go-command">Go command</h3>
|
||
|
||
<p><!-- CL 432535, https://go.dev/issue/47257 -->
|
||
The directory <code>$GOROOT/pkg</code> no longer stores
|
||
pre-compiled package archives for the standard library:
|
||
<code>go</code> <code>install</code> no longer writes them,
|
||
the <code>go</code> build no longer checks for them,
|
||
and the Go distribution no longer ships them.
|
||
Instead, packages in the standard library are built as needed
|
||
and cached in the build cache, just like packages outside <code>GOROOT</code>.
|
||
This change reduces the size of the Go distribution and also
|
||
avoids C toolchain skew for packages that use cgo.
|
||
</p>
|
||
|
||
<p><!-- CL 448357: cmd/go: print test2json start events -->
|
||
The implementation of <code>go</code> <code>test</code> <code>-json</code>
|
||
has been improved to make it more robust.
|
||
Programs that run <code>go</code> <code>test</code> <code>-json</code>
|
||
do not need any updates.
|
||
Programs that invoke <code>go</code> <code>tool</code> <code>test2json</code>
|
||
directly should now run the test binary with <code>-v=test2json</code>
|
||
(for example, <code>go</code> <code>test</code> <code>-v=test2json</code>
|
||
or <code>./pkg.test</code> <code>-test.v=test2json</code>)
|
||
instead of plain <code>-v</code>.
|
||
</p>
|
||
|
||
<p><!-- CL 448357: cmd/go: print test2json start events -->
|
||
A related change to <code>go</code> <code>test</code> <code>-json</code>
|
||
is the addition of an event with <code>Action</code> set to <code>start</code>
|
||
at the beginning of each test program's execution.
|
||
When running multiple tests using the <code>go</code> command,
|
||
these start events are guaranteed to be emitted in the same order as
|
||
the packages named on the command line.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/45454, CL 421434 -->
|
||
The <code>go</code> command now defines
|
||
architecture feature build tags, such as <code>amd64.v2</code>,
|
||
to allow selecting a package implementation file based on the presence
|
||
or absence of a particular architecture feature.
|
||
See <a href="/cmd/go#hdr-Build_constraints"><code>go</code> <code>help</code> <code>buildconstraint</code></a> for details.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/50332 -->
|
||
The <code>go</code> subcommands now accept
|
||
<code>-C</code> <code><dir></code> to change directory to <dir>
|
||
before performing the command, which may be useful for scripts that need to
|
||
execute commands in multiple different modules.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/41696, CL 416094 -->
|
||
The <code>go</code> <code>build</code> and <code>go</code> <code>test</code>
|
||
commands no longer accept the <code>-i</code> flag,
|
||
which has been <a href="https://go.dev/issue/41696">deprecated since Go 1.16</a>.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/38687, CL 421440 -->
|
||
The <code>go</code> <code>generate</code> command now accepts
|
||
<code>-skip</code> <code><pattern></code> to skip <code>//go:generate</code> directives
|
||
matching <code><pattern></code>.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/41583 -->
|
||
The <code>go</code> <code>test</code> command now accepts
|
||
<code>-skip</code> <code><pattern></code> to skip tests, subtests, or examples
|
||
matching <code><pattern></code>.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/37015 -->
|
||
When the main module is located within <code>GOPATH/src</code>,
|
||
<code>go</code> <code>install</code> no longer installs libraries for
|
||
non-<code>main</code> packages to <code>GOPATH/pkg</code>,
|
||
and <code>go</code> <code>list</code> no longer reports a <code>Target</code>
|
||
field for such packages. (In module mode, compiled packages are stored in the
|
||
<a href="https://pkg.go.dev/cmd/go#hdr-Build_and_test_caching">build cache</a>
|
||
only, but <a href="https://go.dev/issue/37015">a bug</a> had caused
|
||
the <code>GOPATH</code> install targets to unexpectedly remain in effect.)
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/55022 -->
|
||
The <code>go</code> <code>build</code>, <code>go</code> <code>install</code>,
|
||
and other build-related commands now support a <code>-pgo</code> flag that enables
|
||
profile-guided optimization, which is described in more detail in the
|
||
<a href="#compiler">Compiler</a> section below.
|
||
The <code>-pgo</code> flag specifies the file path of the profile.
|
||
Specifying <code>-pgo=auto</code> causes the <code>go</code> command to search
|
||
for a file named <code>default.pgo</code> in the main package's directory and
|
||
use it if present.
|
||
This mode currently requires a single main package to be specified on the
|
||
command line, but we plan to lift this restriction in a future release.
|
||
Specifying <code>-pgo=off</code> turns off profile-guided optimization.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/51430 -->
|
||
The <code>go</code> <code>build</code>, <code>go</code> <code>install</code>,
|
||
and other build-related commands now support a <code>-cover</code>
|
||
flag that builds the specified target with code coverage instrumentation.
|
||
This is described in more detail in the
|
||
<a href="#cover">Cover</a> section below.
|
||
</p>
|
||
|
||
<h4 id="go-version"><code>go</code> <code>version</code></h4>
|
||
|
||
<p><!-- https://go.dev/issue/48187 -->
|
||
The <code>go</code> <code>version</code> <code>-m</code> command
|
||
now supports reading more types of Go binaries, most notably, Windows DLLs
|
||
built with <code>go</code> <code>build</code> <code>-buildmode=c-shared</code>
|
||
and Linux binaries without execute permission.
|
||
</p>
|
||
|
||
<h3 id="cgo">Cgo</h3>
|
||
|
||
<p><!-- CL 450739 -->
|
||
The <code>go</code> command now disables <code>cgo</code> by default
|
||
on systems without a C toolchain.
|
||
More specifically, when the <code>CGO_ENABLED</code> environment variable is unset,
|
||
the <code>CC</code> environment variable is unset,
|
||
and the default C compiler (typically <code>clang</code> or <code>gcc</code>)
|
||
is not found in the path,
|
||
<code>CGO_ENABLED</code> defaults to <code>0</code>.
|
||
As always, you can override the default by setting <code>CGO_ENABLED</code> explicitly.
|
||
</p>
|
||
|
||
<p>
|
||
The most important effect of the default change is that when Go is installed
|
||
on a system without a C compiler, it will now use pure Go builds for packages
|
||
in the standard library that use cgo, instead of using pre-distributed package archives
|
||
(which have been removed, as <a href="#go-command">noted above</a>)
|
||
or attempting to use cgo and failing.
|
||
This makes Go work better in some minimal container environments
|
||
as well as on macOS, where pre-distributed package archives have
|
||
not been used for cgo-based packages since Go 1.16.
|
||
</p>
|
||
|
||
<p>
|
||
The packages in the standard library that use cgo are <a href="/pkg/net/"><code>net</code></a>,
|
||
<a href="/pkg/os/user/"><code>os/user</code></a>, and
|
||
<a href="/pkg/plugin/"><code>plugin</code></a>.
|
||
On macOS, the <code>net</code> and <code>os/user</code> packages have been rewritten not to use cgo:
|
||
the same code is now used for cgo and non-cgo builds as well as cross-compiled builds.
|
||
On Windows, the <code>net</code> and <code>os/user</code> packages have never used cgo.
|
||
On other systems, builds with cgo disabled will use a pure Go version of these packages.
|
||
</p>
|
||
|
||
<p>
|
||
On macOS, the race detector has been rewritten not to use cgo:
|
||
race-detector-enabled programs can be built and run without Xcode.
|
||
On Linux and other Unix systems, and on Windows, a host C toolchain
|
||
is required to use the race detector.
|
||
</p>
|
||
|
||
<h3 id="cover">Cover</h3>
|
||
|
||
<p><!-- CL 436236, CL 401236, CL 438503 -->
|
||
Go 1.20 supports collecting code coverage profiles for programs
|
||
(applications and integration tests), as opposed to just unit tests.
|
||
</p>
|
||
|
||
<p>
|
||
To collect coverage data for a program, build it with <code>go</code>
|
||
<code>build</code>'s <code>-cover</code> flag, then run the resulting
|
||
binary with the environment variable <code>GOCOVERDIR</code> set
|
||
to an output directory for coverage profiles.
|
||
See the
|
||
<a href="https://go.dev/testing/coverage">'coverage for integration tests' landing page</a> for more on how to get started.
|
||
For details on the design and implementation, see the
|
||
<a href="https://golang.org/issue/51430">proposal</a>.
|
||
</p>
|
||
|
||
<h3 id="vet">Vet</h3>
|
||
|
||
<h4 id="vet-loopclosure">Improved detection of loop variable capture by nested functions</h4>
|
||
|
||
<p><!-- CL 447256, https://go.dev/issue/55972: extend the loopclosure analysis to parallel subtests -->
|
||
The <code>vet</code> tool now reports references to loop variables following
|
||
a call to <a href="/pkg/testing/#T.Parallel"><code>T.Parallel()</code></a>
|
||
within subtest function bodies. Such references may observe the value of the
|
||
variable from a different iteration (typically causing test cases to be
|
||
skipped) or an invalid state due to unsynchronized concurrent access.
|
||
</p>
|
||
|
||
<p><!-- CL 452615 -->
|
||
The tool also detects reference mistakes in more places. Previously it would
|
||
only consider the last statement of the loop body, but now it recursively
|
||
inspects the last statements within if, switch, and select statements.
|
||
</p>
|
||
|
||
<h4 id="vet-timeformat">New diagnostic for incorrect time formats</h4>
|
||
|
||
<p><!-- CL 354010, https://go.dev/issue/48801: check for time formats with 2006-02-01 -->
|
||
The vet tool now reports use of the time format 2006-02-01 (yyyy-dd-mm)
|
||
with <a href="/pkg/time/#Time.Format"><code>Time.Format</code></a> and
|
||
<a href="/pkg/time/#Parse"><code>time.Parse</code></a>.
|
||
This format does not appear in common date standards, but is frequently
|
||
used by mistake when attempting to use the ISO 8601 date format
|
||
(yyyy-mm-dd).
|
||
</p>
|
||
|
||
<h2 id="runtime">Runtime</h2>
|
||
|
||
<p><!-- CL 422634 -->
|
||
Some of the garbage collector's internal data structures were reorganized to
|
||
be both more space and CPU efficient.
|
||
This change reduces memory overheads and improves overall CPU performance by
|
||
up to 2%.
|
||
</p>
|
||
|
||
<p><!-- CL 417558, https://go.dev/issue/53892 -->
|
||
The garbage collector behaves less erratically with respect to goroutine
|
||
assists in some circumstances.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/51430 -->
|
||
Go 1.20 adds a new <code>runtime/coverage</code> package
|
||
containing APIs for writing coverage profile data at
|
||
runtime from long-running and/or server programs that
|
||
do not terminate via <code>os.Exit()</code>.
|
||
</p>
|
||
|
||
<h2 id="compiler">Compiler</h2>
|
||
|
||
<p><!-- https://go.dev/issue/55022 -->
|
||
Go 1.20 adds preview support for profile-guided optimization (PGO).
|
||
PGO enables the toolchain to perform application- and workload-specific
|
||
optimizations based on run-time profile information.
|
||
Currently, the compiler supports pprof CPU profiles, which can be collected
|
||
through usual means, such as the <code>runtime/pprof</code> or
|
||
<code>net/http/pprof</code> packages.
|
||
To enable PGO, pass the path of a pprof profile file via the
|
||
<code>-pgo</code> flag to <code>go</code> <code>build</code>,
|
||
as mentioned <a href="#go-command">above</a>.
|
||
Go 1.20 uses PGO to more aggressively inline functions at hot call sites.
|
||
Benchmarks for a representative set of Go programs show enabling
|
||
profile-guided inlining optimization improves performance about 3–4%.
|
||
We plan to add more profile-guided optimizations in future releases.
|
||
Note that profile-guided optimization is a preview, so please use it
|
||
with appropriate caution.
|
||
</p>
|
||
|
||
<p>
|
||
The Go 1.20 compiler upgraded its front-end to use a new way of handling the
|
||
compiler's internal data, which fixes several generic-types bugs and enables
|
||
local types in generic functions and methods.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/56103, CL 445598 -->
|
||
The compiler now <a href="https://go.dev/issue/56103">disallows anonymous interface cycles</a>.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/49569 -->
|
||
Go 1.18 and 1.19 saw regressions in build speed, largely due to the addition
|
||
of support for generics and follow-on work. Go 1.20 improves build speeds by
|
||
up to 10%, bringing it back in line with Go 1.17.
|
||
Relative to Go 1.19, generated code performance is also generally slightly improved.
|
||
</p>
|
||
|
||
<h2 id="linker">Linker</h2>
|
||
|
||
<p><!-- https://go.dev/issue/54197, CL 420774 -->
|
||
On Linux, the linker now selects the dynamic interpreter for <code>glibc</code>
|
||
or <code>musl</code> at link time.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/35006 -->
|
||
On Windows, the Go linker now supports modern LLVM-based C toolchains.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/37762, CL 317917 -->
|
||
Go 1.20 uses <code>go:</code> and <code>type:</code> prefixes for compiler-generated
|
||
symbols rather than <code>go.</code> and <code>type.</code>.
|
||
This avoids confusion for user packages whose name starts with <code>go.</code>.
|
||
The <a href="/pkg/debug/gosym"><code>debug/gosym</code></a> package understands
|
||
this new naming convention for binaries built with Go 1.20 and newer.
|
||
</p>
|
||
|
||
<h2 id="bootstrap">Bootstrap</h2>
|
||
|
||
<p><!-- https://go.dev/issue/44505 -->
|
||
When building a Go release from source and <code>GOROOT_BOOTSTRAP</code> is not set,
|
||
previous versions of Go looked for a Go 1.4 or later bootstrap toolchain in the directory
|
||
<code>$HOME/go1.4</code> (<code>%HOMEDRIVE%%HOMEPATH%\go1.4</code> on Windows).
|
||
Go 1.18 and Go 1.19 looked first for <code>$HOME/go1.17</code> or <code>$HOME/sdk/go1.17</code>
|
||
before falling back to <code>$HOME/go1.4</code>,
|
||
in anticipation of requiring Go 1.17 for use when bootstrapping Go 1.20.
|
||
Go 1.20 does require a Go 1.17 release for bootstrapping, but we realized that we should
|
||
adopt the latest point release of the bootstrap toolchain, so it requires Go 1.17.13.
|
||
Go 1.20 looks for <code>$HOME/go1.17.13</code> or <code>$HOME/sdk/go1.17.13</code>
|
||
before falling back to <code>$HOME/go1.4</code>
|
||
(to support systems that hard-coded the path $HOME/go1.4 but have installed
|
||
a newer Go toolchain there).
|
||
In the future, we plan to move the bootstrap toolchain forward approximately once a year,
|
||
and in particular we expect that Go 1.22 will require the final point release of Go 1.20 for bootstrap.
|
||
</p>
|
||
|
||
<h2 id="library">Core library</h2>
|
||
|
||
<h3 id="crypto/ecdh">New crypto/ecdh package</h3>
|
||
|
||
<p><!-- https://go.dev/issue/52221, CL 398914, CL 450335, https://go.dev/issue/56052 -->
|
||
Go 1.20 adds a new <a href="/pkg/crypto/ecdh/"><code>crypto/ecdh</code></a> package
|
||
to provide explicit support for Elliptic Curve Diffie-Hellman key exchanges
|
||
over NIST curves and Curve25519.
|
||
</p>
|
||
<p>
|
||
Programs should use <code>crypto/ecdh</code> instead of the lower-level functionality in
|
||
<a href="/pkg/crypto/elliptic/"><code>crypto/elliptic</code></a> for ECDH, and
|
||
third-party modules for more advanced use cases.
|
||
</p>
|
||
|
||
<h3 id="errors">Wrapping multiple errors</h3>
|
||
|
||
<p><!-- CL 432898 -->
|
||
Go 1.20 expands support for error wrapping to permit an error to
|
||
wrap multiple other errors.
|
||
</p>
|
||
<p>
|
||
An error <code>e</code> can wrap more than one error by providing
|
||
an <code>Unwrap</code> method that returns a <code>[]error</code>.
|
||
</p>
|
||
<p>
|
||
The <a href="/pkg/errors/#Is"><code>errors.Is</code></a> and
|
||
<a href="/pkg/errors/#As"><code>errors.As</code></a> functions
|
||
have been updated to inspect multiply wrapped errors.
|
||
</p>
|
||
<p>
|
||
The <a href="/pkg/fmt/#Errorf"><code>fmt.Errorf</code></a> function
|
||
now supports multiple occurrences of the <code>%w</code> format verb,
|
||
which will cause it to return an error that wraps all of those error operands.
|
||
</p>
|
||
<p>
|
||
The new function <a href="/pkg/errors/#Join"><code>errors.Join</code></a>
|
||
returns an error wrapping a list of errors.
|
||
</p>
|
||
|
||
<h3 id="http_responsecontroller">HTTP ResponseController</h3>
|
||
|
||
<p><!-- CL 436890, https://go.dev/issue/54136 -->
|
||
The new
|
||
<a href="/pkg/net/http/#ResponseController"><code>"net/http".ResponseController</code></a>
|
||
type provides access to extended per-request functionality not handled by the
|
||
<a href="/pkg/net/http/#ResponseWriter"><code>"net/http".ResponseWriter</code></a> interface.
|
||
</p>
|
||
|
||
<p>
|
||
Previously, we have added new per-request functionality by defining optional
|
||
interfaces which a <code>ResponseWriter</code> can implement, such as
|
||
<a href="/pkg/net/http/#Flusher"><code>Flusher</code></a>. These interfaces
|
||
are not discoverable and clumsy to use.
|
||
</p>
|
||
|
||
<p>
|
||
The <code>ResponseController</code> type provides a clearer, more discoverable way
|
||
to add per-handler controls. Two such controls also added in Go 1.20 are
|
||
<code>SetReadDeadline</code> and <code>SetWriteDeadline</code>, which allow setting
|
||
per-request read and write deadlines. For example:
|
||
</p>
|
||
|
||
<pre>
|
||
func RequestHandler(w ResponseWriter, r *Request) {
|
||
rc := http.NewResponseController(w)
|
||
rc.SetWriteDeadline(time.Time{}) // disable Server.WriteTimeout when sending a large response
|
||
io.Copy(w, bigData)
|
||
}
|
||
</pre>
|
||
|
||
<h3 id="reverseproxy_rewrite">New ReverseProxy Rewrite hook</h3>
|
||
|
||
<p><!-- https://go.dev/issue/53002, CL 407214 -->
|
||
The <a href="/pkg/net/http/httputil/#ReverseProxy"><code>httputil.ReverseProxy</code></a>
|
||
forwarding proxy includes a new
|
||
<a href="/pkg/net/http/httputil/#ReverseProxy.Rewrite"><code>Rewrite</code></a>
|
||
hook function, superseding the
|
||
previous <code>Director</code> hook.
|
||
</p>
|
||
|
||
<p>
|
||
The <code>Rewrite</code> hook accepts a
|
||
<a href="/pkg/net/http/httputil/#ProxyRequest"><code>ProxyRequest</code></a> parameter,
|
||
which includes both the inbound request received by the proxy and the outbound
|
||
request that it will send.
|
||
Unlike <code>Director</code> hooks, which only operate on the outbound request,
|
||
this permits <code>Rewrite</code> hooks to avoid certain scenarios where
|
||
a malicious inbound request may cause headers added by the hook
|
||
to be removed before forwarding.
|
||
See <a href="https://go.dev/issue/50580">issue #50580</a>.
|
||
</p>
|
||
|
||
<p>
|
||
The <a href="/pkg/net/http/httputil/#ProxyRequest.SetURL"><code>ProxyRequest.SetURL</code></a>
|
||
method routes the outbound request to a provided destination
|
||
and supersedes the <code>NewSingleHostReverseProxy</code> function.
|
||
Unlike <code>NewSingleHostReverseProxy</code>, <code>SetURL</code>
|
||
also sets the <code>Host</code> header of the outbound request.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/50465, CL 407414 -->
|
||
The
|
||
<a href="/pkg/net/http/httputil/#ProxyRequest.SetXForwarded"><code>ProxyRequest.SetXForwarded</code></a>
|
||
method sets the <code>X-Forwarded-For</code>, <code>X-Forwarded-Host</code>,
|
||
and <code>X-Forwarded-Proto</code> headers of the outbound request.
|
||
When using a <code>Rewrite</code>, these headers are not added by default.
|
||
</p>
|
||
|
||
<p>
|
||
An example of a <code>Rewrite</code> hook using these features is:
|
||
</p>
|
||
|
||
<pre>
|
||
proxyHandler := &httputil.ReverseProxy{
|
||
Rewrite: func(r *httputil.ProxyRequest) {
|
||
r.SetURL(outboundURL) // Forward request to outboundURL.
|
||
r.SetXForwarded() // Set X-Forwarded-* headers.
|
||
r.Out.Header.Set("X-Additional-Header", "header set by the proxy")
|
||
},
|
||
}
|
||
</pre>
|
||
|
||
<p><!-- CL 407375 -->
|
||
<a href="/pkg/net/http/httputil/#ReverseProxy"><code>ReverseProxy</code></a> no longer adds a <code>User-Agent</code> header
|
||
to forwarded requests when the incoming request does not have one.
|
||
</p>
|
||
|
||
<h3 id="minor_library_changes">Minor changes to the library</h3>
|
||
|
||
<p>
|
||
As always, there are various minor changes and updates to the library,
|
||
made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a>
|
||
in mind.
|
||
There are also various performance improvements, not enumerated here.
|
||
</p>
|
||
|
||
<dl id="archive/tar"><dt><a href="/pkg/archive/tar/">archive/tar</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/55356, CL 449937 -->
|
||
When the <code>GODEBUG=tarinsecurepath=0</code> environment variable is set,
|
||
<a href="/pkg/archive/tar/#Reader.Next"><code>Reader.Next</code></a> method
|
||
will now return the error <a href="/pkg/archive/tar/#ErrInsecurePath"><code>ErrInsecurePath</code></a>
|
||
for an entry with a file name that is an absolute path,
|
||
refers to a location outside the current directory, contains invalid
|
||
characters, or (on Windows) is a reserved name such as <code>NUL</code>.
|
||
A future version of Go may disable insecure paths by default.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- archive/tar -->
|
||
|
||
<dl id="archive/zip"><dt><a href="/pkg/archive/zip/">archive/zip</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/55356 -->
|
||
When the <code>GODEBUG=zipinsecurepath=0</code> environment variable is set,
|
||
<a href="/pkg/archive/zip/#NewReader"><code>NewReader</code></a> will now return the error
|
||
<a href="/pkg/archive/zip/#ErrInsecurePath"><code>ErrInsecurePath</code></a>
|
||
when opening an archive which contains any file name that is an absolute path,
|
||
refers to a location outside the current directory, contains invalid
|
||
characters, or (on Windows) is a reserved names such as <code>NUL</code>.
|
||
A future version of Go may disable insecure paths by default.
|
||
</p>
|
||
<p><!-- CL 449955 -->
|
||
Reading from a directory file that contains file data will now return an error.
|
||
The zip specification does not permit directory files to contain file data,
|
||
so this change only affects reading from invalid archives.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- archive/zip -->
|
||
|
||
<dl id="bytes"><dt><a href="/pkg/bytes/">bytes</a></dt>
|
||
<dd>
|
||
<p><!-- CL 407176 -->
|
||
The new
|
||
<a href="/pkg/bytes/#CutPrefix"><code>CutPrefix</code></a> and
|
||
<a href="/pkg/bytes/#CutSuffix"><code>CutSuffix</code></a> functions
|
||
are like <a href="/pkg/bytes/#TrimPrefix"><code>TrimPrefix</code></a>
|
||
and <a href="/pkg/bytes/#TrimSuffix"><code>TrimSuffix</code></a>
|
||
but also report whether the string was trimmed.
|
||
</p>
|
||
|
||
<p><!-- CL 359675, https://go.dev/issue/45038 -->
|
||
The new <a href="/pkg/bytes/#Clone"><code>Clone</code></a> function
|
||
allocates a copy of a byte slice.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- bytes -->
|
||
|
||
<dl id="context"><dt><a href="/pkg/context/">context</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/51365, CL 375977 -->
|
||
The new <a href="/pkg/context/#WithCancelCause"><code>WithCancelCause</code></a> function
|
||
provides a way to cancel a context with a given error.
|
||
That error can be retrieved by calling the new <a href="/pkg/context/#Cause"><code>Cause</code></a> function.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- context -->
|
||
|
||
<dl id="crypto/ecdsa"><dt><a href="/pkg/crypto/ecdsa/">crypto/ecdsa</a></dt>
|
||
<dd>
|
||
<p><!-- CL 353849 -->
|
||
When using supported curves, all operations are now implemented in constant time.
|
||
This led to an increase in CPU time between 5% and 30%, mostly affecting P-384 and P-521.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/56088, CL 450816 -->
|
||
The new <a href="/pkg/crypto/ecdsa/#PrivateKey.ECDH"><code>PrivateKey.ECDH</code></a> method
|
||
converts an <code>ecdsa.PrivateKey</code> to an <code>ecdh.PrivateKey</code>.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- crypto/ecdsa -->
|
||
|
||
<dl id="crypto/ed25519"><dt><a href="/pkg/crypto/ed25519/">crypto/ed25519</a></dt>
|
||
<dd>
|
||
<p><!-- CL 373076, CL 404274, https://go.dev/issue/31804 -->
|
||
The <a href="/pkg/crypto/ed25519/#PrivateKey.Sign"><code>PrivateKey.Sign</code></a> method
|
||
and the
|
||
<a href="/pkg/crypto/ed25519/#VerifyWithOptions"><code>VerifyWithOptions</code></a> function
|
||
now support signing pre-hashed messages with Ed25519ph,
|
||
indicated by an
|
||
<a href="/pkg/crypto/ed25519/#Options.HashFunc"><code>Options.HashFunc</code></a>
|
||
that returns
|
||
<a href="/pkg/crypto/#SHA512"><code>crypto.SHA512</code></a>.
|
||
They also now support Ed25519ctx and Ed25519ph with context,
|
||
indicated by setting the new
|
||
<a href="/pkg/crypto/ed25519/#Options.Context"><code>Options.Context</code></a>
|
||
field.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- crypto/ed25519 -->
|
||
|
||
<dl id="crypto/rsa"><dt><a href="/pkg/crypto/rsa/">crypto/rsa</a></dt>
|
||
<dd>
|
||
<p><!-- CL 418874, https://go.dev/issue/19974 -->
|
||
The new field <a href="/pkg/crypto/rsa/#OAEPOptions.MGFHash"><code>OAEPOptions.MGFHash</code></a>
|
||
allows configuring the MGF1 hash separately for OAEP decryption.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/20654 -->
|
||
crypto/rsa now uses a new, safer, constant-time backend. This causes a CPU
|
||
runtime increase for decryption operations between approximately 15%
|
||
(RSA-2048 on amd64) and 45% (RSA-4096 on arm64), and more on 32-bit architectures.
|
||
Encryption operations are approximately 20x slower than before (but still 5-10x faster than decryption).
|
||
Performance is expected to improve in future releases.
|
||
Programs must not modify or manually generate the fields of
|
||
<a href="/pkg/crypto/rsa/#PrecomputedValues"><code>PrecomputedValues</code></a>.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- crypto/rsa -->
|
||
|
||
<dl id="crypto/subtle"><dt><a href="/pkg/crypto/subtle/">crypto/subtle</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/53021, CL 421435 -->
|
||
The new function <a href="/pkg/crypto/subtle/#XORBytes"><code>XORBytes</code></a>
|
||
XORs two byte slices together.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- crypto/subtle -->
|
||
|
||
<dl id="crypto/tls"><dt><a href="/pkg/crypto/tls/">crypto/tls</a></dt>
|
||
<dd>
|
||
<p><!-- CL 426455, CL 427155, CL 426454, https://go.dev/issue/46035 -->
|
||
Parsed certificates are now shared across all clients actively using that certificate.
|
||
The memory savings can be significant in programs that make many concurrent connections to a
|
||
server or collection of servers sharing any part of their certificate chains.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/48152, CL 449336 -->
|
||
For a handshake failure due to a certificate verification failure,
|
||
the TLS client and server now return an error of the new type
|
||
<a href="/pkg/crypto/tls/#CertificateVerificationError"><code>CertificateVerificationError</code></a>,
|
||
which includes the presented certificates.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- crypto/tls -->
|
||
|
||
<dl id="crypto/x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt>
|
||
<dd>
|
||
<p><!-- CL 450816, CL 450815 -->
|
||
<a href="/pkg/crypto/x509/#ParsePKCS8PrivateKey"><code>ParsePKCS8PrivateKey</code></a>
|
||
and
|
||
<a href="/pkg/crypto/x509/#MarshalPKCS8PrivateKey"><code>MarshalPKCS8PrivateKey</code></a>
|
||
now support keys of type <a href="/pkg/crypto/ecdh.PrivateKey"><code>*crypto/ecdh.PrivateKey</code></a>.
|
||
<a href="/pkg/crypto/x509/#ParsePKIXPublicKey"><code>ParsePKIXPublicKey</code></a>
|
||
and
|
||
<a href="/pkg/crypto/x509/#MarshalPKIXPublicKey"><code>MarshalPKIXPublicKey</code></a>
|
||
now support keys of type <a href="/pkg/crypto/ecdh.PublicKey"><code>*crypto/ecdh.PublicKey</code></a>.
|
||
Parsing NIST curve keys still returns values of type
|
||
<code>*ecdsa.PublicKey</code> and <code>*ecdsa.PrivateKey</code>.
|
||
Use their new <code>ECDH</code> methods to convert to the <code>crypto/ecdh</code> types.
|
||
</p>
|
||
<p><!-- CL 449235 -->
|
||
The new <a href="/pkg/crypto/x509/#SetFallbackRoots"><code>SetFallbackRoots</code></a>
|
||
function allows a program to define a set of fallback root certificates in case an
|
||
operating system verifier or standard platform root bundle is unavailable at runtime.
|
||
It will most commonly be used with a new package, <a href="/pkg/golang.org/x/crypto/x509roots/fallback">golang.org/x/crypto/x509roots/fallback</a>,
|
||
which will provide an up to date root bundle.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- crypto/x509 -->
|
||
|
||
<dl id="debug/elf"><dt><a href="/pkg/debug/elf/">debug/elf</a></dt>
|
||
<dd>
|
||
<p><!-- CL 429601 -->
|
||
Attempts to read from a <code>SHT_NOBITS</code> section using
|
||
<a href="/pkg/debug/elf/#Section.Data"><code>Section.Data</code></a>
|
||
or the reader returned by <a href="/pkg/debug/elf/#Section.Open"><code>Section.Open</code></a>
|
||
now return an error.
|
||
</p>
|
||
<p><!-- CL 420982 -->
|
||
Additional <a href="/pkg/debug/elf/#R_LARCH"><code>R_LARCH_*</code></a> constants are defined for use with LoongArch systems.
|
||
</p>
|
||
<p><!-- CL 420982, CL 435415, CL 425555 -->
|
||
Additional <a href="/pkg/debug/elf/#R_PPC64"><code>R_PPC64_*</code></a> constants are defined for use with PPC64 ELFv2 relocations.
|
||
</p>
|
||
<p><!-- CL 411915 -->
|
||
The constant value for <a href="/pkg/debug/elf/#R_PPC64_SECTOFF_LO_DS"><code>R_PPC64_SECTOFF_LO_DS</code></a> is corrected, from 61 to 62.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- debug/elf -->
|
||
|
||
<dl id="debug/gosym"><dt><a href="/pkg/debug/gosym/">debug/gosym</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/37762, CL 317917 -->
|
||
Due to a change of <a href="#linker">Go's symbol naming conventions</a>, tools that
|
||
process Go binaries should use Go 1.20's <code>debug/gosym</code> package to
|
||
transparently handle both old and new binaries.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- debug/gosym -->
|
||
|
||
<dl id="debug/pe"><dt><a href="/pkg/debug/pe/">debug/pe</a></dt>
|
||
<dd>
|
||
<p><!-- CL 421357 -->
|
||
Additional <a href="/pkg/debug/pe/#IMAGE_FILE_MACHINE_RISCV128"><code>IMAGE_FILE_MACHINE_RISCV*</code></a> constants are defined for use with RISC-V systems.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- debug/pe -->
|
||
|
||
<dl id="encoding/binary"><dt><a href="/pkg/encoding/binary/">encoding/binary</a></dt>
|
||
<dd>
|
||
<p><!-- CL 420274 -->
|
||
The <a href="/pkg/encoding/binary/#ReadVarint"><code>ReadVarint</code></a> and
|
||
<a href="/pkg/encoding/binary/#ReadUvarint"><code>ReadUvarint</code></a>
|
||
functions will now return <code>io.ErrUnexpectedEOF</code> after reading a partial value,
|
||
rather than <code>io.EOF</code>.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- encoding/binary -->
|
||
|
||
<dl id="encoding/xml"><dt><a href="/pkg/encoding/xml/">encoding/xml</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/53346, CL 424777 -->
|
||
The new <a href="/pkg/encoding/xml/#Encoder.Close"><code>Encoder.Close</code></a> method
|
||
can be used to check for unclosed elements when finished encoding.
|
||
</p>
|
||
|
||
<p><!-- CL 103875, CL 105636 -->
|
||
The decoder now rejects element and attribute names with more than one colon,
|
||
such as <code><a:b:c></code>,
|
||
as well as namespaces that resolve to an empty string, such as <code>xmlns:a=""</code>.
|
||
</p>
|
||
|
||
<p><!-- CL 107255 -->
|
||
The decoder now rejects elements that use different namespace prefixes in the opening and closing tag,
|
||
even if those prefixes both denote the same namespace.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- encoding/xml -->
|
||
|
||
<dl id="errors"><dt><a href="/pkg/errors/">errors</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/53435 -->
|
||
The new <a href="/pkg/errors/#Join"><code>Join</code></a> function returns an error wrapping a list of errors.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- errors -->
|
||
|
||
<dl id="fmt"><dt><a href="/pkg/fmt/">fmt</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/53435 -->
|
||
The <a href="/pkg/fmt/#Errorf"><code>Errorf</code></a> function supports multiple occurrences of
|
||
the <code>%w</code> format verb, returning an error that unwraps to the list of all arguments to <code>%w</code>.
|
||
</p>
|
||
<p><!-- https://go.dev/issue/51668, CL 400875 -->
|
||
The new <a href="/pkg/fmt/#FormatString"><code>FormatString</code></a> function recovers the
|
||
formatting directive corresponding to a <a href="/pkg/fmt/#State"><code>State</code></a>,
|
||
which can be useful in <a href="/pkg/fmt/#Formatter"><code>Formatter</code></a>.
|
||
implementations.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- fmt -->
|
||
|
||
<dl id="go/ast"><dt><a href="/pkg/go/ast/">go/ast</a></dt>
|
||
<dd>
|
||
<p><!-- CL 426091, https://go.dev/issue/50429 -->
|
||
The new <a href="/pkg/go/ast/#RangeStmt.Range"><code>RangeStmt.Range</code></a> field
|
||
records the position of the <code>range</code> keyword in a range statement.
|
||
</p>
|
||
<p><!-- CL 427955, https://go.dev/issue/53202 -->
|
||
The new <a href="/pkg/go/ast/#File.FileStart"><code>File.FileStart</code></a>
|
||
and <a href="/pkg/go/ast/#File.FileEnd"><code>File.FileEnd</code></a> fields
|
||
record the position of the start and end of the entire source file.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- go/ast -->
|
||
|
||
<dl id="go/token"><dt><a href="/pkg/go/token/">go/token</a></dt>
|
||
<dd>
|
||
<p><!-- CL 410114, https://go.dev/issue/53200 -->
|
||
The new <a href="/pkg/go/token/#FileSet.RemoveFile"><code>FileSet.RemoveFile</code></a> method
|
||
removes a file from a <code>FileSet</code>.
|
||
Long-running programs can use this to release memory associated
|
||
with files they no longer need.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- go/token -->
|
||
|
||
<dl id="go/types"><dt><a href="/pkg/go/types/">go/types</a></dt>
|
||
<dd>
|
||
<p><!-- CL 454575 -->
|
||
The new <a href="/pkg/go/types/#Satisfies"><code>Satisfies</code></a> function reports
|
||
whether a type satisfies a constraint.
|
||
This change aligns with the <a href="#language">new language semantics</a>
|
||
that distinguish satisfying a constraint from implementing an interface.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- go/types -->
|
||
|
||
<dl id="io"><dt><a href="/pkg/io/">io</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/45899, CL 406776 -->
|
||
The new <a href="/pkg/io/#OffsetWriter"><code>OffsetWriter</code></a> wraps an underlying
|
||
<a href="/pkg/io/#WriterAt"><code>WriterAt</code></a>
|
||
and provides <code>Seek</code>, <code>Write</code>, and <code>WriteAt</code> methods
|
||
that adjust their effective file offset position by a fixed amount.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- io -->
|
||
|
||
<dl id="io/fs"><dt><a href="/pkg/io/fs/">io/fs</a></dt>
|
||
<dd>
|
||
<p><!-- CL 363814, https://go.dev/issue/47209 -->
|
||
The new error <a href="/pkg/io/fs/#SkipAll"><code>SkipAll</code></a>
|
||
terminates a <a href="/pkg/io/fs/#WalkDir"><code>WalkDir</code></a>
|
||
immediately but successfully.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- io -->
|
||
|
||
<dl id="math/big"><dt><a href="/pkg/math/big/">math/big</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/52182 -->
|
||
The <a href="/pkg/math/big/">math/big</a> package's wide scope and
|
||
input-dependent timing make it ill-suited for implementing cryptography.
|
||
The cryptography packages in the standard library no longer call non-trivial
|
||
<a href="/pkg/math/big#Int">Int</a> methods on attacker-controlled inputs.
|
||
In the future, the determination of whether a bug in math/big is
|
||
considered a security vulnerability will depend on its wider impact on the
|
||
standard library.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- math/big -->
|
||
|
||
<dl id="math/rand"><dt><a href="/pkg/math/rand/">math/rand</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/54880, CL 436955, https://go.dev/issue/56319 -->
|
||
The <a href="/pkg/math/rand/">math/rand</a> package now automatically seeds
|
||
the global random number generator
|
||
(used by top-level functions like <code>Float64</code> and <code>Int</code>) with a random value,
|
||
and the top-level <a href="/pkg/math/rand/#Seed"><code>Seed</code></a> function has been deprecated.
|
||
Programs that need a reproducible sequence of random numbers
|
||
should prefer to allocate their own random source, using <code>rand.New(rand.NewSource(seed))</code>.
|
||
</p>
|
||
<p>
|
||
Programs that need the earlier consistent global seeding behavior can set
|
||
<code>GODEBUG=randautoseed=0</code> in their environment.
|
||
</p>
|
||
<p><!-- https://go.dev/issue/20661 -->
|
||
The top-level <a href="/pkg/math/rand/#Read"><code>Read</code></a> function has been deprecated.
|
||
In almost all cases, <a href="/pkg/crypto/rand/#Read"><code>crypto/rand.Read</code></a> is more appropriate.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- math/rand -->
|
||
|
||
<dl id="mime"><dt><a href="/pkg/mime/">mime</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/48866 -->
|
||
The <a href="/pkg/mime/#ParseMediaType"><code>ParseMediaType</code></a> function now allows duplicate parameter names,
|
||
so long as the values of the names are the same.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- mime -->
|
||
|
||
<dl id="mime/multipart"><dt><a href="/pkg/mime/multipart/">mime/multipart</a></dt>
|
||
<dd>
|
||
<p><!-- CL 431675 -->
|
||
Methods of the <a href="/pkg/mime/multipart/#Reader"><code>Reader</code></a> type now wrap errors
|
||
returned by the underlying <code>io.Reader</code>.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- mime/multipart -->
|
||
|
||
<dl id="net"><dt><a href="/pkg/net/">net</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/50101, CL 446179 -->
|
||
The <a href="/pkg/net/#LookupCNAME"><code>LookupCNAME</code></a>
|
||
function now consistently returns the contents
|
||
of a <code>CNAME</code> record when one exists. Previously on Unix systems and
|
||
when using the pure Go resolver, <code>LookupCNAME</code> would return an error
|
||
if a <code>CNAME</code> record referred to a name that with no <code>A</code>,
|
||
<code>AAAA</code>, or <code>CNAME</code> record. This change modifies
|
||
<code>LookupCNAME</code> to match the previous behavior on Windows,
|
||
allowing <code>LookupCNAME</code> to succeed whenever a
|
||
<code>CNAME</code> exists.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/53482, CL 413454 -->
|
||
<a href="/pkg/net/#Interface.Flags"><code>Interface.Flags</code></a> now includes the new flag <code>FlagRunning</code>,
|
||
indicating an operationally active interface. An interface which is administratively
|
||
configured but not active (for example, because the network cable is not connected)
|
||
will have <code>FlagUp</code> set but not <code>FlagRunning</code>.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/55301, CL 444955 -->
|
||
The new <a href="/pkg/net/#Dialer.ControlContext"><code>Dialer.ControlContext</code></a> field contains a callback function
|
||
similar to the existing <a href="/pkg/net/#Dialer.Control"><code>Dialer.Control</code></a> hook, that additionally
|
||
accepts the dial context as a parameter.
|
||
<code>Control</code> is ignored when <code>ControlContext</code> is not nil.
|
||
</p>
|
||
|
||
<p><!-- CL 428955 -->
|
||
The Go DNS resolver recognizes the <code>trust-ad</code> resolver option.
|
||
When <code>options trust-ad</code> is set in <code>resolv.conf</code>,
|
||
the Go resolver will set the AD bit in DNS queries. The resolver does not
|
||
make use of the AD bit in responses.
|
||
</p>
|
||
|
||
<p><!-- CL 448075 -->
|
||
DNS resolution will detect changes to <code>/etc/nsswitch.conf</code>
|
||
and reload the file when it changes. Checks are made at most once every
|
||
five seconds, matching the previous handling of <code>/etc/hosts</code>
|
||
and <code>/etc/resolv.conf</code>.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- net -->
|
||
|
||
<dl id="net/http"><dt><a href="/pkg/net/http/">net/http</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/51914 -->
|
||
The <a href="/pkg/net/http/#ResponseWriter.WriteHeader"><code>ResponseWriter.WriteHeader</code></a> function now supports sending
|
||
<code>1xx</code> status codes.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/41773, CL 356410 -->
|
||
The new <a href="/pkg/net/http/#Server.DisableGeneralOptionsHandler"><code>Server.DisableGeneralOptionsHandler</code></a> configuration setting
|
||
allows disabling the default <code>OPTIONS *</code> handler.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/54299, CL 447216 -->
|
||
The new <a href="/pkg/net/http/#Transport.OnProxyConnectResponse"><code>Transport.OnProxyConnectResponse</code></a> hook is called
|
||
when a <code>Transport</code> receives an HTTP response from a proxy
|
||
for a <code>CONNECT</code> request.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/53960, CL 418614 -->
|
||
The HTTP server now accepts HEAD requests containing a body,
|
||
rather than rejecting them as invalid.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/53896 -->
|
||
HTTP/2 stream errors returned by <code>net/http</code> functions may be converted
|
||
to a <a href="/pkg/golang.org/x/net/http2/#StreamError"><code>golang.org/x/net/http2.StreamError</code></a> using
|
||
<a href="/pkg/errors/#As"><code>errors.As</code></a>.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/cl/397734 -->
|
||
Leading and trailing spaces are trimmed from cookie names,
|
||
rather than being rejected as invalid.
|
||
For example, a cookie setting of "name =value"
|
||
is now accepted as setting the cookie "name".
|
||
</p>
|
||
</dd>
|
||
</dl><!-- net/http -->
|
||
|
||
<dl id="net/netip"><dt><a href="/pkg/net/netip/">net/netip</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/51766, https://go.dev/issue/51777, CL 412475 -->
|
||
The new <a href="/pkg/net/netip/#IPv6LinkLocalAllRouters"><code>IPv6LinkLocalAllRouters</code></a>
|
||
and <a href="/pkg/net/netip/#IPv6Loopback"><code>IPv6Loopback</code></a> functions
|
||
are the <code>net/netip</code> equivalents of
|
||
<a href="/pkg/net/#IPv6loopback"><code>net.IPv6loopback</code></a> and
|
||
<a href="/pkg/net/#IPv6linklocalallrouters"><code>net.IPv6linklocalallrouters</code></a>.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- net/netip -->
|
||
|
||
<dl id="os"><dt><a href="/pkg/os/">os</a></dt>
|
||
<dd>
|
||
<p><!-- CL 448897 -->
|
||
On Windows, the name <code>NUL</code> is no longer treated as a special case in
|
||
<a href="/pkg/os/#Mkdir"><code>Mkdir</code></a> and
|
||
<a href="/pkg/os/#Stat"><code>Stat</code></a>.
|
||
</p>
|
||
<p><!-- https://go.dev/issue/52747, CL 405275 -->
|
||
On Windows, <a href="/pkg/os/#File.Stat"><code>File.Stat</code></a>
|
||
now uses the file handle to retrieve attributes when the file is a directory.
|
||
Previously it would use the path passed to
|
||
<a href="/pkg/os/#Open"><code>Open</code></a>, which may no longer be the file
|
||
represented by the file handle if the file has been moved or replaced.
|
||
This change modifies <code>Open</code> to open directories without the
|
||
<code>FILE_SHARE_DELETE</code> access, which match the behavior of regular files.
|
||
</p>
|
||
<p><!-- https://go.dev/issue/36019, CL 405275 -->
|
||
On Windows, <a href="/pkg/os/#File.Seek"><code>File.Seek</code></a> now supports
|
||
seeking to the beginning of a directory.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- os -->
|
||
|
||
<dl id="os/exec"><dt><a href="/pkg/os/exec/">os/exec</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/50436, CL 401835 -->
|
||
The new <a href="/pkg/os/exec/#Cmd"><code>Cmd</code></a> fields
|
||
<a href="/pkg/os/exec/#Cmd.Cancel"><code>Cancel</code></a> and
|
||
<a href="/pkg/os/exec/#Cmd.WaitDelay"><code>WaitDelay</code></a>
|
||
specify the behavior of the <code>Cmd</code> when its associated
|
||
<code>Context</code> is canceled or its process exits with I/O pipes still
|
||
held open by a child process.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- os/exec -->
|
||
|
||
<dl id="path/filepath"><dt><a href="/pkg/path/filepath/">path/filepath</a></dt>
|
||
<dd>
|
||
<p><!-- CL 363814, https://go.dev/issue/47209 -->
|
||
The new error <a href="/pkg/path/filepath/#SkipAll"><code>SkipAll</code></a>
|
||
terminates a <a href="/pkg/path/filepath/#Walk"><code>Walk</code></a>
|
||
immediately but successfully.
|
||
</p>
|
||
<p><!-- https://go.dev/issue/56219, CL 449239 -->
|
||
The new <a href="/pkg/path/filepath/#IsLocal"><code>IsLocal</code></a> function reports whether a path is
|
||
lexically local to a directory.
|
||
For example, if <code>IsLocal(p)</code> is <code>true</code>,
|
||
then <code>Open(p)</code> will refer to a file that is lexically
|
||
within the subtree rooted at the current directory.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- io -->
|
||
|
||
<dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/46746, CL 423794 -->
|
||
The new <a href="/pkg/reflect/#Value.Comparable"><code>Value.Comparable</code></a> and
|
||
<a href="/pkg/reflect/#Value.Equal"><code>Value.Equal</code></a> methods
|
||
can be used to compare two <code>Value</code>s for equality.
|
||
<code>Comparable</code> reports whether <code>Equal</code> is a valid operation for a given <code>Value</code> receiver.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/48000, CL 389635 -->
|
||
The new <a href="/pkg/reflect/#Value.Grow"><code>Value.Grow</code></a> method
|
||
extends a slice to guarantee space for another <code>n</code> elements.
|
||
</p>
|
||
|
||
<p><!-- https://go.dev/issue/52376, CL 411476 -->
|
||
The new <a href="/pkg/reflect/#Value.SetZero"><code>Value.SetZero</code></a> method
|
||
sets a value to be the zero value for its type.
|
||
</p>
|
||
|
||
<p><!-- CL 425184 -->
|
||
Go 1.18 introduced <a href="/pkg/reflect/#Value.SetIterKey"><code>Value.SetIterKey</code></a>
|
||
and <a href="/pkg/reflect/#Value.SetIterValue"><code>Value.SetIterValue</code></a> methods.
|
||
These are optimizations: <code>v.SetIterKey(it)</code> is meant to be equivalent to <code>v.Set(it.Key())</code>.
|
||
The implementations incorrectly omitted a check for use of unexported fields that was present in the unoptimized forms.
|
||
Go 1.20 corrects these methods to include the unexported field check.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- reflect -->
|
||
|
||
<dl id="regexp"><dt><a href="/pkg/regexp/">regexp</a></dt>
|
||
<dd>
|
||
<p><!-- CL 444817 -->
|
||
Go 1.19.2 and Go 1.18.7 included a security fix to the regular expression parser,
|
||
making it reject very large expressions that would consume too much memory.
|
||
Because Go patch releases do not introduce new API,
|
||
the parser returned <a href="/pkg/regexp/syntax/#ErrInternalError"><code>syntax.ErrInternalError</code></a> in this case.
|
||
Go 1.20 adds a more specific error, <a href="/pkg/regexp/syntax/#ErrLarge"><code>syntax.ErrLarge</code></a>,
|
||
which the parser now returns instead.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- regexp -->
|
||
|
||
<dl id="runtime/cgo"><dt><a href="/pkg/runtime/cgo/">runtime/cgo</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/46731, CL 421879 -->
|
||
Go 1.20 adds new <a href="/pkg/runtime/cgo/#Incomplete"><code>Incomplete</code></a> marker type.
|
||
Code generated by cgo will use <code>cgo.Incomplete</code> to mark an incomplete C type.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- runtime/cgo -->
|
||
|
||
<dl id="runtime/metrics"><dt><a href="/pkg/runtime/metrics/">runtime/metrics</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/47216, https://go.dev/issue/49881 -->
|
||
Go 1.20 adds new <a href="/pkg/runtime/metrics/#hdr-Supported_metrics">supported metrics</a>,
|
||
including the current <code>GOMAXPROCS</code> setting (<code>/sched/gomaxprocs:threads</code>),
|
||
the number of cgo calls executed (<code>/cgo/go-to-c-calls:calls</code>),
|
||
total mutex block time (<code>/sync/mutex/wait/total</code>), and various measures of time
|
||
spent in garbage collection.
|
||
</p>
|
||
|
||
<p><!-- CL 427615 -->
|
||
Time-based histogram metrics are now less precise, but take up much less memory.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- runtime/metrics -->
|
||
|
||
<dl id="runtime/pprof"><dt><a href="/pkg/runtime/pprof/">runtime/pprof</a></dt>
|
||
<dd>
|
||
<p><!-- CL 443056 -->
|
||
Mutex profile samples are now pre-scaled, fixing an issue where old mutex profile
|
||
samples would be scaled incorrectly if the sampling rate changed during execution.
|
||
</p>
|
||
|
||
<p><!-- CL 416975 -->
|
||
Profiles collected on Windows now include memory mapping information that fixes
|
||
symbolization issues for position-independent binaries.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- runtime/pprof -->
|
||
|
||
<dl id="runtime/trace"><dt><a href="/pkg/runtime/trace/">runtime/trace</a></dt>
|
||
<dd>
|
||
<p><!-- CL 447135, https://go.dev/issue/55022 -->
|
||
The garbage collector's background sweeper now yields less frequently,
|
||
resulting in many fewer extraneous events in execution traces.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- runtime/trace -->
|
||
|
||
<dl id="strings"><dt><a href="/pkg/strings/">strings</a></dt>
|
||
<dd>
|
||
<p><!-- CL 407176, https://go.dev/issue/42537 -->
|
||
The new
|
||
<a href="/pkg/strings/#CutPrefix"><code>CutPrefix</code></a> and
|
||
<a href="/pkg/strings/#CutSuffix"><code>CutSuffix</code></a> functions
|
||
are like <a href="/pkg/strings/#TrimPrefix"><code>TrimPrefix</code></a>
|
||
and <a href="/pkg/strings/#TrimSuffix"><code>TrimSuffix</code></a>
|
||
but also report whether the string was trimmed.
|
||
</p>
|
||
|
||
<p><!-- CL 359675, https://go.dev/issue/45038 -->
|
||
The new <a href="/pkg/strings/#Clone"><code>Clone</code></a> function
|
||
allocates a copy of a string.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- strings -->
|
||
|
||
<dl id="sync"><dt><a href="/pkg/sync/">sync</a></dt>
|
||
<dd>
|
||
<p><!-- CL 399094, https://go.dev/issue/51972 -->
|
||
The new <a href="/pkg/sync/#Map"><code>Map</code></a> methods <a href="/pkg/sync/#Map.Swap"><code>Swap</code></a>,
|
||
<a href="/pkg/sync/#Map.CompareAndSwap"><code>CompareAndSwap</code></a>, and
|
||
<a href="/pkg/sync/#Map.CompareAndDelete"><code>CompareAndDelete</code></a>
|
||
allow existing map entries to be updated atomically.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- sync -->
|
||
|
||
<dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt>
|
||
<dd>
|
||
<p><!-- CL 411596 -->
|
||
On FreeBSD, compatibility shims needed for FreeBSD 11 and earlier have been removed.
|
||
</p>
|
||
<p><!-- CL 407574 -->
|
||
On Linux, additional <a href="/pkg/syscall/#CLONE_CLEAR_SIGHAND"><code>CLONE_*</code></a> constants
|
||
are defined for use with the <a href="/pkg/syscall/#SysProcAttr.Cloneflags"><code>SysProcAttr.Cloneflags</code></a> field.
|
||
</p>
|
||
<p><!-- CL 417695 -->
|
||
On Linux, the new <a href="/pkg/syscall/#SysProcAttr.CgroupFD"><code>SysProcAttr.CgroupFD</code></a>
|
||
and <a href="/pkg/syscall/#SysProcAttr.UseCgroupFD"><code>SysProcAttr.UseCgroupFD</code></a> fields
|
||
provide a way to place a child process into a specific cgroup.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- syscall -->
|
||
|
||
<dl id="testing"><dt><a href="/pkg/testing/">testing</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/43620, CL 420254 -->
|
||
The new method <a href="/pkg/testing/#B.Elapsed"><code>B.Elapsed</code></a>
|
||
reports the current elapsed time of the benchmark, which may be useful for
|
||
calculating rates to report with <code>ReportMetric</code>.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- testing -->
|
||
|
||
<dl id="time"><dt><a href="/pkg/time/">time</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/52746, CL 412495 -->
|
||
The new time layout constants <a href="/pkg/time/#DateTime"><code>DateTime</code></a>,
|
||
<a href="/pkg/time/#DateOnly"><code>DateOnly</code></a>, and
|
||
<a href="/pkg/time/#TimeOnly"><code>TimeOnly</code></a>
|
||
provide names for three of the most common layout strings used in a survey of public Go source code.
|
||
</p>
|
||
|
||
<p><!-- CL 382734, https://go.dev/issue/50770 -->
|
||
The new <a href="/pkg/time/#Time.Compare"><code>Time.Compare</code></a> method
|
||
compares two times.
|
||
</p>
|
||
|
||
<p><!-- CL 425037 -->
|
||
<a href="/pkg/time/#Parse"><code>Parse</code></a>
|
||
now ignores sub-nanosecond precision in its input,
|
||
instead of reporting those digits as an error.
|
||
</p>
|
||
|
||
<p><!-- CL 444277 -->
|
||
The <a href="/pkg/time/#Time.MarshalJSON"><code>Time.MarshalJSON</code></a> method
|
||
is now more strict about adherence to RFC 3339.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- time -->
|
||
|
||
<dl id="unicode/utf16"><dt><a href="/pkg/unicode/utf16/">unicode/utf16</a></dt>
|
||
<dd>
|
||
<p><!-- https://go.dev/issue/51896, CL 409054 -->
|
||
The new <a href="/pkg/unicode/utf16/#AppendRune"><code>AppendRune</code></a>
|
||
function appends the UTF-16 encoding of a given rune to a uint16 slice,
|
||
analogous to <a href="/pkg/unicode/utf8/#AppendRune"><code>utf8.AppendRune</code></a>.
|
||
</p>
|
||
</dd>
|
||
</dl><!-- unicode/utf16 -->
|
||
|
||
<!-- Silence false positives from x/build/cmd/relnote: -->
|
||
<!-- https://go.dev/issue/45964 was documented in Go 1.18 release notes but closed recently -->
|
||
<!-- https://go.dev/issue/52114 is an accepted proposal to add golang.org/x/net/http2.Transport.DialTLSContext; it's not a part of the Go release -->
|
||
<!-- CL 431335: cmd/api: make check pickier about api/*.txt -->
|
||
<!-- CL 447896 api: add newline to 55301.txt; modified api/next/55301.txt -->
|
||
<!-- CL 449215 api/next/54299: add missing newline; modified api/next/54299.txt -->
|
||
<!-- CL 433057 cmd: update vendored golang.org/x/tools for multiple error wrapping -->
|
||
<!-- CL 423362 crypto/internal/boring: update to newer boringcrypto, add arm64 -->
|
||
<!-- https://go.dev/issue/53481 x/cryptobyte ReadUint64, AddUint64 -->
|
||
<!-- https://go.dev/issue/51994 x/crypto/ssh -->
|
||
<!-- https://go.dev/issue/55358 x/exp/slices -->
|
||
<!-- https://go.dev/issue/54714 x/sys/unix -->
|
||
<!-- https://go.dev/issue/50035 https://go.dev/issue/54237 x/time/rate -->
|
||
<!-- CL 345488 strconv optimization -->
|
||
<!-- CL 428757 reflect deprecation, rolled back -->
|
||
<!-- https://go.dev/issue/49390 compile -l -N is fully supported -->
|
||
<!-- https://go.dev/issue/54619 x/tools -->
|
||
<!-- CL 448898 reverted -->
|
||
<!-- https://go.dev/issue/54850 x/net/http2 Transport.MaxReadFrameSize -->
|
||
<!-- https://go.dev/issue/56054 x/net/http2 SETTINGS_HEADER_TABLE_SIZE -->
|
||
<!-- CL 450375 reverted -->
|
||
<!-- CL 453259 tracking deprecations in api -->
|
||
<!-- CL 453260 tracking darwin port in api -->
|
||
<!-- CL 453615 fix deprecation comment in archive/tar -->
|
||
<!-- CL 453616 fix deprecation comment in archive/zip -->
|
||
<!-- CL 453617 fix deprecation comment in encoding/csv -->
|
||
<!-- https://go.dev/issue/54661 x/tools/go/analysis -->
|
||
<!-- CL 423359, https://go.dev/issue/51317 arena -->
|