From 036696a2ea04a7be334b3f0442fcadcab2eeaf70 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 22 Nov 2022 10:38:34 -0500 Subject: [PATCH] doc/go1.20: finish most standard library TODOs Change-Id: Id8f074b96d28ae37a3d2d2a52a2b80cc53cd1203 Reviewed-on: https://go-review.googlesource.com/c/go/+/452760 TryBot-Bypass: Russ Cox Reviewed-by: Ian Lance Taylor --- doc/go1.20.html | 188 +++++++++++++++++++++---------------------- src/reflect/value.go | 3 +- 2 files changed, 94 insertions(+), 97 deletions(-) diff --git a/doc/go1.20.html b/doc/go1.20.html index 8f5b901ffd..9a90cb8a80 100644 --- a/doc/go1.20.html +++ b/doc/go1.20.html @@ -101,7 +101,7 @@ Do not send CLs removing the interior tags from such phrases. the packages named on the command line.

-

+

The go command now defines architecture feature build tags, such as amd64.v2, to allow selecting a package implementation file based on the presence @@ -432,11 +432,17 @@ proxyHandler := &httputil.ReverseProxy{

bytes

- TODO: https://go.dev/cl/407176: strings, bytes: add CutPrefix and CutSuffix + The new + CutPrefix and + CutSuffix functions + are like TrimPrefix + and TrimSuffix + but also report whether the string was trimmed.

- TODO: https://go.dev/cl/359675: bytes: add Clone function + The new Clone function + allocates a copy of a byte slice.

@@ -537,20 +543,20 @@ proxyHandler := &httputil.ReverseProxy{
encoding/xml
-

- TODO: https://go.dev/issue/53346: Add (*Encoder).Close() to check for unclosed elements +

+ The new Encoder.Close method + can be used to check for unclosed elements when finished encoding.

-

- TODO: https://go.dev/cl/424777: encoding/xml: add (*Encoder).Close -

- -

- TODO: https://go.dev/cl/103875: encoding/xml: error when more than one colon in qualified names +

+ The decoder now rejects element and attribute names with more than one colon, + such as <a:b:c>, + as well as namespaces that resolve to an empty string, such as xmlns:a="".

- TODO: https://go.dev/cl/107255: encoding/xml: error when closing tag does not match opening tag + 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.

@@ -569,12 +575,11 @@ proxyHandler := &httputil.ReverseProxy{ The Errorf function supports multiple occurrences of the %w format verb, returning an error that unwraps to the list of all arguments to %w.

-

- TODO: https://go.dev/issue/51668: add FormatString(State) string -

- -

- TODO: https://go.dev/cl/400875: fmt: add a function to recover the original format string given a State; modified api/next/51668.txt +

+ The new FormatString function recovers the + formatting directive corresponding to a State, + which can be useful in Formatter. + implementations.

@@ -591,14 +596,6 @@ proxyHandler := &httputil.ReverseProxy{ -
go/build
-
-

- TODO: https://go.dev/cl/421434: go/build: add GO$GOARCH-based ToolTags -

-
-
-
go/token

@@ -609,20 +606,21 @@ proxyHandler := &httputil.ReverseProxy{

io
-

- TODO: https://go.dev/issue/45899: add OffsetWriter, NewOffsetWriter -

- -

- TODO: https://go.dev/cl/406776: io: add OffsetWriter, NewOffsetWriter; modified api/next/45899.txt +

+ The new OffsetWriter wraps an underlying + WriterAt + and provides Seek, Write, and WriteAt methods + that adjust their effective file offset position by a fixed amount.

io/fs
-

- TODO: https://go.dev/cl/363814: path/filepath, io/fs: add SkipAll; modified api/next/47209.txt +

+ The new error SkipAll + terminates a WalkDir + immediately but successfully.

@@ -757,16 +755,12 @@ proxyHandler := &httputil.ReverseProxy{
net/netip
-

- TODO: https://go.dev/issue/51766: add IPv6LinkLocalAllRouters -

- -

- TODO: https://go.dev/issue/51777: add IPv6Loopback -

- -

- TODO: https://go.dev/cl/412475: net/netip: add IPv6LinkLocalAllRouters and IPv6Loopback; modified api/next/51766.txt, api/next/51777.txt +

+ The new IPv6LinkLocalAllRouters + and IPv6Loopback functions + are the net/netip equivalents of + net.IPv6loopback and + net.IPv6linklocalallrouters.

@@ -795,7 +789,9 @@ proxyHandler := &httputil.ReverseProxy{
path/filepath

- TODO: https://go.dev/cl/363814: path/filepath, io/fs: add SkipAll; modified api/next/47209.txt + The new error SkipAll + terminates a Walk + immediately but successfully.

The new IsLocal function reports whether a path is @@ -809,36 +805,29 @@ proxyHandler := &httputil.ReverseProxy{

reflect
-

- TODO: https://go.dev/issue/46746: add Value.Equal, Value.Comparable -

- -

- TODO: https://go.dev/issue/48000: add reflect.Value.Grow +

+ The new Value.Comparable and + Value.Equal methods + can be used to compare two Values for equality. + Comparable reports whether Equal is a valid operation for a given Value receiver.

-

- TODO: https://go.dev/issue/52376: add Value.SetZero +

+ The new Value.Grow method + extends a slice to guarantee space for another n elements.

-

- TODO: https://go.dev/cl/389635: reflect: add Value.Grow -

- -

- TODO: https://go.dev/cl/411476: reflect: add Value.SetZero -

- -

- TODO: https://go.dev/cl/423794: reflect: add Value.{Comparable,Equal} +

+ The new Value.SetZero method + sets a value to be the zero value for its type.

- TODO: https://go.dev/cl/425184: reflect: fix Value.SetIterXXX to check for the read-only bit -

- -

- TODO: https://go.dev/cl/428757: reflect: deprecate SliceHeader and StringHeader + Go 1.18 introduced Value.SetIterKey + and Value.SetIterValue methods. + These are optimizations: v.SetIterKey(it) is meant to be equivalent to v.Set(it.Key()). + 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.

@@ -846,7 +835,12 @@ proxyHandler := &httputil.ReverseProxy{
regexp

- TODO: https://go.dev/cl/444817: regexp: add ErrLarge error; modified api/next/56041.txt + 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 syntax.ErrInternalError in this case. + Go 1.20 adds a more specific error, syntax.ErrLarge, + which the parser now returns instead.

@@ -859,22 +853,20 @@ proxyHandler := &httputil.ReverseProxy{
-
strconv
-
-

- TODO: https://go.dev/cl/345488: strconv: optimize Parse for []byte arguments -

-
-
-
strings
-

- TODO: https://go.dev/issue/42537: add CutPrefix and CutSuffix +

+ The new + CutPrefix and + CutSuffix functions + are like TrimPrefix + and TrimSuffix + but also report whether the string was trimmed.

-

- TODO: https://go.dev/issue/45038: bytes, strings: add Clone +

+ The new Clone function + allocates a copy of a string.

@@ -918,36 +910,38 @@ proxyHandler := &httputil.ReverseProxy{
time
-

- TODO: https://go.dev/issue/52746: add DateTime, DateOnly, TimeOnly format constants -

- -

- TODO: https://go.dev/cl/412495: time: add DateTime, DateOnly, and TimeOnly +

+ The new time layout constants DateTime, + DateOnly, and + TimeOnly + provide names for three of the most common layout strings used in a survey of public Go source code.

- TODO: https://go.dev/cl/382734: time: implement Compare method + The new Time.Compare method + compares two times.

- TODO: https://go.dev/cl/425037: time: fix Parse to ignore extra sub-nanosecond digits + Parse + now ignores sub-nanosecond precision in its input, + instead of reporting those digits as an error.

- TODO: https://go.dev/cl/444277: time: implement strict RFC 3339 during marshal and unmarshal + The Time.MarshalJSON and + Time.UnmarshalJSON methods + are now more strict about adherence to RFC 3339.

unicode/utf16
-

- TODO: https://go.dev/issue/51896: add AppendRune -

- -

- TODO: https://go.dev/cl/409054: unicode/utf16: add AppendRune; modified api/next/51896.txt +

+ The new AppendRune + function appends the UTF-16 encoding of a given rune to a uint16 slice, + analogous to utf8.AppendRune.

@@ -967,3 +961,5 @@ proxyHandler := &httputil.ReverseProxy{ + + diff --git a/src/reflect/value.go b/src/reflect/value.go index 4acd3238b4..c27e517411 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -3284,7 +3284,8 @@ func (v Value) CanConvert(t Type) bool { // Comparable reports whether the value v is comparable. // If the type of v is an interface, this checks the dynamic type. -// If this reports true then v.Interface() == x will not panic for any x. +// If this reports true then v.Interface() == x will not panic for any x, +// nor will v.Equal(u) for any Value u. func (v Value) Comparable() bool { k := v.Kind() switch k { -- 2.50.0