From 94d899bc857dc17e9d6c9cad67cb6e75ffaad68d Mon Sep 17 00:00:00 2001 From: Jonathan Amsterdam Date: Mon, 13 Nov 2023 11:33:24 -0500 Subject: [PATCH] _content/doc: change relnote definition lists to headings Since 1.7, the "Minor changes to the library" second has used a definition list to describe the changes to each package. Use level 4 headings instead. This removes one feature that is not CommonMark-compliant. It paves the way for using a CommonMark-compliant Markdown parser and renderer for both display and generation of release notes. For golang/go#64169. Change-Id: I2327499971a2db4eee06ef35e3e41cd0d2f953b3 Reviewed-on: https://go-review.googlesource.com/c/website/+/541976 Reviewed-by: Dmitri Shuralyov Reviewed-by: Dmitri Shuralyov Run-TryBot: Jonathan Amsterdam TryBot-Result: Gopher Robot --- _content/doc/go1.10.md | 1198 +++++++++++++++++----------------- _content/doc/go1.11.md | 530 ++++++++-------- _content/doc/go1.12.md | 566 ++++++++--------- _content/doc/go1.13.md | 544 ++++++++-------- _content/doc/go1.14.md | 608 +++++++++--------- _content/doc/go1.15.md | 758 +++++++++++----------- _content/doc/go1.16.md | 840 ++++++++++++------------ _content/doc/go1.17.md | 808 +++++++++++------------ _content/doc/go1.18.md | 866 ++++++++++++------------- _content/doc/go1.19.md | 948 +++++++++++++-------------- _content/doc/go1.20.md | 872 ++++++++++++------------- _content/doc/go1.21.md | 1048 +++++++++++++++--------------- _content/doc/go1.7.md | 1084 +++++++++++++++---------------- _content/doc/go1.8.md | 1376 ++++++++++++++++++++-------------------- _content/doc/go1.9.md | 706 ++++++++++----------- 15 files changed, 6376 insertions(+), 6376 deletions(-) diff --git a/_content/doc/go1.10.md b/_content/doc/go1.10.md index 1967dcc3..6fc1ebf6 100644 --- a/_content/doc/go1.10.md +++ b/_content/doc/go1.10.md @@ -521,603 +521,603 @@ As always, there are various minor changes and updates to the library, made with the Go 1 [promise of compatibility](/doc/go1compat) in mind. -[archive/tar](/pkg/archive/tar/) - -: In general, the handling of special header formats is significantly improved and expanded. - - [`FileInfoHeader`](/pkg/archive/tar/#FileInfoHeader) has always - recorded the Unix UID and GID numbers from its [`os.FileInfo`](/pkg/os/#FileInfo) argument - (specifically, from the system-dependent information returned by the `FileInfo`'s `Sys` method) - in the returned [`Header`](/pkg/archive/tar/#Header). - Now it also records the user and group names corresponding to those IDs, - as well as the major and minor device numbers for device files. - - The new [`Header.Format`](/pkg/archive/tar/#Header) field - of type [`Format`](/pkg/archive/tar/#Format) - controls which tar header format the [`Writer`](/pkg/archive/tar/#Writer) uses. - The default, as before, is to select the most widely-supported header type - that can encode the fields needed by the header (USTAR if possible, or else PAX if possible, or else GNU). - The [`Reader`](/pkg/archive/tar/#Reader) sets `Header.Format` for each header it reads. - - `Reader` and the `Writer` now support arbitrary PAX records, - using the new [`Header.PAXRecords`](/pkg/archive/tar/#Header) field, - a generalization of the existing `Xattrs` field. - - The `Reader` no longer insists that the file name or link name in GNU headers - be valid UTF-8. - - When writing PAX- or GNU-format headers, the `Writer` now includes - the `Header.AccessTime` and `Header.ChangeTime` fields (if set). - When writing PAX-format headers, the times include sub-second precision. - -[archive/zip](/pkg/archive/zip/) - -: Go 1.10 adds more complete support for times and character set encodings in ZIP archives. - - The original ZIP format used the standard MS-DOS encoding of year, month, day, hour, minute, and second into fields in two 16-bit values. - That encoding cannot represent time zones or odd seconds, so multiple extensions have been - introduced to allow richer encodings. - In Go 1.10, the [`Reader`](/pkg/archive/zip/#Reader) and [`Writer`](/pkg/archive/zip/#Writer) - now support the widely-understood Info-Zip extension that encodes the time separately in the 32-bit Unix “seconds since epoch” form. - The [`FileHeader`](/pkg/archive/zip/#FileHeader)'s new `Modified` field of type [`time.Time`](/pkg/time/#Time) - obsoletes the `ModifiedTime` and `ModifiedDate` fields, which continue to hold the MS-DOS encoding. - The `Reader` and `Writer` now adopt the common - convention that a ZIP archive storing a time zone-independent Unix time - also stores the local time in the MS-DOS field, - so that the time zone offset can be inferred. - For compatibility, the [`ModTime`](/pkg/archive/zip/#FileHeader.ModTime) and - [`SetModTime`](/pkg/archive/zip/#FileHeader.SetModTime) methods - behave the same as in earlier releases; new code should use `Modified` directly. - - The header for each file in a ZIP archive has a flag bit indicating whether - the name and comment fields are encoded as UTF-8, as opposed to a system-specific default encoding. - In Go 1.8 and earlier, the `Writer` never set the UTF-8 bit. - In Go 1.9, the `Writer` changed to set the UTF-8 bit almost always. - This broke the creation of ZIP archives containing Shift-JIS file names. - In Go 1.10, the `Writer` now sets the UTF-8 bit only when - both the name and the comment field are valid UTF-8 and at least one is non-ASCII. - Because non-ASCII encodings very rarely look like valid UTF-8, the new - heuristic should be correct nearly all the time. - Setting a `FileHeader`'s new `NonUTF8` field to true - disables the heuristic entirely for that file. - - The `Writer` also now supports setting the end-of-central-directory record's comment field, - by calling the `Writer`'s new [`SetComment`](/pkg/archive/zip/#Writer.SetComment) method. - -[bufio](/pkg/bufio/) - -: The new [`Reader.Size`](/pkg/bufio/#Reader.Size) - and [`Writer.Size`](/pkg/bufio/#Writer.Size) - methods report the `Reader` or `Writer`'s underlying buffer size. - -[bytes](/pkg/bytes/) - -: The - [`Fields`](/pkg/bytes/#Fields), - [`FieldsFunc`](/pkg/bytes/#FieldsFunc), - [`Split`](/pkg/bytes/#Split), - and - [`SplitAfter`](/pkg/bytes/#SplitAfter) - functions have always returned subslices of their inputs. - Go 1.10 changes each returned subslice to have capacity equal to its length, - so that appending to one cannot overwrite adjacent data in the original input. - -[crypto/cipher](/pkg/crypto/cipher/) - -: [`NewOFB`](/pkg/crypto/cipher/#NewOFB) now panics if given - an initialization vector of incorrect length, like the other constructors in the - package always have. - (Previously it returned a nil `Stream` implementation.) - -[crypto/tls](/pkg/crypto/tls/) - -: The TLS server now advertises support for SHA-512 signatures when using TLS 1.2. - The server already supported the signatures, but some clients would not select - them unless explicitly advertised. - -[crypto/x509](/pkg/crypto/x509/) - -: [`Certificate.Verify`](/pkg/crypto/x509/#Certificate.Verify) - now enforces the name constraints for all - names contained in the certificate, not just the one name that a client has asked about. - Extended key usage restrictions are similarly now checked all at once. - As a result, after a certificate has been validated, now it can be trusted in its entirety. - It is no longer necessary to revalidate the certificate for each additional name - or key usage. - - Parsed certificates also now report URI names and IP, email, and URI constraints, using the new - [`Certificate`](/pkg/crypto/x509/#Certificate) fields - `URIs`, `PermittedIPRanges`, `ExcludedIPRanges`, - `PermittedEmailAddresses`, `ExcludedEmailAddresses`, - `PermittedURIDomains`, and `ExcludedURIDomains`. Certificates with - invalid values for those fields are now rejected. - - The new [`MarshalPKCS1PublicKey`](/pkg/crypto/x509/#MarshalPKCS1PublicKey) - and [`ParsePKCS1PublicKey`](/pkg/crypto/x509/#ParsePKCS1PublicKey) - functions convert an RSA public key to and from PKCS#1-encoded form. - - The new [`MarshalPKCS8PrivateKey`](/pkg/crypto/x509/#MarshalPKCS8PrivateKey) - function converts a private key to PKCS#8-encoded form. - ([`ParsePKCS8PrivateKey`](/pkg/crypto/x509/#ParsePKCS8PrivateKey) - has existed since Go 1.) - -[crypto/x509/pkix](/pkg/crypto/x509/pkix/) - -: [`Name`](/pkg/crypto/x509/pkix/#Name) now implements a - [`String`](/pkg/crypto/x509/pkix/#Name.String) method that - formats the X.509 distinguished name in the standard RFC 2253 format. - -[database/sql/driver](/pkg/database/sql/driver/) - -: Drivers that currently hold on to the destination buffer provided by - [`driver.Rows.Next`](/pkg/database/sql/driver/#Rows.Next) should ensure they no longer - write to a buffer assigned to the destination array outside of that call. - Drivers must be careful that underlying buffers are not modified when closing - [`driver.Rows`](/pkg/database/sql/driver/#Rows). - - Drivers that want to construct a [`sql.DB`](/pkg/database/sql/#DB) for - their clients can now implement the [`Connector`](/pkg/database/sql/driver/#Connector) interface - and call the new [`sql.OpenDB`](/pkg/database/sql/#OpenDB) function, - instead of needing to encode all configuration into a string - passed to [`sql.Open`](/pkg/database/sql/#Open). - - Drivers that want to parse the configuration string only once per `sql.DB` - instead of once per [`sql.Conn`](/pkg/database/sql/#Conn), - or that want access to each `sql.Conn`'s underlying context, - can make their [`Driver`](/pkg/database/sql/driver/#Driver) - implementations also implement [`DriverContext`](/pkg/database/sql/driver/#DriverContext)'s - new `OpenConnector` method. - - Drivers that implement [`ExecerContext`](/pkg/database/sql/driver/#ExecerContext) - no longer need to implement [`Execer`](/pkg/database/sql/driver/#Execer); - similarly, drivers that implement [`QueryerContext`](/pkg/database/sql/driver/#QueryerContext) - no longer need to implement [`Queryer`](/pkg/database/sql/driver/#Queryer). - Previously, even if the context-based interfaces were implemented they were ignored - unless the non-context-based interfaces were also implemented. - - To allow drivers to better isolate different clients using a cached driver connection in succession, - if a [`Conn`](/pkg/database/sql/driver/#Conn) implements the new - [`SessionResetter`](/pkg/database/sql/driver/#SessionResetter) interface, - `database/sql` will now call `ResetSession` before - reusing the `Conn` for a new client. - -[debug/elf](/pkg/debug/elf/) - -: This release adds 348 new relocation constants divided between the relocation types - [`R_386`](/pkg/debug/elf/#R_386), - [`R_AARCH64`](/pkg/debug/elf/#R_AARCH64), - [`R_ARM`](/pkg/debug/elf/#R_ARM), - [`R_PPC64`](/pkg/debug/elf/#R_PPC64), - and - [`R_X86_64`](/pkg/debug/elf/#R_X86_64). - -[debug/macho](/pkg/debug/macho/) - -: Go 1.10 adds support for reading relocations from Mach-O sections, - using the [`Section`](/pkg/debug/macho#Section) struct's new `Relocs` field - and the new [`Reloc`](/pkg/debug/macho/#Reloc), - [`RelocTypeARM`](/pkg/debug/macho/#RelocTypeARM), - [`RelocTypeARM64`](/pkg/debug/macho/#RelocTypeARM64), - [`RelocTypeGeneric`](/pkg/debug/macho/#RelocTypeGeneric), - and - [`RelocTypeX86_64`](/pkg/debug/macho/#RelocTypeX86_64) - types and associated constants. - - Go 1.10 also adds support for the `LC_RPATH` load command, - represented by the types - [`RpathCmd`](/pkg/debug/macho/#RpathCmd) and - [`Rpath`](/pkg/debug/macho/#Rpath), - and new [named constants](/pkg/debug/macho/#pkg-constants) - for the various flag bits found in headers. - -[encoding/asn1](/pkg/encoding/asn1/) - -: [`Marshal`](/pkg/encoding/asn1/#Marshal) now correctly encodes - strings containing asterisks as type UTF8String instead of PrintableString, - unless the string is in a struct field with a tag forcing the use of PrintableString. - `Marshal` also now respects struct tags containing `application` directives. - - The new [`MarshalWithParams`](/pkg/encoding/asn1/#MarshalWithParams) - function marshals its argument as if the additional params were its associated - struct field tag. - - [`Unmarshal`](/pkg/encoding/asn1/#Unmarshal) now respects - struct field tags using the `explicit` and `tag` - directives. - - Both `Marshal` and `Unmarshal` now support a new struct field tag - `numeric`, indicating an ASN.1 NumericString. - -[encoding/csv](/pkg/encoding/csv/) - -: [`Reader`](/pkg/encoding/csv/#Reader) now disallows the use of - nonsensical `Comma` and `Comment` settings, - such as NUL, carriage return, newline, invalid runes, and the Unicode replacement character, - or setting `Comma` and `Comment` equal to each other. - - In the case of a syntax error in a CSV record that spans multiple input lines, `Reader` - now reports the line on which the record started in the [`ParseError`](/pkg/encoding/csv/#ParseError)'s new `StartLine` field. - -[encoding/hex](/pkg/encoding/hex/) - -: The new functions - [`NewEncoder`](/pkg/encoding/hex/#NewEncoder) - and - [`NewDecoder`](/pkg/encoding/hex/#NewDecoder) - provide streaming conversions to and from hexadecimal, - analogous to equivalent functions already in - [encoding/base32](/pkg/encoding/base32/) - and - [encoding/base64](/pkg/encoding/base64/). - - When the functions - [`Decode`](/pkg/encoding/hex/#Decode) - and - [`DecodeString`](/pkg/encoding/hex/#DecodeString) - encounter malformed input, - they now return the number of bytes already converted - along with the error. - Previously they always returned a count of 0 with any error. - -[encoding/json](/pkg/encoding/json/) - -: The [`Decoder`](/pkg/encoding/json/#Decoder) - adds a new method - [`DisallowUnknownFields`](/pkg/encoding/json/#Decoder.DisallowUnknownFields) - that causes it to report inputs with unknown JSON fields as a decoding error. - (The default behavior has always been to discard unknown fields.) - - As a result of [fixing a reflect bug](#reflect), - [`Unmarshal`](/pkg/encoding/json/#Unmarshal) - can no longer decode into fields inside - embedded pointers to unexported struct types, - because it cannot initialize the unexported embedded pointer - to point at fresh storage. - `Unmarshal` now returns an error in this case. - -[encoding/pem](/pkg/encoding/pem/) - -: [`Encode`](/pkg/encoding/pem/#Encode) - and - [`EncodeToMemory`](/pkg/encoding/pem/#EncodeToMemory) - no longer generate partial output when presented with a - block that is impossible to encode as PEM data. - -[encoding/xml](/pkg/encoding/xml/) - -: The new function - [`NewTokenDecoder`](/pkg/encoding/xml/#NewTokenDecoder) - is like - [`NewDecoder`](/pkg/encoding/xml/#NewDecoder) - but creates a decoder reading from a [`TokenReader`](/pkg/encoding/xml/#TokenReader) - instead of an XML-formatted byte stream. - This is meant to enable the construction of XML stream transformers in client libraries. - -[flag](/pkg/flag/) - -: The default - [`Usage`](/pkg/flag/#Usage) function now prints - its first line of output to - `CommandLine.Output()` - instead of assuming `os.Stderr`, - so that the usage message is properly redirected for - clients using `CommandLine.SetOutput`. - - [`PrintDefaults`](/pkg/flag/#PrintDefaults) now - adds appropriate indentation after newlines in flag usage strings, - so that multi-line usage strings display nicely. - - [`FlagSet`](/pkg/flag/#FlagSet) adds new methods - [`ErrorHandling`](/pkg/flag/#FlagSet.ErrorHandling), - [`Name`](/pkg/flag/#FlagSet.Name), - and - [`Output`](/pkg/flag/#FlagSet.Output), - to retrieve the settings passed to - [`NewFlagSet`](/pkg/flag/#NewFlagSet) - and - [`FlagSet.SetOutput`](/pkg/flag/#FlagSet.SetOutput). - -[go/doc](/pkg/go/doc/) - -: To support the [doc change](#doc) described above, - functions returning slices of `T`, `*T`, `**T`, and so on - are now reported in `T`'s [`Type`](/pkg/go/doc/#Type)'s `Funcs` list, - instead of in the [`Package`](/pkg/go/doc/#Package)'s `Funcs` list. - -[go/importer](/pkg/go/importer/) - -: The [`For`](/pkg/go/importer/#For) function now accepts a non-nil lookup argument. - -[go/printer](/pkg/go/printer/) - -: The changes to the default formatting of Go source code - discussed in the [gofmt section](#gofmt) above - are implemented in the [go/printer](/pkg/go/printer/) package - and also affect the output of the higher-level [go/format](/pkg/go/format/) package. - -[hash](/pkg/hash/) - -: Implementations of the [`Hash`](/pkg/hash/#Hash) interface are now - encouraged to implement [`encoding.BinaryMarshaler`](/pkg/encoding/#BinaryMarshaler) - and [`encoding.BinaryUnmarshaler`](/pkg/encoding/#BinaryUnmarshaler) - to allow saving and recreating their internal state, - and all implementations in the standard library - ([hash/crc32](/pkg/hash/crc32/), [crypto/sha256](/pkg/crypto/sha256/), and so on) - now implement those interfaces. - -[html/template](/pkg/html/template/) - -: The new [`Srcset`](/pkg/html/template#Srcset) content - type allows for proper handling of values within the - [`srcset`](https://w3c.github.io/html/semantics-embedded-content.html#element-attrdef-img-srcset) - attribute of `img` tags. - -[math/big](/pkg/math/big/) - -: [`Int`](/pkg/math/big/#Int) now supports conversions to and from bases 2 through 62 - in its [`SetString`](/pkg/math/big/#Int.SetString) and [`Text`](/pkg/math/big/#Text) methods. - (Previously it only allowed bases 2 through 36.) - The value of the constant `MaxBase` has been updated. - - [`Int`](/pkg/math/big/#Int) adds a new - [`CmpAbs`](/pkg/math/big/#CmpAbs) method - that is like [`Cmp`](/pkg/math/big/#Cmp) but - compares only the absolute values (not the signs) of its arguments. - - [`Float`](/pkg/math/big/#Float) adds a new - [`Sqrt`](/pkg/math/big/#Float.Sqrt) method to - compute square roots. - -[math/cmplx](/pkg/math/cmplx/) - -: Branch cuts and other boundary cases in - [`Asin`](/pkg/math/cmplx/#Asin), - [`Asinh`](/pkg/math/cmplx/#Asinh), - [`Atan`](/pkg/math/cmplx/#Atan), - and - [`Sqrt`](/pkg/math/cmplx/#Sqrt) - have been corrected to match the definitions used in the C99 standard. - -[math/rand](/pkg/math/rand/) - -: The new [`Shuffle`](/pkg/math/rand/#Shuffle) function and corresponding - [`Rand.Shuffle`](/pkg/math/rand/#Rand.Shuffle) method - shuffle an input sequence. - -[math](/pkg/math/) - -: The new functions - [`Round`](/pkg/math/#Round) - and - [`RoundToEven`](/pkg/math/#RoundToEven) - round their arguments to the nearest floating-point integer; - `Round` rounds a half-integer to its larger integer neighbor (away from zero) - while `RoundToEven` rounds a half-integer to its even integer neighbor. - - The new functions - [`Erfinv`](/pkg/math/#Erfinv) - and - [`Erfcinv`](/pkg/math/#Erfcinv) - compute the inverse error function and the - inverse complementary error function. - -[mime/multipart](/pkg/mime/multipart/) +#### [archive/tar](/pkg/archive/tar/) + +In general, the handling of special header formats is significantly improved and expanded. + +[`FileInfoHeader`](/pkg/archive/tar/#FileInfoHeader) has always +recorded the Unix UID and GID numbers from its [`os.FileInfo`](/pkg/os/#FileInfo) argument +(specifically, from the system-dependent information returned by the `FileInfo`'s `Sys` method) +in the returned [`Header`](/pkg/archive/tar/#Header). +Now it also records the user and group names corresponding to those IDs, +as well as the major and minor device numbers for device files. + +The new [`Header.Format`](/pkg/archive/tar/#Header) field +of type [`Format`](/pkg/archive/tar/#Format) +controls which tar header format the [`Writer`](/pkg/archive/tar/#Writer) uses. +The default, as before, is to select the most widely-supported header type +that can encode the fields needed by the header (USTAR if possible, or else PAX if possible, or else GNU). +The [`Reader`](/pkg/archive/tar/#Reader) sets `Header.Format` for each header it reads. + +`Reader` and the `Writer` now support arbitrary PAX records, +using the new [`Header.PAXRecords`](/pkg/archive/tar/#Header) field, +a generalization of the existing `Xattrs` field. + +The `Reader` no longer insists that the file name or link name in GNU headers +be valid UTF-8. + +When writing PAX- or GNU-format headers, the `Writer` now includes +the `Header.AccessTime` and `Header.ChangeTime` fields (if set). +When writing PAX-format headers, the times include sub-second precision. + +#### [archive/zip](/pkg/archive/zip/) + +Go 1.10 adds more complete support for times and character set encodings in ZIP archives. + +The original ZIP format used the standard MS-DOS encoding of year, month, day, hour, minute, and second into fields in two 16-bit values. +That encoding cannot represent time zones or odd seconds, so multiple extensions have been +introduced to allow richer encodings. +In Go 1.10, the [`Reader`](/pkg/archive/zip/#Reader) and [`Writer`](/pkg/archive/zip/#Writer) +now support the widely-understood Info-Zip extension that encodes the time separately in the 32-bit Unix “seconds since epoch” form. +The [`FileHeader`](/pkg/archive/zip/#FileHeader)'s new `Modified` field of type [`time.Time`](/pkg/time/#Time) +obsoletes the `ModifiedTime` and `ModifiedDate` fields, which continue to hold the MS-DOS encoding. +The `Reader` and `Writer` now adopt the common +convention that a ZIP archive storing a time zone-independent Unix time +also stores the local time in the MS-DOS field, +so that the time zone offset can be inferred. +For compatibility, the [`ModTime`](/pkg/archive/zip/#FileHeader.ModTime) and +[`SetModTime`](/pkg/archive/zip/#FileHeader.SetModTime) methods +behave the same as in earlier releases; new code should use `Modified` directly. + +The header for each file in a ZIP archive has a flag bit indicating whether +the name and comment fields are encoded as UTF-8, as opposed to a system-specific default encoding. +In Go 1.8 and earlier, the `Writer` never set the UTF-8 bit. +In Go 1.9, the `Writer` changed to set the UTF-8 bit almost always. +This broke the creation of ZIP archives containing Shift-JIS file names. +In Go 1.10, the `Writer` now sets the UTF-8 bit only when +both the name and the comment field are valid UTF-8 and at least one is non-ASCII. +Because non-ASCII encodings very rarely look like valid UTF-8, the new +heuristic should be correct nearly all the time. +Setting a `FileHeader`'s new `NonUTF8` field to true +disables the heuristic entirely for that file. + +The `Writer` also now supports setting the end-of-central-directory record's comment field, +by calling the `Writer`'s new [`SetComment`](/pkg/archive/zip/#Writer.SetComment) method. + +#### [bufio](/pkg/bufio/) + +The new [`Reader.Size`](/pkg/bufio/#Reader.Size) +and [`Writer.Size`](/pkg/bufio/#Writer.Size) +methods report the `Reader` or `Writer`'s underlying buffer size. + +#### [bytes](/pkg/bytes/) + +The +[`Fields`](/pkg/bytes/#Fields), +[`FieldsFunc`](/pkg/bytes/#FieldsFunc), +[`Split`](/pkg/bytes/#Split), +and +[`SplitAfter`](/pkg/bytes/#SplitAfter) +functions have always returned subslices of their inputs. +Go 1.10 changes each returned subslice to have capacity equal to its length, +so that appending to one cannot overwrite adjacent data in the original input. + +#### [crypto/cipher](/pkg/crypto/cipher/) + +[`NewOFB`](/pkg/crypto/cipher/#NewOFB) now panics if given +an initialization vector of incorrect length, like the other constructors in the +package always have. +(Previously it returned a nil `Stream` implementation.) + +#### [crypto/tls](/pkg/crypto/tls/) + +The TLS server now advertises support for SHA-512 signatures when using TLS 1.2. +The server already supported the signatures, but some clients would not select +them unless explicitly advertised. + +#### [crypto/x509](/pkg/crypto/x509/) + +[`Certificate.Verify`](/pkg/crypto/x509/#Certificate.Verify) +now enforces the name constraints for all +names contained in the certificate, not just the one name that a client has asked about. +Extended key usage restrictions are similarly now checked all at once. +As a result, after a certificate has been validated, now it can be trusted in its entirety. +It is no longer necessary to revalidate the certificate for each additional name +or key usage. + +Parsed certificates also now report URI names and IP, email, and URI constraints, using the new +[`Certificate`](/pkg/crypto/x509/#Certificate) fields +`URIs`, `PermittedIPRanges`, `ExcludedIPRanges`, +`PermittedEmailAddresses`, `ExcludedEmailAddresses`, +`PermittedURIDomains`, and `ExcludedURIDomains`. Certificates with +invalid values for those fields are now rejected. + +The new [`MarshalPKCS1PublicKey`](/pkg/crypto/x509/#MarshalPKCS1PublicKey) +and [`ParsePKCS1PublicKey`](/pkg/crypto/x509/#ParsePKCS1PublicKey) +functions convert an RSA public key to and from PKCS#1-encoded form. + +The new [`MarshalPKCS8PrivateKey`](/pkg/crypto/x509/#MarshalPKCS8PrivateKey) +function converts a private key to PKCS#8-encoded form. +([`ParsePKCS8PrivateKey`](/pkg/crypto/x509/#ParsePKCS8PrivateKey) +has existed since Go 1.) + +#### [crypto/x509/pkix](/pkg/crypto/x509/pkix/) + +[`Name`](/pkg/crypto/x509/pkix/#Name) now implements a +[`String`](/pkg/crypto/x509/pkix/#Name.String) method that +formats the X.509 distinguished name in the standard RFC 2253 format. + +#### [database/sql/driver](/pkg/database/sql/driver/) + +Drivers that currently hold on to the destination buffer provided by +[`driver.Rows.Next`](/pkg/database/sql/driver/#Rows.Next) should ensure they no longer +write to a buffer assigned to the destination array outside of that call. +Drivers must be careful that underlying buffers are not modified when closing +[`driver.Rows`](/pkg/database/sql/driver/#Rows). + +Drivers that want to construct a [`sql.DB`](/pkg/database/sql/#DB) for +their clients can now implement the [`Connector`](/pkg/database/sql/driver/#Connector) interface +and call the new [`sql.OpenDB`](/pkg/database/sql/#OpenDB) function, +instead of needing to encode all configuration into a string +passed to [`sql.Open`](/pkg/database/sql/#Open). + +Drivers that want to parse the configuration string only once per `sql.DB` +instead of once per [`sql.Conn`](/pkg/database/sql/#Conn), +or that want access to each `sql.Conn`'s underlying context, +can make their [`Driver`](/pkg/database/sql/driver/#Driver) +implementations also implement [`DriverContext`](/pkg/database/sql/driver/#DriverContext)'s +new `OpenConnector` method. + +Drivers that implement [`ExecerContext`](/pkg/database/sql/driver/#ExecerContext) +no longer need to implement [`Execer`](/pkg/database/sql/driver/#Execer); +similarly, drivers that implement [`QueryerContext`](/pkg/database/sql/driver/#QueryerContext) +no longer need to implement [`Queryer`](/pkg/database/sql/driver/#Queryer). +Previously, even if the context-based interfaces were implemented they were ignored +unless the non-context-based interfaces were also implemented. + +To allow drivers to better isolate different clients using a cached driver connection in succession, +if a [`Conn`](/pkg/database/sql/driver/#Conn) implements the new +[`SessionResetter`](/pkg/database/sql/driver/#SessionResetter) interface, +`database/sql` will now call `ResetSession` before +reusing the `Conn` for a new client. + +#### [debug/elf](/pkg/debug/elf/) + +This release adds 348 new relocation constants divided between the relocation types +[`R_386`](/pkg/debug/elf/#R_386), +[`R_AARCH64`](/pkg/debug/elf/#R_AARCH64), +[`R_ARM`](/pkg/debug/elf/#R_ARM), +[`R_PPC64`](/pkg/debug/elf/#R_PPC64), +and +[`R_X86_64`](/pkg/debug/elf/#R_X86_64). + +#### [debug/macho](/pkg/debug/macho/) + +Go 1.10 adds support for reading relocations from Mach-O sections, +using the [`Section`](/pkg/debug/macho#Section) struct's new `Relocs` field +and the new [`Reloc`](/pkg/debug/macho/#Reloc), +[`RelocTypeARM`](/pkg/debug/macho/#RelocTypeARM), +[`RelocTypeARM64`](/pkg/debug/macho/#RelocTypeARM64), +[`RelocTypeGeneric`](/pkg/debug/macho/#RelocTypeGeneric), +and +[`RelocTypeX86_64`](/pkg/debug/macho/#RelocTypeX86_64) +types and associated constants. + +Go 1.10 also adds support for the `LC_RPATH` load command, +represented by the types +[`RpathCmd`](/pkg/debug/macho/#RpathCmd) and +[`Rpath`](/pkg/debug/macho/#Rpath), +and new [named constants](/pkg/debug/macho/#pkg-constants) +for the various flag bits found in headers. + +#### [encoding/asn1](/pkg/encoding/asn1/) + +[`Marshal`](/pkg/encoding/asn1/#Marshal) now correctly encodes +strings containing asterisks as type UTF8String instead of PrintableString, +unless the string is in a struct field with a tag forcing the use of PrintableString. +`Marshal` also now respects struct tags containing `application` directives. + +The new [`MarshalWithParams`](/pkg/encoding/asn1/#MarshalWithParams) +function marshals its argument as if the additional params were its associated +struct field tag. + +[`Unmarshal`](/pkg/encoding/asn1/#Unmarshal) now respects +struct field tags using the `explicit` and `tag` +directives. + +Both `Marshal` and `Unmarshal` now support a new struct field tag +`numeric`, indicating an ASN.1 NumericString. + +#### [encoding/csv](/pkg/encoding/csv/) + +[`Reader`](/pkg/encoding/csv/#Reader) now disallows the use of +nonsensical `Comma` and `Comment` settings, +such as NUL, carriage return, newline, invalid runes, and the Unicode replacement character, +or setting `Comma` and `Comment` equal to each other. + +In the case of a syntax error in a CSV record that spans multiple input lines, `Reader` +now reports the line on which the record started in the [`ParseError`](/pkg/encoding/csv/#ParseError)'s new `StartLine` field. + +#### [encoding/hex](/pkg/encoding/hex/) + +The new functions +[`NewEncoder`](/pkg/encoding/hex/#NewEncoder) +and +[`NewDecoder`](/pkg/encoding/hex/#NewDecoder) +provide streaming conversions to and from hexadecimal, +analogous to equivalent functions already in +[encoding/base32](/pkg/encoding/base32/) +and +[encoding/base64](/pkg/encoding/base64/). + +When the functions +[`Decode`](/pkg/encoding/hex/#Decode) +and +[`DecodeString`](/pkg/encoding/hex/#DecodeString) +encounter malformed input, +they now return the number of bytes already converted +along with the error. +Previously they always returned a count of 0 with any error. + +#### [encoding/json](/pkg/encoding/json/) + +The [`Decoder`](/pkg/encoding/json/#Decoder) +adds a new method +[`DisallowUnknownFields`](/pkg/encoding/json/#Decoder.DisallowUnknownFields) +that causes it to report inputs with unknown JSON fields as a decoding error. +(The default behavior has always been to discard unknown fields.) + +As a result of [fixing a reflect bug](#reflect), +[`Unmarshal`](/pkg/encoding/json/#Unmarshal) +can no longer decode into fields inside +embedded pointers to unexported struct types, +because it cannot initialize the unexported embedded pointer +to point at fresh storage. +`Unmarshal` now returns an error in this case. + +#### [encoding/pem](/pkg/encoding/pem/) + +[`Encode`](/pkg/encoding/pem/#Encode) +and +[`EncodeToMemory`](/pkg/encoding/pem/#EncodeToMemory) +no longer generate partial output when presented with a +block that is impossible to encode as PEM data. + +#### [encoding/xml](/pkg/encoding/xml/) + +The new function +[`NewTokenDecoder`](/pkg/encoding/xml/#NewTokenDecoder) +is like +[`NewDecoder`](/pkg/encoding/xml/#NewDecoder) +but creates a decoder reading from a [`TokenReader`](/pkg/encoding/xml/#TokenReader) +instead of an XML-formatted byte stream. +This is meant to enable the construction of XML stream transformers in client libraries. + +#### [flag](/pkg/flag/) + +The default +[`Usage`](/pkg/flag/#Usage) function now prints +its first line of output to +`CommandLine.Output()` +instead of assuming `os.Stderr`, +so that the usage message is properly redirected for +clients using `CommandLine.SetOutput`. + +[`PrintDefaults`](/pkg/flag/#PrintDefaults) now +adds appropriate indentation after newlines in flag usage strings, +so that multi-line usage strings display nicely. + +[`FlagSet`](/pkg/flag/#FlagSet) adds new methods +[`ErrorHandling`](/pkg/flag/#FlagSet.ErrorHandling), +[`Name`](/pkg/flag/#FlagSet.Name), +and +[`Output`](/pkg/flag/#FlagSet.Output), +to retrieve the settings passed to +[`NewFlagSet`](/pkg/flag/#NewFlagSet) +and +[`FlagSet.SetOutput`](/pkg/flag/#FlagSet.SetOutput). + +#### [go/doc](/pkg/go/doc/) + +To support the [doc change](#doc) described above, +functions returning slices of `T`, `*T`, `**T`, and so on +are now reported in `T`'s [`Type`](/pkg/go/doc/#Type)'s `Funcs` list, +instead of in the [`Package`](/pkg/go/doc/#Package)'s `Funcs` list. + +#### [go/importer](/pkg/go/importer/) + +The [`For`](/pkg/go/importer/#For) function now accepts a non-nil lookup argument. + +#### [go/printer](/pkg/go/printer/) + +The changes to the default formatting of Go source code +discussed in the [gofmt section](#gofmt) above +are implemented in the [go/printer](/pkg/go/printer/) package +and also affect the output of the higher-level [go/format](/pkg/go/format/) package. + +#### [hash](/pkg/hash/) + +Implementations of the [`Hash`](/pkg/hash/#Hash) interface are now +encouraged to implement [`encoding.BinaryMarshaler`](/pkg/encoding/#BinaryMarshaler) +and [`encoding.BinaryUnmarshaler`](/pkg/encoding/#BinaryUnmarshaler) +to allow saving and recreating their internal state, +and all implementations in the standard library +([hash/crc32](/pkg/hash/crc32/), [crypto/sha256](/pkg/crypto/sha256/), and so on) +now implement those interfaces. + +#### [html/template](/pkg/html/template/) + +The new [`Srcset`](/pkg/html/template#Srcset) content +type allows for proper handling of values within the +[`srcset`](https://w3c.github.io/html/semantics-embedded-content.html#element-attrdef-img-srcset) +attribute of `img` tags. + +#### [math/big](/pkg/math/big/) + +[`Int`](/pkg/math/big/#Int) now supports conversions to and from bases 2 through 62 +in its [`SetString`](/pkg/math/big/#Int.SetString) and [`Text`](/pkg/math/big/#Text) methods. +(Previously it only allowed bases 2 through 36.) +The value of the constant `MaxBase` has been updated. + +[`Int`](/pkg/math/big/#Int) adds a new +[`CmpAbs`](/pkg/math/big/#CmpAbs) method +that is like [`Cmp`](/pkg/math/big/#Cmp) but +compares only the absolute values (not the signs) of its arguments. + +[`Float`](/pkg/math/big/#Float) adds a new +[`Sqrt`](/pkg/math/big/#Float.Sqrt) method to +compute square roots. + +#### [math/cmplx](/pkg/math/cmplx/) + +Branch cuts and other boundary cases in +[`Asin`](/pkg/math/cmplx/#Asin), +[`Asinh`](/pkg/math/cmplx/#Asinh), +[`Atan`](/pkg/math/cmplx/#Atan), +and +[`Sqrt`](/pkg/math/cmplx/#Sqrt) +have been corrected to match the definitions used in the C99 standard. + +#### [math/rand](/pkg/math/rand/) + +The new [`Shuffle`](/pkg/math/rand/#Shuffle) function and corresponding +[`Rand.Shuffle`](/pkg/math/rand/#Rand.Shuffle) method +shuffle an input sequence. + +#### [math](/pkg/math/) + +The new functions +[`Round`](/pkg/math/#Round) +and +[`RoundToEven`](/pkg/math/#RoundToEven) +round their arguments to the nearest floating-point integer; +`Round` rounds a half-integer to its larger integer neighbor (away from zero) +while `RoundToEven` rounds a half-integer to its even integer neighbor. + +The new functions +[`Erfinv`](/pkg/math/#Erfinv) +and +[`Erfcinv`](/pkg/math/#Erfcinv) +compute the inverse error function and the +inverse complementary error function. + +#### [mime/multipart](/pkg/mime/multipart/) -: [`Reader`](/pkg/mime/multipart/#Reader) - now accepts parts with empty filename attributes. - -[mime](/pkg/mime/) - -: [`ParseMediaType`](/pkg/mime/#ParseMediaType) now discards - invalid attribute values; previously it returned those values as empty strings. - -[net](/pkg/net/) - -: The [`Conn`](/pkg/net/#Conn) and - [`Listener`](/pkg/net/#Conn) implementations - in this package now guarantee that when `Close` returns, - the underlying file descriptor has been closed. - (In earlier releases, if the `Close` stopped pending I/O - in other goroutines, the closing of the file descriptor could happen in one of those - goroutines shortly after `Close` returned.) - - [`TCPListener`](/pkg/net/#TCPListener) and - [`UnixListener`](/pkg/net/#UnixListener) - now implement - [`syscall.Conn`](/pkg/syscall/#Conn), - to allow setting options on the underlying file descriptor - using [`syscall.RawConn.Control`](/pkg/syscall/#RawConn). - - The `Conn` implementations returned by [`Pipe`](/pkg/net/#Pipe) - now support setting read and write deadlines. - - The [`IPConn.ReadMsgIP`](/pkg/net/#IPConn.ReadMsgIP), - [`IPConn.WriteMsgIP`](/pkg/net/#IPConn.WriteMsgIP), - [`UDPConn.ReadMsgUDP`](/pkg/net/#UDPConn.ReadMsgUDP), - and - [`UDPConn.WriteMsgUDP`](/pkg/net/#UDPConn.WriteMsgUDP), - methods are now implemented on Windows. - -[net/http](/pkg/net/http/) - -: On the client side, an HTTP proxy (most commonly configured by - [`ProxyFromEnvironment`](/pkg/net/http/#ProxyFromEnvironment)) - can now be specified as an `https://` URL, - meaning that the client connects to the proxy over HTTPS before issuing a standard, proxied HTTP request. - (Previously, HTTP proxy URLs were required to begin with `http://` or `socks5://`.) - - On the server side, [`FileServer`](/pkg/net/http/#FileServer) and its single-file equivalent [`ServeFile`](/pkg/net/http/#ServeFile) - now apply `If-Range` checks to `HEAD` requests. - `FileServer` also now reports directory read failures to the [`Server`](/pkg/net/http/#Server)'s `ErrorLog`. - The content-serving handlers also now omit the `Content-Type` header when serving zero-length content. - - [`ResponseWriter`](/pkg/net/http/#ResponseWriter)'s `WriteHeader` method now panics - if passed an invalid (non-3-digit) status code. - - - The `Server` will no longer add an implicit Content-Type when a `Handler` does not write any output. - - [`Redirect`](/pkg/net/http/#Redirect) now sets the `Content-Type` header before writing its HTTP response. - -[net/mail](/pkg/net/mail/) - -: [`ParseAddress`](/pkg/net/mail/#ParseAddress) and - [`ParseAddressList`](/pkg/net/mail/#ParseAddressList) - now support a variety of obsolete address formats. - -[net/smtp](/pkg/net/smtp/) - -: The [`Client`](/pkg/net/smtp/#Client) adds a new - [`Noop`](/pkg/net/smtp/#Client.Noop) method, - to test whether the server is still responding. - It also now defends against possible SMTP injection in the inputs - to the [`Hello`](/pkg/net/smtp/#Client.Hello) - and [`Verify`](/pkg/net/smtp/#Client.Verify) methods. - -[net/textproto](/pkg/net/textproto/) - -: [`ReadMIMEHeader`](/pkg/net/textproto/#ReadMIMEHeader) - now rejects any header that begins with a continuation (indented) header line. - Previously a header with an indented first line was treated as if the first line - were not indented. - -[net/url](/pkg/net/url/) - -: [`ResolveReference`](/pkg/net/url/#ResolveReference) - now preserves multiple leading slashes in the target URL. - Previously it rewrote multiple leading slashes to a single slash, - which resulted in the [`http.Client`](/pkg/net/http/#Client) - following certain redirects incorrectly. - - For example, this code's output has changed: - - base, _ := url.Parse("http://host//path//to/page1") - target, _ := url.Parse("page2") - fmt.Println(base.ResolveReference(target)) - - Note the doubled slashes around `path`. - In Go 1.9 and earlier, the resolved URL was `http://host/path//to/page2`: - the doubled slash before `path` was incorrectly rewritten - to a single slash, while the doubled slash after `path` was - correctly preserved. - Go 1.10 preserves both doubled slashes, resolving to `http://host//path//to/page2` - as required by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-5.2). - - This change may break existing buggy programs that unintentionally - construct a base URL with a leading doubled slash in the path and inadvertently - depend on `ResolveReference` to correct that mistake. - For example, this can happen if code adds a host prefix - like `http://host/` to a path like `/my/api`, - resulting in a URL with a doubled slash: `http://host//my/api`. - - [`UserInfo`](/pkg/net/url/#UserInfo)'s methods - now treat a nil receiver as equivalent to a pointer to a zero `UserInfo`. - Previously, they panicked. - -[os](/pkg/os/) - -: [`File`](/pkg/os/#File) adds new methods - [`SetDeadline`](/pkg/os/#File.SetDeadline), - [`SetReadDeadline`](/pkg/os/#File.SetReadDeadline), - and - [`SetWriteDeadline`](/pkg/os/#File.SetWriteDeadline) - that allow setting I/O deadlines when the - underlying file descriptor supports non-blocking I/O operations. - The definition of these methods matches those in [`net.Conn`](/pkg/net/#Conn). - If an I/O method fails due to missing a deadline, it will return a - timeout error; the - new [`IsTimeout`](/pkg/os/#IsTimeout) function - reports whether an error represents a timeout. - - Also matching `net.Conn`, - `File`'s - [`Close`](/pkg/os/#File.Close) method - now guarantee that when `Close` returns, - the underlying file descriptor has been closed. - (In earlier releases, - if the `Close` stopped pending I/O - in other goroutines, the closing of the file descriptor could happen in one of those - goroutines shortly after `Close` returned.) - - On BSD, macOS, and Solaris systems, - [`Chtimes`](/pkg/os/#Chtimes) - now supports setting file times with nanosecond precision - (assuming the underlying file system can represent them). - -[reflect](/pkg/reflect/) - -: The [`Copy`](/pkg/reflect/#Copy) function now allows copying - from a string into a byte array or byte slice, to match the - [built-in copy function](/pkg/builtin/#copy). - - In structs, embedded pointers to unexported struct types were - previously incorrectly reported with an empty `PkgPath` - in the corresponding [StructField](/pkg/reflect/#StructField), - with the result that for those fields, - and [`Value.CanSet`](/pkg/reflect/#Value.CanSet) - incorrectly returned true and - [`Value.Set`](/pkg/reflect/#Value.Set) - incorrectly succeeded. - The underlying metadata has been corrected; - for those fields, - `CanSet` now correctly returns false - and `Set` now correctly panics. - This may affect reflection-based unmarshalers - that could previously unmarshal into such fields - but no longer can. - For example, see the [`encoding/json` notes](#encoding/json). - -[runtime/pprof](/pkg/runtime/pprof/) - -: As [noted above](#pprof), the blocking and mutex profiles - now include symbol information so that they can be viewed without needing - the binary that generated them. - -[strconv](/pkg/strconv/) - -: [`ParseUint`](/pkg/strconv/#ParseUint) now returns - the maximum magnitude integer of the appropriate size - with any `ErrRange` error, as it was already documented to do. - Previously it returned 0 with `ErrRange` errors. - -[strings](/pkg/strings/) - -: A new type - [`Builder`](/pkg/strings/#Builder) is a replacement for - [`bytes.Buffer`](/pkg/bytes/#Buffer) for the use case of - accumulating text into a `string` result. - The `Builder`'s API is a restricted subset of `bytes.Buffer`'s - that allows it to safely avoid making a duplicate copy of the data - during the [`String`](/pkg/strings/#Builder.String) method. - -[syscall](/pkg/syscall/) - -: On Windows, - the new [`SysProcAttr`](/pkg/syscall/#SysProcAttr) field `Token`, - of type [`Token`](/pkg/syscall/#Token) allows the creation of a process that - runs as another user during [`StartProcess`](/pkg/syscall/#StartProcess) - (and therefore also during [`os.StartProcess`](/pkg/os/#StartProcess) and - [`exec.Cmd.Start`](/pkg/os/exec/#Cmd.Start)). - The new function [`CreateProcessAsUser`](/pkg/syscall/#CreateProcessAsUser) - gives access to the underlying system call. - - On BSD, macOS, and Solaris systems, [`UtimesNano`](/pkg/syscall/#UtimesNano) - is now implemented. - -[time](/pkg/time/) - -: [`LoadLocation`](/pkg/time/#LoadLocation) now uses the directory - or uncompressed zip file named by the `$ZONEINFO` - environment variable before looking in the default system-specific list of - known installation locations or in `$GOROOT/lib/time/zoneinfo.zip`. - - The new function [`LoadLocationFromTZData`](/pkg/time/#LoadLocationFromTZData) - allows conversion of IANA time zone file data to a [`Location`](/pkg/time/#Location). - -[unicode](/pkg/unicode/) - -: The [`unicode`](/pkg/unicode/) package and associated - support throughout the system has been upgraded from Unicode 9.0 to - [Unicode 10.0](https://www.unicode.org/versions/Unicode10.0.0/), - which adds 8,518 new characters, including four new scripts, one new property, - a Bitcoin currency symbol, and 56 new emoji. +[`Reader`](/pkg/mime/multipart/#Reader) +now accepts parts with empty filename attributes. + +#### [mime](/pkg/mime/) + +[`ParseMediaType`](/pkg/mime/#ParseMediaType) now discards +invalid attribute values; previously it returned those values as empty strings. + +#### [net](/pkg/net/) + +The [`Conn`](/pkg/net/#Conn) and +[`Listener`](/pkg/net/#Conn) implementations +in this package now guarantee that when `Close` returns, +the underlying file descriptor has been closed. +(In earlier releases, if the `Close` stopped pending I/O +in other goroutines, the closing of the file descriptor could happen in one of those +goroutines shortly after `Close` returned.) + +[`TCPListener`](/pkg/net/#TCPListener) and +[`UnixListener`](/pkg/net/#UnixListener) +now implement +[`syscall.Conn`](/pkg/syscall/#Conn), +to allow setting options on the underlying file descriptor +using [`syscall.RawConn.Control`](/pkg/syscall/#RawConn). + +The `Conn` implementations returned by [`Pipe`](/pkg/net/#Pipe) +now support setting read and write deadlines. + +The [`IPConn.ReadMsgIP`](/pkg/net/#IPConn.ReadMsgIP), +[`IPConn.WriteMsgIP`](/pkg/net/#IPConn.WriteMsgIP), +[`UDPConn.ReadMsgUDP`](/pkg/net/#UDPConn.ReadMsgUDP), +and +[`UDPConn.WriteMsgUDP`](/pkg/net/#UDPConn.WriteMsgUDP), +methods are now implemented on Windows. + +#### [net/http](/pkg/net/http/) + +On the client side, an HTTP proxy (most commonly configured by +[`ProxyFromEnvironment`](/pkg/net/http/#ProxyFromEnvironment)) +can now be specified as an `https://` URL, +meaning that the client connects to the proxy over HTTPS before issuing a standard, proxied HTTP request. +(Previously, HTTP proxy URLs were required to begin with `http://` or `socks5://`.) + +On the server side, [`FileServer`](/pkg/net/http/#FileServer) and its single-file equivalent [`ServeFile`](/pkg/net/http/#ServeFile) +now apply `If-Range` checks to `HEAD` requests. +`FileServer` also now reports directory read failures to the [`Server`](/pkg/net/http/#Server)'s `ErrorLog`. +The content-serving handlers also now omit the `Content-Type` header when serving zero-length content. + +[`ResponseWriter`](/pkg/net/http/#ResponseWriter)'s `WriteHeader` method now panics +if passed an invalid (non-3-digit) status code. + + +The `Server` will no longer add an implicit Content-Type when a `Handler` does not write any output. + +[`Redirect`](/pkg/net/http/#Redirect) now sets the `Content-Type` header before writing its HTTP response. + +#### [net/mail](/pkg/net/mail/) + +[`ParseAddress`](/pkg/net/mail/#ParseAddress) and +[`ParseAddressList`](/pkg/net/mail/#ParseAddressList) +now support a variety of obsolete address formats. + +#### [net/smtp](/pkg/net/smtp/) + +The [`Client`](/pkg/net/smtp/#Client) adds a new +[`Noop`](/pkg/net/smtp/#Client.Noop) method, +to test whether the server is still responding. +It also now defends against possible SMTP injection in the inputs +to the [`Hello`](/pkg/net/smtp/#Client.Hello) +and [`Verify`](/pkg/net/smtp/#Client.Verify) methods. + +#### [net/textproto](/pkg/net/textproto/) + +[`ReadMIMEHeader`](/pkg/net/textproto/#ReadMIMEHeader) +now rejects any header that begins with a continuation (indented) header line. +Previously a header with an indented first line was treated as if the first line +were not indented. + +#### [net/url](/pkg/net/url/) + +[`ResolveReference`](/pkg/net/url/#ResolveReference) +now preserves multiple leading slashes in the target URL. +Previously it rewrote multiple leading slashes to a single slash, +which resulted in the [`http.Client`](/pkg/net/http/#Client) +following certain redirects incorrectly. + +For example, this code's output has changed: + + base, _ := url.Parse("http://host//path//to/page1") + target, _ := url.Parse("page2") + fmt.Println(base.ResolveReference(target)) + +Note the doubled slashes around `path`. +In Go 1.9 and earlier, the resolved URL was `http://host/path//to/page2`: +the doubled slash before `path` was incorrectly rewritten +to a single slash, while the doubled slash after `path` was +correctly preserved. +Go 1.10 preserves both doubled slashes, resolving to `http://host//path//to/page2` +as required by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-5.2). + +This change may break existing buggy programs that unintentionally +construct a base URL with a leading doubled slash in the path and inadvertently +depend on `ResolveReference` to correct that mistake. +For example, this can happen if code adds a host prefix +like `http://host/` to a path like `/my/api`, +resulting in a URL with a doubled slash: `http://host//my/api`. + +[`UserInfo`](/pkg/net/url/#UserInfo)'s methods +now treat a nil receiver as equivalent to a pointer to a zero `UserInfo`. +Previously, they panicked. + +#### [os](/pkg/os/) + +[`File`](/pkg/os/#File) adds new methods +[`SetDeadline`](/pkg/os/#File.SetDeadline), +[`SetReadDeadline`](/pkg/os/#File.SetReadDeadline), +and +[`SetWriteDeadline`](/pkg/os/#File.SetWriteDeadline) +that allow setting I/O deadlines when the +underlying file descriptor supports non-blocking I/O operations. +The definition of these methods matches those in [`net.Conn`](/pkg/net/#Conn). +If an I/O method fails due to missing a deadline, it will return a +timeout error; the +new [`IsTimeout`](/pkg/os/#IsTimeout) function +reports whether an error represents a timeout. + +Also matching `net.Conn`, +`File`'s +[`Close`](/pkg/os/#File.Close) method +now guarantee that when `Close` returns, +the underlying file descriptor has been closed. +(In earlier releases, +if the `Close` stopped pending I/O +in other goroutines, the closing of the file descriptor could happen in one of those +goroutines shortly after `Close` returned.) + +On BSD, macOS, and Solaris systems, +[`Chtimes`](/pkg/os/#Chtimes) +now supports setting file times with nanosecond precision +(assuming the underlying file system can represent them). + +#### [reflect](/pkg/reflect/) + +The [`Copy`](/pkg/reflect/#Copy) function now allows copying +from a string into a byte array or byte slice, to match the +[built-in copy function](/pkg/builtin/#copy). + +In structs, embedded pointers to unexported struct types were +previously incorrectly reported with an empty `PkgPath` +in the corresponding [StructField](/pkg/reflect/#StructField), +with the result that for those fields, +and [`Value.CanSet`](/pkg/reflect/#Value.CanSet) +incorrectly returned true and +[`Value.Set`](/pkg/reflect/#Value.Set) +incorrectly succeeded. +The underlying metadata has been corrected; +for those fields, +`CanSet` now correctly returns false +and `Set` now correctly panics. +This may affect reflection-based unmarshalers +that could previously unmarshal into such fields +but no longer can. +For example, see the [`encoding/json` notes](#encoding/json). + +#### [runtime/pprof](/pkg/runtime/pprof/) + +As [noted above](#pprof), the blocking and mutex profiles +now include symbol information so that they can be viewed without needing +the binary that generated them. + +#### [strconv](/pkg/strconv/) + +[`ParseUint`](/pkg/strconv/#ParseUint) now returns +the maximum magnitude integer of the appropriate size +with any `ErrRange` error, as it was already documented to do. +Previously it returned 0 with `ErrRange` errors. + +#### [strings](/pkg/strings/) + +A new type +[`Builder`](/pkg/strings/#Builder) is a replacement for +[`bytes.Buffer`](/pkg/bytes/#Buffer) for the use case of +accumulating text into a `string` result. +The `Builder`'s API is a restricted subset of `bytes.Buffer`'s +that allows it to safely avoid making a duplicate copy of the data +during the [`String`](/pkg/strings/#Builder.String) method. + +#### [syscall](/pkg/syscall/) + +On Windows, +the new [`SysProcAttr`](/pkg/syscall/#SysProcAttr) field `Token`, +of type [`Token`](/pkg/syscall/#Token) allows the creation of a process that +runs as another user during [`StartProcess`](/pkg/syscall/#StartProcess) +(and therefore also during [`os.StartProcess`](/pkg/os/#StartProcess) and +[`exec.Cmd.Start`](/pkg/os/exec/#Cmd.Start)). +The new function [`CreateProcessAsUser`](/pkg/syscall/#CreateProcessAsUser) +gives access to the underlying system call. + +On BSD, macOS, and Solaris systems, [`UtimesNano`](/pkg/syscall/#UtimesNano) +is now implemented. + +#### [time](/pkg/time/) + +[`LoadLocation`](/pkg/time/#LoadLocation) now uses the directory +or uncompressed zip file named by the `$ZONEINFO` +environment variable before looking in the default system-specific list of +known installation locations or in `$GOROOT/lib/time/zoneinfo.zip`. + +The new function [`LoadLocationFromTZData`](/pkg/time/#LoadLocationFromTZData) +allows conversion of IANA time zone file data to a [`Location`](/pkg/time/#Location). + +#### [unicode](/pkg/unicode/) + +The [`unicode`](/pkg/unicode/) package and associated +support throughout the system has been upgraded from Unicode 9.0 to +[Unicode 10.0](https://www.unicode.org/versions/Unicode10.0.0/), +which adds 8,518 new characters, including four new scripts, one new property, +a Bitcoin currency symbol, and 56 new emoji. diff --git a/_content/doc/go1.11.md b/_content/doc/go1.11.md index bddfa657..0995413b 100644 --- a/_content/doc/go1.11.md +++ b/_content/doc/go1.11.md @@ -408,402 +408,402 @@ in mind. -[crypto](/pkg/crypto/) +#### [crypto](/pkg/crypto/) -: - Certain crypto operations, including - [`ecdsa.Sign`](/pkg/crypto/ecdsa/#Sign), - [`rsa.EncryptPKCS1v15`](/pkg/crypto/rsa/#EncryptPKCS1v15) and - [`rsa.GenerateKey`](/pkg/crypto/rsa/#GenerateKey), - now randomly read an extra byte of randomness to ensure tests don't rely on internal behavior. + +Certain crypto operations, including +[`ecdsa.Sign`](/pkg/crypto/ecdsa/#Sign), +[`rsa.EncryptPKCS1v15`](/pkg/crypto/rsa/#EncryptPKCS1v15) and +[`rsa.GenerateKey`](/pkg/crypto/rsa/#GenerateKey), +now randomly read an extra byte of randomness to ensure tests don't rely on internal behavior. -[crypto/cipher](/pkg/crypto/cipher/) +#### [crypto/cipher](/pkg/crypto/cipher/) -: - The new function [`NewGCMWithTagSize`](/pkg/crypto/cipher/#NewGCMWithTagSize) - implements Galois Counter Mode with non-standard tag lengths for compatibility with existing cryptosystems. + +The new function [`NewGCMWithTagSize`](/pkg/crypto/cipher/#NewGCMWithTagSize) +implements Galois Counter Mode with non-standard tag lengths for compatibility with existing cryptosystems. -[crypto/rsa](/pkg/crypto/rsa/) +#### [crypto/rsa](/pkg/crypto/rsa/) -: - [`PublicKey`](/pkg/crypto/rsa/#PublicKey) now implements a - [`Size`](/pkg/crypto/rsa/#PublicKey.Size) method that - returns the modulus size in bytes. + +[`PublicKey`](/pkg/crypto/rsa/#PublicKey) now implements a +[`Size`](/pkg/crypto/rsa/#PublicKey.Size) method that +returns the modulus size in bytes. -[crypto/tls](/pkg/crypto/tls/) +#### [crypto/tls](/pkg/crypto/tls/) -: - [`ConnectionState`](/pkg/crypto/tls/#ConnectionState)'s new - [`ExportKeyingMaterial`](/pkg/crypto/tls/#ConnectionState.ExportKeyingMaterial) - method allows exporting keying material bound to the - connection according to RFC 5705. + +[`ConnectionState`](/pkg/crypto/tls/#ConnectionState)'s new +[`ExportKeyingMaterial`](/pkg/crypto/tls/#ConnectionState.ExportKeyingMaterial) +method allows exporting keying material bound to the +connection according to RFC 5705. -[crypto/x509](/pkg/crypto/x509/) +#### [crypto/x509](/pkg/crypto/x509/) -: - The deprecated, legacy behavior of treating the `CommonName` field as - a hostname when no Subject Alternative Names are present is now disabled when the CN is not a - valid hostname. - The `CommonName` can be completely ignored by adding the experimental value - `x509ignoreCN=1` to the `GODEBUG` environment variable. - When the CN is ignored, certificates without SANs validate under chains with name constraints - instead of returning `NameConstraintsWithoutSANs`. + +The deprecated, legacy behavior of treating the `CommonName` field as +a hostname when no Subject Alternative Names are present is now disabled when the CN is not a +valid hostname. +The `CommonName` can be completely ignored by adding the experimental value +`x509ignoreCN=1` to the `GODEBUG` environment variable. +When the CN is ignored, certificates without SANs validate under chains with name constraints +instead of returning `NameConstraintsWithoutSANs`. - - Extended key usage restrictions are again checked only if they appear in the `KeyUsages` - field of [`VerifyOptions`](/pkg/crypto/x509/#VerifyOptions), instead of always being checked. - This matches the behavior of Go 1.9 and earlier. + +Extended key usage restrictions are again checked only if they appear in the `KeyUsages` +field of [`VerifyOptions`](/pkg/crypto/x509/#VerifyOptions), instead of always being checked. +This matches the behavior of Go 1.9 and earlier. - - The value returned by [`SystemCertPool`](/pkg/crypto/x509/#SystemCertPool) - is now cached and might not reflect system changes between invocations. + +The value returned by [`SystemCertPool`](/pkg/crypto/x509/#SystemCertPool) +is now cached and might not reflect system changes between invocations. -[debug/elf](/pkg/debug/elf/) +#### [debug/elf](/pkg/debug/elf/) -: - More [`ELFOSABI`](/pkg/debug/elf/#ELFOSABI_NONE) - and [`EM`](/pkg/debug/elf/#EM_NONE) - constants have been added. + +More [`ELFOSABI`](/pkg/debug/elf/#ELFOSABI_NONE) +and [`EM`](/pkg/debug/elf/#EM_NONE) +constants have been added. -[encoding/asn1](/pkg/encoding/asn1/) +#### [encoding/asn1](/pkg/encoding/asn1/) -: - `Marshal` and [`Unmarshal`](/pkg/encoding/asn1/#Unmarshal) - now support "private" class annotations for fields. + +`Marshal` and [`Unmarshal`](/pkg/encoding/asn1/#Unmarshal) +now support "private" class annotations for fields. -[encoding/base32](/pkg/encoding/base32/) +#### [encoding/base32](/pkg/encoding/base32/) -: - The decoder now consistently - returns `io.ErrUnexpectedEOF` for an incomplete - chunk. Previously it would return `io.EOF` in some - cases. + +The decoder now consistently +returns `io.ErrUnexpectedEOF` for an incomplete +chunk. Previously it would return `io.EOF` in some +cases. -[encoding/csv](/pkg/encoding/csv/) +#### [encoding/csv](/pkg/encoding/csv/) -: - The `Reader` now rejects attempts to set - the [`Comma`](/pkg/encoding/csv/#Reader.Comma) - field to a double-quote character, as double-quote characters - already have a special meaning in CSV. + +The `Reader` now rejects attempts to set +the [`Comma`](/pkg/encoding/csv/#Reader.Comma) +field to a double-quote character, as double-quote characters +already have a special meaning in CSV. -[html/template](/pkg/html/template/) +#### [html/template](/pkg/html/template/) -: - The package has changed its behavior when a typed interface - value is passed to an implicit escaper function. Previously such - a value was written out as (an escaped form) - of ``. Now such values are ignored, just - as an untyped `nil` value is (and always has been) - ignored. + +The package has changed its behavior when a typed interface +value is passed to an implicit escaper function. Previously such +a value was written out as (an escaped form) +of ``. Now such values are ignored, just +as an untyped `nil` value is (and always has been) +ignored. -[image/gif](/pkg/image/gif/) +#### [image/gif](/pkg/image/gif/) -: - Non-looping animated GIFs are now supported. They are denoted by having a - [`LoopCount`](/pkg/image/gif/#GIF.LoopCount) of -1. + +Non-looping animated GIFs are now supported. They are denoted by having a +[`LoopCount`](/pkg/image/gif/#GIF.LoopCount) of -1. -[io/ioutil](/pkg/io/ioutil/) +#### [io/ioutil](/pkg/io/ioutil/) -: - The [`TempFile`](/pkg/io/ioutil/#TempFile) - function now supports specifying where the random characters in - the filename are placed. If the `prefix` argument - includes a "`*`", the random string replaces the - "`*`". For example, a `prefix` argument of "`myname.*.bat`" will - result in a random filename such as - "`myname.123456.bat`". If no "`*`" is - included the old behavior is retained, and the random digits are - appended to the end. + +The [`TempFile`](/pkg/io/ioutil/#TempFile) +function now supports specifying where the random characters in +the filename are placed. If the `prefix` argument +includes a "`*`", the random string replaces the +"`*`". For example, a `prefix` argument of "`myname.*.bat`" will +result in a random filename such as +"`myname.123456.bat`". If no "`*`" is +included the old behavior is retained, and the random digits are +appended to the end. -[math/big](/pkg/math/big/) +#### [math/big](/pkg/math/big/) -: - [`ModInverse`](/pkg/math/big/#Int.ModInverse) now returns nil when g and n are not relatively prime. The result was previously undefined. + +[`ModInverse`](/pkg/math/big/#Int.ModInverse) now returns nil when g and n are not relatively prime. The result was previously undefined. -[mime/multipart](/pkg/mime/multipart/) +#### [mime/multipart](/pkg/mime/multipart/) -: - The handling of form-data with missing/empty file names has been - restored to the behavior in Go 1.9: in the - [`Form`](/pkg/mime/multipart/#Form) for - the form-data part the value is available in - the `Value` field rather than the `File` - field. In Go releases 1.10 through 1.10.3 a form-data part with - a missing/empty file name and a non-empty "Content-Type" field - was stored in the `File` field. This change was a - mistake in 1.10 and has been reverted to the 1.9 behavior. + +The handling of form-data with missing/empty file names has been +restored to the behavior in Go 1.9: in the +[`Form`](/pkg/mime/multipart/#Form) for +the form-data part the value is available in +the `Value` field rather than the `File` +field. In Go releases 1.10 through 1.10.3 a form-data part with +a missing/empty file name and a non-empty "Content-Type" field +was stored in the `File` field. This change was a +mistake in 1.10 and has been reverted to the 1.9 behavior. -[mime/quotedprintable](/pkg/mime/quotedprintable/) +#### [mime/quotedprintable](/pkg/mime/quotedprintable/) -: - To support invalid input found in the wild, the package now - permits non-ASCII bytes but does not validate their encoding. + +To support invalid input found in the wild, the package now +permits non-ASCII bytes but does not validate their encoding. -[net](/pkg/net/) +#### [net](/pkg/net/) -: - The new [`ListenConfig`](/pkg/net/#ListenConfig) type and the new - [`Dialer.Control`](/pkg/net/#Dialer.Control) field permit - setting socket options before accepting and creating connections, respectively. + +The new [`ListenConfig`](/pkg/net/#ListenConfig) type and the new +[`Dialer.Control`](/pkg/net/#Dialer.Control) field permit +setting socket options before accepting and creating connections, respectively. - - The [`syscall.RawConn`](/pkg/syscall/#RawConn) `Read` - and `Write` methods now work correctly on Windows. + +The [`syscall.RawConn`](/pkg/syscall/#RawConn) `Read` +and `Write` methods now work correctly on Windows. - - The `net` package now automatically uses the - [`splice` system call](https://man7.org/linux/man-pages/man2/splice.2.html) - on Linux when copying data between TCP connections in - [`TCPConn.ReadFrom`](/pkg/net/#TCPConn.ReadFrom), as called by - [`io.Copy`](/pkg/io/#Copy). The result is faster, more efficient TCP proxying. + +The `net` package now automatically uses the +[`splice` system call](https://man7.org/linux/man-pages/man2/splice.2.html) +on Linux when copying data between TCP connections in +[`TCPConn.ReadFrom`](/pkg/net/#TCPConn.ReadFrom), as called by +[`io.Copy`](/pkg/io/#Copy). The result is faster, more efficient TCP proxying. - - The [`TCPConn.File`](/pkg/net/#TCPConn.File), - [`UDPConn.File`](/pkg/net/#UDPConn.File), - [`UnixConn.File`](/pkg/net/#UnixCOnn.File), - and [`IPConn.File`](/pkg/net/#IPConn.File) - methods no longer put the returned `*os.File` into - blocking mode. + +The [`TCPConn.File`](/pkg/net/#TCPConn.File), +[`UDPConn.File`](/pkg/net/#UDPConn.File), +[`UnixConn.File`](/pkg/net/#UnixCOnn.File), +and [`IPConn.File`](/pkg/net/#IPConn.File) +methods no longer put the returned `*os.File` into +blocking mode. -[net/http](/pkg/net/http/) +#### [net/http](/pkg/net/http/) -: - The [`Transport`](/pkg/net/http/#Transport) type has a - new [`MaxConnsPerHost`](/pkg/net/http/#Transport.MaxConnsPerHost) - option that permits limiting the maximum number of connections - per host. + +The [`Transport`](/pkg/net/http/#Transport) type has a +new [`MaxConnsPerHost`](/pkg/net/http/#Transport.MaxConnsPerHost) +option that permits limiting the maximum number of connections +per host. - - The [`Cookie`](/pkg/net/http/#Cookie) type has a new - [`SameSite`](/pkg/net/http/#Cookie.SameSite) field - (of new type also named - [`SameSite`](/pkg/net/http/#SameSite)) to represent the new cookie attribute recently supported by most browsers. - The `net/http`'s `Transport` does not use the `SameSite` - attribute itself, but the package supports parsing and serializing the - attribute for browsers to use. + +The [`Cookie`](/pkg/net/http/#Cookie) type has a new +[`SameSite`](/pkg/net/http/#Cookie.SameSite) field +(of new type also named +[`SameSite`](/pkg/net/http/#SameSite)) to represent the new cookie attribute recently supported by most browsers. +The `net/http`'s `Transport` does not use the `SameSite` +attribute itself, but the package supports parsing and serializing the +attribute for browsers to use. - - It is no longer allowed to reuse a [`Server`](/pkg/net/http/#Server) - after a call to - [`Shutdown`](/pkg/net/http/#Server.Shutdown) or - [`Close`](/pkg/net/http/#Server.Close). It was never officially supported - in the past and had often surprising behavior. Now, all future calls to the server's `Serve` - methods will return errors after a shutdown or close. + +It is no longer allowed to reuse a [`Server`](/pkg/net/http/#Server) +after a call to +[`Shutdown`](/pkg/net/http/#Server.Shutdown) or +[`Close`](/pkg/net/http/#Server.Close). It was never officially supported +in the past and had often surprising behavior. Now, all future calls to the server's `Serve` +methods will return errors after a shutdown or close. - + - - The constant `StatusMisdirectedRequest` is now defined for HTTP status code 421. + +The constant `StatusMisdirectedRequest` is now defined for HTTP status code 421. - - The HTTP server will no longer cancel contexts or send on - [`CloseNotifier`](/pkg/net/http/#CloseNotifier) - channels upon receiving pipelined HTTP/1.1 requests. Browsers do - not use HTTP pipelining, but some clients (such as - Debian's `apt`) may be configured to do so. + +The HTTP server will no longer cancel contexts or send on +[`CloseNotifier`](/pkg/net/http/#CloseNotifier) +channels upon receiving pipelined HTTP/1.1 requests. Browsers do +not use HTTP pipelining, but some clients (such as +Debian's `apt`) may be configured to do so. - - [`ProxyFromEnvironment`](/pkg/net/http/#ProxyFromEnvironment), which is used by the - [`DefaultTransport`](/pkg/net/http/#DefaultTransport), now - supports CIDR notation and ports in the `NO_PROXY` environment variable. + +[`ProxyFromEnvironment`](/pkg/net/http/#ProxyFromEnvironment), which is used by the +[`DefaultTransport`](/pkg/net/http/#DefaultTransport), now +supports CIDR notation and ports in the `NO_PROXY` environment variable. -[net/http/httputil](/pkg/net/http/httputil/) +#### [net/http/httputil](/pkg/net/http/httputil/) -: - The - [`ReverseProxy`](/pkg/net/http/httputil/#ReverseProxy) - has a new - [`ErrorHandler`](/pkg/net/http/httputil/#ReverseProxy.ErrorHandler) - option to permit changing how errors are handled. + +The +[`ReverseProxy`](/pkg/net/http/httputil/#ReverseProxy) +has a new +[`ErrorHandler`](/pkg/net/http/httputil/#ReverseProxy.ErrorHandler) +option to permit changing how errors are handled. - - The `ReverseProxy` now also passes - "`TE:` `trailers`" request headers - through to the backend, as required by the gRPC protocol. + +The `ReverseProxy` now also passes +"`TE:` `trailers`" request headers +through to the backend, as required by the gRPC protocol. -[os](/pkg/os/) +#### [os](/pkg/os/) -: - The new [`UserCacheDir`](/pkg/os/#UserCacheDir) function - returns the default root directory to use for user-specific cached data. + +The new [`UserCacheDir`](/pkg/os/#UserCacheDir) function +returns the default root directory to use for user-specific cached data. - - The new [`ModeIrregular`](/pkg/os/#ModeIrregular) - is a [`FileMode`](/pkg/os/#FileMode) bit to represent - that a file is not a regular file, but nothing else is known about it, or that - it's not a socket, device, named pipe, symlink, or other file type for which - Go has a defined mode bit. + +The new [`ModeIrregular`](/pkg/os/#ModeIrregular) +is a [`FileMode`](/pkg/os/#FileMode) bit to represent +that a file is not a regular file, but nothing else is known about it, or that +it's not a socket, device, named pipe, symlink, or other file type for which +Go has a defined mode bit. - - [`Symlink`](/pkg/os/#Symlink) now works - for unprivileged users on Windows 10 on machines with Developer - Mode enabled. + +[`Symlink`](/pkg/os/#Symlink) now works +for unprivileged users on Windows 10 on machines with Developer +Mode enabled. - - When a non-blocking descriptor is passed - to [`NewFile`](/pkg/os#NewFile), the - resulting `*File` will be kept in non-blocking - mode. This means that I/O for that `*File` will use - the runtime poller rather than a separate thread, and that - the [`SetDeadline`](/pkg/os/#File.SetDeadline) - methods will work. + +When a non-blocking descriptor is passed +to [`NewFile`](/pkg/os#NewFile), the +resulting `*File` will be kept in non-blocking +mode. This means that I/O for that `*File` will use +the runtime poller rather than a separate thread, and that +the [`SetDeadline`](/pkg/os/#File.SetDeadline) +methods will work. -[os/signal](/pkg/os/signal/) +#### [os/signal](/pkg/os/signal/) -: - The new [`Ignored`](/pkg/os/signal/#Ignored) function reports - whether a signal is currently ignored. + +The new [`Ignored`](/pkg/os/signal/#Ignored) function reports +whether a signal is currently ignored. -[os/user](/pkg/os/user/) +#### [os/user](/pkg/os/user/) -: - The `os/user` package can now be built in pure Go - mode using the build tag "`osusergo`", - independent of the use of the environment - variable `CGO_ENABLED=0`. Previously the only way to use - the package's pure Go implementation was to disable `cgo` - support across the entire program. + +The `os/user` package can now be built in pure Go +mode using the build tag "`osusergo`", +independent of the use of the environment +variable `CGO_ENABLED=0`. Previously the only way to use +the package's pure Go implementation was to disable `cgo` +support across the entire program. -[runtime](/pkg/runtime/) +#### [runtime](/pkg/runtime/) -: - Setting the GODEBUG=tracebackancestors=_N_ - environment variable now extends tracebacks with the stacks at - which goroutines were created, where _N_ limits the - number of ancestor goroutines to report. + +Setting the GODEBUG=tracebackancestors=_N_ +environment variable now extends tracebacks with the stacks at +which goroutines were created, where _N_ limits the +number of ancestor goroutines to report. -[runtime/pprof](/pkg/runtime/pprof/) +#### [runtime/pprof](/pkg/runtime/pprof/) -: - This release adds a new "allocs" profile type that profiles - total number of bytes allocated since the program began - (including garbage-collected bytes). This is identical to the - existing "heap" profile viewed in `-alloc_space` mode. - Now `go test -memprofile=...` reports an "allocs" profile - instead of "heap" profile. + +This release adds a new "allocs" profile type that profiles +total number of bytes allocated since the program began +(including garbage-collected bytes). This is identical to the +existing "heap" profile viewed in `-alloc_space` mode. +Now `go test -memprofile=...` reports an "allocs" profile +instead of "heap" profile. -[sync](/pkg/sync/) +#### [sync](/pkg/sync/) -: - The mutex profile now includes reader/writer contention - for [`RWMutex`](/pkg/sync/#RWMutex). - Writer/writer contention was already included in the mutex - profile. + +The mutex profile now includes reader/writer contention +for [`RWMutex`](/pkg/sync/#RWMutex). +Writer/writer contention was already included in the mutex +profile. -[syscall](/pkg/syscall/) +#### [syscall](/pkg/syscall/) -: - On Windows, several fields were changed from `uintptr` to a new - [`Pointer`](/pkg/syscall/?GOOS=windows&GOARCH=amd64#Pointer) - type to avoid problems with Go's garbage collector. The same change was made - to the [`golang.org/x/sys/windows`](https://godoc.org/golang.org/x/sys/windows) - package. For any code affected, users should first migrate away from the `syscall` - package to the `golang.org/x/sys/windows` package, and then change - to using the `Pointer`, while obeying the - [`unsafe.Pointer` conversion rules](/pkg/unsafe/#Pointer). + +On Windows, several fields were changed from `uintptr` to a new +[`Pointer`](/pkg/syscall/?GOOS=windows&GOARCH=amd64#Pointer) +type to avoid problems with Go's garbage collector. The same change was made +to the [`golang.org/x/sys/windows`](https://godoc.org/golang.org/x/sys/windows) +package. For any code affected, users should first migrate away from the `syscall` +package to the `golang.org/x/sys/windows` package, and then change +to using the `Pointer`, while obeying the +[`unsafe.Pointer` conversion rules](/pkg/unsafe/#Pointer). - - On Linux, the `flags` parameter to - [`Faccessat`](/pkg/syscall/?GOOS=linux&GOARCH=amd64#Faccessat) - is now implemented just as in glibc. In earlier Go releases the - flags parameter was ignored. + +On Linux, the `flags` parameter to +[`Faccessat`](/pkg/syscall/?GOOS=linux&GOARCH=amd64#Faccessat) +is now implemented just as in glibc. In earlier Go releases the +flags parameter was ignored. - - On Linux, the `flags` parameter to - [`Fchmodat`](/pkg/syscall/?GOOS=linux&GOARCH=amd64#Fchmodat) - is now validated. Linux's `fchmodat` doesn't support the `flags` parameter - so we now mimic glibc's behavior and return an error if it's non-zero. + +On Linux, the `flags` parameter to +[`Fchmodat`](/pkg/syscall/?GOOS=linux&GOARCH=amd64#Fchmodat) +is now validated. Linux's `fchmodat` doesn't support the `flags` parameter +so we now mimic glibc's behavior and return an error if it's non-zero. -[text/scanner](/pkg/text/scanner/) +#### [text/scanner](/pkg/text/scanner/) -: - The [`Scanner.Scan`](/pkg/text/scanner/#Scanner.Scan) method now returns - the [`RawString`](/pkg/text/scanner/#RawString) token - instead of [`String`](/pkg/text/scanner/#String) - for raw string literals. + +The [`Scanner.Scan`](/pkg/text/scanner/#Scanner.Scan) method now returns +the [`RawString`](/pkg/text/scanner/#RawString) token +instead of [`String`](/pkg/text/scanner/#String) +for raw string literals. -[text/template](/pkg/text/template/) +#### [text/template](/pkg/text/template/) -: - Modifying template variables via assignments is now permitted via the `=` token: + +Modifying template variables via assignments is now permitted via the `=` token: - {{ $v := "init" }} - {{ if true }} - {{ $v = "changed" }} - {{ end }} - v: {{ $v }} {{/* "changed" */}} + {{ $v := "init" }} + {{ if true }} + {{ $v = "changed" }} + {{ end }} + v: {{ $v }} {{/* "changed" */}} - - In previous versions untyped `nil` values passed to - template functions were ignored. They are now passed as normal - arguments. + +In previous versions untyped `nil` values passed to +template functions were ignored. They are now passed as normal +arguments. -[time](/pkg/time/) +#### [time](/pkg/time/) -: - Parsing of timezones denoted by sign and offset is now - supported. In previous versions, numeric timezone names - (such as `+03`) were not considered valid, and only - three-letter abbreviations (such as `MST`) were accepted - when expecting a timezone name. + +Parsing of timezones denoted by sign and offset is now +supported. In previous versions, numeric timezone names +(such as `+03`) were not considered valid, and only +three-letter abbreviations (such as `MST`) were accepted +when expecting a timezone name. diff --git a/_content/doc/go1.12.md b/_content/doc/go1.12.md index d3f3f930..4281d266 100644 --- a/_content/doc/go1.12.md +++ b/_content/doc/go1.12.md @@ -390,437 +390,437 @@ in mind. -[bufio](/pkg/bufio/) +#### [bufio](/pkg/bufio/) -: - `Reader`'s [`UnreadRune`](/pkg/bufio/#Reader.UnreadRune) and - [`UnreadByte`](/pkg/bufio/#Reader.UnreadByte) methods will now return an error - if they are called after [`Peek`](/pkg/bufio/#Reader.Peek). + +`Reader`'s [`UnreadRune`](/pkg/bufio/#Reader.UnreadRune) and +[`UnreadByte`](/pkg/bufio/#Reader.UnreadByte) methods will now return an error +if they are called after [`Peek`](/pkg/bufio/#Reader.Peek). -[bytes](/pkg/bytes/) +#### [bytes](/pkg/bytes/) -: - The new function [`ReplaceAll`](/pkg/bytes/#ReplaceAll) returns a copy of - a byte slice with all non-overlapping instances of a value replaced by another. + +The new function [`ReplaceAll`](/pkg/bytes/#ReplaceAll) returns a copy of +a byte slice with all non-overlapping instances of a value replaced by another. - - A pointer to a zero-value [`Reader`](/pkg/bytes/#Reader) is now - functionally equivalent to [`NewReader`](/pkg/bytes/#NewReader)`(nil)`. - Prior to Go 1.12, the former could not be used as a substitute for the latter in all cases. + +A pointer to a zero-value [`Reader`](/pkg/bytes/#Reader) is now +functionally equivalent to [`NewReader`](/pkg/bytes/#NewReader)`(nil)`. +Prior to Go 1.12, the former could not be used as a substitute for the latter in all cases. -[crypto/rand](/pkg/crypto/rand/) +#### [crypto/rand](/pkg/crypto/rand/) -: - A warning will now be printed to standard error the first time - `Reader.Read` is blocked for more than 60 seconds waiting - to read entropy from the kernel. + +A warning will now be printed to standard error the first time +`Reader.Read` is blocked for more than 60 seconds waiting +to read entropy from the kernel. - - On FreeBSD, `Reader` now uses the `getrandom` - system call if available, `/dev/urandom` otherwise. + +On FreeBSD, `Reader` now uses the `getrandom` +system call if available, `/dev/urandom` otherwise. -[crypto/rc4](/pkg/crypto/rc4/) +#### [crypto/rc4](/pkg/crypto/rc4/) -: - This release removes the assembly implementations, leaving only - the pure Go version. The Go compiler generates code that is - either slightly better or slightly worse, depending on the exact - CPU. RC4 is insecure and should only be used for compatibility - with legacy systems. + +This release removes the assembly implementations, leaving only +the pure Go version. The Go compiler generates code that is +either slightly better or slightly worse, depending on the exact +CPU. RC4 is insecure and should only be used for compatibility +with legacy systems. -[crypto/tls](/pkg/crypto/tls/) +#### [crypto/tls](/pkg/crypto/tls/) -: - If a client sends an initial message that does not look like TLS, the server - will no longer reply with an alert, and it will expose the underlying - `net.Conn` in the new field `Conn` of - [`RecordHeaderError`](/pkg/crypto/tls/#RecordHeaderError). + +If a client sends an initial message that does not look like TLS, the server +will no longer reply with an alert, and it will expose the underlying +`net.Conn` in the new field `Conn` of +[`RecordHeaderError`](/pkg/crypto/tls/#RecordHeaderError). -[database/sql](/pkg/database/sql/) +#### [database/sql](/pkg/database/sql/) -: - A query cursor can now be obtained by passing a - [`*Rows`](/pkg/database/sql/#Rows) - value to the [`Row.Scan`](/pkg/database/sql/#Row.Scan) method. + +A query cursor can now be obtained by passing a +[`*Rows`](/pkg/database/sql/#Rows) +value to the [`Row.Scan`](/pkg/database/sql/#Row.Scan) method. -[expvar](/pkg/expvar/) +#### [expvar](/pkg/expvar/) -: - The new [`Delete`](/pkg/expvar/#Map.Delete) method allows - for deletion of key/value pairs from a [`Map`](/pkg/expvar/#Map). + +The new [`Delete`](/pkg/expvar/#Map.Delete) method allows +for deletion of key/value pairs from a [`Map`](/pkg/expvar/#Map). -[fmt](/pkg/fmt/) +#### [fmt](/pkg/fmt/) -: - Maps are now printed in key-sorted order to ease testing. The ordering rules are: + +Maps are now printed in key-sorted order to ease testing. The ordering rules are: - - When applicable, nil compares low - - ints, floats, and strings order by < - - NaN compares less than non-NaN floats - - bool compares false before true - - Complex compares real, then imaginary - - Pointers compare by machine address - - Channel values compare by machine address - - Structs compare each field in turn - - Arrays compare each element in turn - - Interface values compare first by `reflect.Type` describing the concrete type - and then by concrete value as described in the previous rules. + - When applicable, nil compares low + - ints, floats, and strings order by < + - NaN compares less than non-NaN floats + - bool compares false before true + - Complex compares real, then imaginary + - Pointers compare by machine address + - Channel values compare by machine address + - Structs compare each field in turn + - Arrays compare each element in turn + - Interface values compare first by `reflect.Type` describing the concrete type + and then by concrete value as described in the previous rules. - - When printing maps, non-reflexive key values like `NaN` were previously - displayed as ``. As of this release, the correct values are printed. + +When printing maps, non-reflexive key values like `NaN` were previously +displayed as ``. As of this release, the correct values are printed. -[go/doc](/pkg/go/doc/) +#### [go/doc](/pkg/go/doc/) -: - To address some outstanding issues in [`cmd/doc`](/cmd/doc/), - this package has a new [`Mode`](/pkg/go/doc/#Mode) bit, - `PreserveAST`, which controls whether AST data is cleared. + +To address some outstanding issues in [`cmd/doc`](/cmd/doc/), +this package has a new [`Mode`](/pkg/go/doc/#Mode) bit, +`PreserveAST`, which controls whether AST data is cleared. -[go/token](/pkg/go/token/) +#### [go/token](/pkg/go/token/) -: - The [`File`](/pkg/go/token#File) type has a new - [`LineStart`](/pkg/go/token#File.LineStart) field, - which returns the position of the start of a given line. This is especially useful - in programs that occasionally handle non-Go files, such as assembly, but wish to use - the `token.Pos` mechanism to identify file positions. + +The [`File`](/pkg/go/token#File) type has a new +[`LineStart`](/pkg/go/token#File.LineStart) field, +which returns the position of the start of a given line. This is especially useful +in programs that occasionally handle non-Go files, such as assembly, but wish to use +the `token.Pos` mechanism to identify file positions. -[image](/pkg/image/) +#### [image](/pkg/image/) -: - The [`RegisterFormat`](/pkg/image/#RegisterFormat) function is now safe for concurrent use. + +The [`RegisterFormat`](/pkg/image/#RegisterFormat) function is now safe for concurrent use. -[image/png](/pkg/image/png/) +#### [image/png](/pkg/image/png/) -: - Paletted images with fewer than 16 colors now encode to smaller outputs. + +Paletted images with fewer than 16 colors now encode to smaller outputs. -[io](/pkg/io/) +#### [io](/pkg/io/) -: - The new [`StringWriter`](/pkg/io#StringWriter) interface wraps the - [`WriteString`](/pkg/io/#WriteString) function. + +The new [`StringWriter`](/pkg/io#StringWriter) interface wraps the +[`WriteString`](/pkg/io/#WriteString) function. -[math](/pkg/math/) +#### [math](/pkg/math/) -: - The functions - [`Sin`](/pkg/math/#Sin), - [`Cos`](/pkg/math/#Cos), - [`Tan`](/pkg/math/#Tan), - and [`Sincos`](/pkg/math/#Sincos) now - apply Payne-Hanek range reduction to huge arguments. This - produces more accurate answers, but they will not be bit-for-bit - identical with the results in earlier releases. + +The functions +[`Sin`](/pkg/math/#Sin), +[`Cos`](/pkg/math/#Cos), +[`Tan`](/pkg/math/#Tan), +and [`Sincos`](/pkg/math/#Sincos) now +apply Payne-Hanek range reduction to huge arguments. This +produces more accurate answers, but they will not be bit-for-bit +identical with the results in earlier releases. -[math/bits](/pkg/math/bits/) +#### [math/bits](/pkg/math/bits/) -: - New extended precision operations [`Add`](/pkg/math/bits/#Add), [`Sub`](/pkg/math/bits/#Sub), [`Mul`](/pkg/math/bits/#Mul), and [`Div`](/pkg/math/bits/#Div) are available in `uint`, `uint32`, and `uint64` versions. + +New extended precision operations [`Add`](/pkg/math/bits/#Add), [`Sub`](/pkg/math/bits/#Sub), [`Mul`](/pkg/math/bits/#Mul), and [`Div`](/pkg/math/bits/#Div) are available in `uint`, `uint32`, and `uint64` versions. -[net](/pkg/net/) +#### [net](/pkg/net/) -: - The - [`Dialer.DualStack`](/pkg/net/#Dialer.DualStack) setting is now ignored and deprecated; - RFC 6555 Fast Fallback ("Happy Eyeballs") is now enabled by default. To disable, set - [`Dialer.FallbackDelay`](/pkg/net/#Dialer.FallbackDelay) to a negative value. + +The +[`Dialer.DualStack`](/pkg/net/#Dialer.DualStack) setting is now ignored and deprecated; +RFC 6555 Fast Fallback ("Happy Eyeballs") is now enabled by default. To disable, set +[`Dialer.FallbackDelay`](/pkg/net/#Dialer.FallbackDelay) to a negative value. - - Similarly, TCP keep-alives are now enabled by default if - [`Dialer.KeepAlive`](/pkg/net/#Dialer.KeepAlive) is zero. - To disable, set it to a negative value. + +Similarly, TCP keep-alives are now enabled by default if +[`Dialer.KeepAlive`](/pkg/net/#Dialer.KeepAlive) is zero. +To disable, set it to a negative value. - - On Linux, the [`splice` system call](https://man7.org/linux/man-pages/man2/splice.2.html) is now used when copying from a - [`UnixConn`](/pkg/net/#UnixConn) to a - [`TCPConn`](/pkg/net/#TCPConn). + +On Linux, the [`splice` system call](https://man7.org/linux/man-pages/man2/splice.2.html) is now used when copying from a +[`UnixConn`](/pkg/net/#UnixConn) to a +[`TCPConn`](/pkg/net/#TCPConn). -[net/http](/pkg/net/http/) +#### [net/http](/pkg/net/http/) -: - The HTTP server now rejects misdirected HTTP requests to HTTPS servers with a plaintext "400 Bad Request" response. + +The HTTP server now rejects misdirected HTTP requests to HTTPS servers with a plaintext "400 Bad Request" response. - - The new [`Client.CloseIdleConnections`](/pkg/net/http/#Client.CloseIdleConnections) - method calls the `Client`'s underlying `Transport`'s `CloseIdleConnections` - if it has one. + +The new [`Client.CloseIdleConnections`](/pkg/net/http/#Client.CloseIdleConnections) +method calls the `Client`'s underlying `Transport`'s `CloseIdleConnections` +if it has one. - - The [`Transport`](/pkg/net/http/#Transport) no longer rejects HTTP responses which declare - HTTP Trailers but don't use chunked encoding. Instead, the declared trailers are now just ignored. + +The [`Transport`](/pkg/net/http/#Transport) no longer rejects HTTP responses which declare +HTTP Trailers but don't use chunked encoding. Instead, the declared trailers are now just ignored. - - - The [`Transport`](/pkg/net/http/#Transport) no longer handles `MAX_CONCURRENT_STREAMS` values - advertised from HTTP/2 servers as strictly as it did during Go 1.10 and Go 1.11. The default behavior is now back - to how it was in Go 1.9: each connection to a server can have up to `MAX_CONCURRENT_STREAMS` requests - active and then new TCP connections are created as needed. In Go 1.10 and Go 1.11 the `http2` package - would block and wait for requests to finish instead of creating new connections. - To get the stricter behavior back, import the - [`golang.org/x/net/http2`](https://godoc.org/golang.org/x/net/http2) package - directly and set - [`Transport.StrictMaxConcurrentStreams`](https://godoc.org/golang.org/x/net/http2#Transport.StrictMaxConcurrentStreams) to - `true`. + + +The [`Transport`](/pkg/net/http/#Transport) no longer handles `MAX_CONCURRENT_STREAMS` values +advertised from HTTP/2 servers as strictly as it did during Go 1.10 and Go 1.11. The default behavior is now back +to how it was in Go 1.9: each connection to a server can have up to `MAX_CONCURRENT_STREAMS` requests +active and then new TCP connections are created as needed. In Go 1.10 and Go 1.11 the `http2` package +would block and wait for requests to finish instead of creating new connections. +To get the stricter behavior back, import the +[`golang.org/x/net/http2`](https://godoc.org/golang.org/x/net/http2) package +directly and set +[`Transport.StrictMaxConcurrentStreams`](https://godoc.org/golang.org/x/net/http2#Transport.StrictMaxConcurrentStreams) to +`true`. -[net/url](/pkg/net/url/) +#### [net/url](/pkg/net/url/) -: - [`Parse`](/pkg/net/url/#Parse), - [`ParseRequestURI`](/pkg/net/url/#ParseRequestURI), - and - [`URL.Parse`](/pkg/net/url/#URL.Parse) - now return an - error for URLs containing ASCII control characters, which includes NULL, - tab, and newlines. + +[`Parse`](/pkg/net/url/#Parse), +[`ParseRequestURI`](/pkg/net/url/#ParseRequestURI), +and +[`URL.Parse`](/pkg/net/url/#URL.Parse) +now return an +error for URLs containing ASCII control characters, which includes NULL, +tab, and newlines. -[net/http/httputil](/pkg/net/http/httputil/) +#### [net/http/httputil](/pkg/net/http/httputil/) -: - The [`ReverseProxy`](/pkg/net/http/httputil/#ReverseProxy) now automatically - proxies WebSocket requests. + +The [`ReverseProxy`](/pkg/net/http/httputil/#ReverseProxy) now automatically +proxies WebSocket requests. -[os](/pkg/os/) +#### [os](/pkg/os/) -: - The new [`ProcessState.ExitCode`](/pkg/os/#ProcessState.ExitCode) method - returns the process's exit code. + +The new [`ProcessState.ExitCode`](/pkg/os/#ProcessState.ExitCode) method +returns the process's exit code. - - `ModeCharDevice` has been added to the `ModeType` bitmask, allowing for - `ModeDevice | ModeCharDevice` to be recovered when masking a - [`FileMode`](/pkg/os/#FileMode) with `ModeType`. + +`ModeCharDevice` has been added to the `ModeType` bitmask, allowing for +`ModeDevice | ModeCharDevice` to be recovered when masking a +[`FileMode`](/pkg/os/#FileMode) with `ModeType`. - - The new function [`UserHomeDir`](/pkg/os/#UserHomeDir) returns the - current user's home directory. + +The new function [`UserHomeDir`](/pkg/os/#UserHomeDir) returns the +current user's home directory. - - [`RemoveAll`](/pkg/os/#RemoveAll) now supports paths longer than 4096 characters - on most Unix systems. + +[`RemoveAll`](/pkg/os/#RemoveAll) now supports paths longer than 4096 characters +on most Unix systems. - - [`File.Sync`](/pkg/os/#File.Sync) now uses `F_FULLFSYNC` on macOS - to correctly flush the file contents to permanent storage. - This may cause the method to run more slowly than in previous releases. + +[`File.Sync`](/pkg/os/#File.Sync) now uses `F_FULLFSYNC` on macOS +to correctly flush the file contents to permanent storage. +This may cause the method to run more slowly than in previous releases. - - [`File`](/pkg/os/#File) now supports - a [`SyscallConn`](/pkg/os/#File.SyscallConn) - method returning - a [`syscall.RawConn`](/pkg/syscall/#RawConn) - interface value. This may be used to invoke system-specific - operations on the underlying file descriptor. + +[`File`](/pkg/os/#File) now supports +a [`SyscallConn`](/pkg/os/#File.SyscallConn) +method returning +a [`syscall.RawConn`](/pkg/syscall/#RawConn) +interface value. This may be used to invoke system-specific +operations on the underlying file descriptor. -[path/filepath](/pkg/path/filepath/) +#### [path/filepath](/pkg/path/filepath/) -: - The [`IsAbs`](/pkg/path/filepath/#IsAbs) function now returns true when passed - a reserved filename on Windows such as `NUL`. - [List of reserved names.](https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#naming-conventions) + +The [`IsAbs`](/pkg/path/filepath/#IsAbs) function now returns true when passed +a reserved filename on Windows such as `NUL`. +[List of reserved names.](https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#naming-conventions) -[reflect](/pkg/reflect/) +#### [reflect](/pkg/reflect/) -: - A new [`MapIter`](/pkg/reflect#MapIter) type is - an iterator for ranging over a map. This type is exposed through the - [`Value`](/pkg/reflect#Value) type's new - [`MapRange`](/pkg/reflect#Value.MapRange) method. - This follows the same iteration semantics as a range statement, with `Next` - to advance the iterator, and `Key`/`Value` to access each entry. + +A new [`MapIter`](/pkg/reflect#MapIter) type is +an iterator for ranging over a map. This type is exposed through the +[`Value`](/pkg/reflect#Value) type's new +[`MapRange`](/pkg/reflect#Value.MapRange) method. +This follows the same iteration semantics as a range statement, with `Next` +to advance the iterator, and `Key`/`Value` to access each entry. -[regexp](/pkg/regexp/) +#### [regexp](/pkg/regexp/) -: - [`Copy`](/pkg/regexp/#Regexp.Copy) is no longer necessary - to avoid lock contention, so it has been given a partial deprecation comment. - [`Copy`](/pkg/regexp/#Regexp.Copy) - may still be appropriate if the reason for its use is to make two copies with - different [`Longest`](/pkg/regexp/#Regexp.Longest) settings. + +[`Copy`](/pkg/regexp/#Regexp.Copy) is no longer necessary +to avoid lock contention, so it has been given a partial deprecation comment. +[`Copy`](/pkg/regexp/#Regexp.Copy) +may still be appropriate if the reason for its use is to make two copies with +different [`Longest`](/pkg/regexp/#Regexp.Longest) settings. -[runtime/debug](/pkg/runtime/debug/) +#### [runtime/debug](/pkg/runtime/debug/) -: - A new [`BuildInfo`](/pkg/runtime/debug/#BuildInfo) type - exposes the build information read from the running binary, available only in - binaries built with module support. This includes the main package path, main - module information, and the module dependencies. This type is given through the - [`ReadBuildInfo`](/pkg/runtime/debug/#ReadBuildInfo) function - on [`BuildInfo`](/pkg/runtime/debug/#BuildInfo). + +A new [`BuildInfo`](/pkg/runtime/debug/#BuildInfo) type +exposes the build information read from the running binary, available only in +binaries built with module support. This includes the main package path, main +module information, and the module dependencies. This type is given through the +[`ReadBuildInfo`](/pkg/runtime/debug/#ReadBuildInfo) function +on [`BuildInfo`](/pkg/runtime/debug/#BuildInfo). -[strings](/pkg/strings/) +#### [strings](/pkg/strings/) -: - The new function [`ReplaceAll`](/pkg/strings/#ReplaceAll) returns a copy of - a string with all non-overlapping instances of a value replaced by another. + +The new function [`ReplaceAll`](/pkg/strings/#ReplaceAll) returns a copy of +a string with all non-overlapping instances of a value replaced by another. - - A pointer to a zero-value [`Reader`](/pkg/strings/#Reader) is now - functionally equivalent to [`NewReader`](/pkg/strings/#NewReader)`(nil)`. - Prior to Go 1.12, the former could not be used as a substitute for the latter in all cases. + +A pointer to a zero-value [`Reader`](/pkg/strings/#Reader) is now +functionally equivalent to [`NewReader`](/pkg/strings/#NewReader)`(nil)`. +Prior to Go 1.12, the former could not be used as a substitute for the latter in all cases. - - The new [`Builder.Cap`](/pkg/strings/#Builder.Cap) method returns the capacity of the builder's underlying byte slice. + +The new [`Builder.Cap`](/pkg/strings/#Builder.Cap) method returns the capacity of the builder's underlying byte slice. - - The character mapping functions [`Map`](/pkg/strings/#Map), - [`Title`](/pkg/strings/#Title), - [`ToLower`](/pkg/strings/#ToLower), - [`ToLowerSpecial`](/pkg/strings/#ToLowerSpecial), - [`ToTitle`](/pkg/strings/#ToTitle), - [`ToTitleSpecial`](/pkg/strings/#ToTitleSpecial), - [`ToUpper`](/pkg/strings/#ToUpper), and - [`ToUpperSpecial`](/pkg/strings/#ToUpperSpecial) - now always guarantee to return valid UTF-8. In earlier releases, if the input was invalid UTF-8 but no character replacements - needed to be applied, these routines incorrectly returned the invalid UTF-8 unmodified. + +The character mapping functions [`Map`](/pkg/strings/#Map), +[`Title`](/pkg/strings/#Title), +[`ToLower`](/pkg/strings/#ToLower), +[`ToLowerSpecial`](/pkg/strings/#ToLowerSpecial), +[`ToTitle`](/pkg/strings/#ToTitle), +[`ToTitleSpecial`](/pkg/strings/#ToTitleSpecial), +[`ToUpper`](/pkg/strings/#ToUpper), and +[`ToUpperSpecial`](/pkg/strings/#ToUpperSpecial) +now always guarantee to return valid UTF-8. In earlier releases, if the input was invalid UTF-8 but no character replacements +needed to be applied, these routines incorrectly returned the invalid UTF-8 unmodified. -[syscall](/pkg/syscall/) +#### [syscall](/pkg/syscall/) -: - 64-bit inodes are now supported on FreeBSD 12. Some types have been adjusted accordingly. + +64-bit inodes are now supported on FreeBSD 12. Some types have been adjusted accordingly. - - The Unix socket - ([`AF_UNIX`](https://blogs.msdn.microsoft.com/commandline/2017/12/19/af_unix-comes-to-windows/)) - address family is now supported for compatible versions of Windows. + +The Unix socket +([`AF_UNIX`](https://blogs.msdn.microsoft.com/commandline/2017/12/19/af_unix-comes-to-windows/)) +address family is now supported for compatible versions of Windows. - - The new function [`Syscall18`](/pkg/syscall/?GOOS=windows&GOARCH=amd64#Syscall18) - has been introduced for Windows, allowing for calls with up to 18 arguments. + +The new function [`Syscall18`](/pkg/syscall/?GOOS=windows&GOARCH=amd64#Syscall18) +has been introduced for Windows, allowing for calls with up to 18 arguments. -[syscall/js](/pkg/syscall/js/) +#### [syscall/js](/pkg/syscall/js/) -: + - The `Callback` type and `NewCallback` function have been renamed; - they are now called - [`Func`](/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Func) and - [`FuncOf`](/pkg/syscall/js/?GOOS=js&GOARCH=wasm#FuncOf), respectively. - This is a breaking change, but WebAssembly support is still experimental - and not yet subject to the - [Go 1 compatibility promise](/doc/go1compat). Any code using the - old names will need to be updated. +The `Callback` type and `NewCallback` function have been renamed; +they are now called +[`Func`](/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Func) and +[`FuncOf`](/pkg/syscall/js/?GOOS=js&GOARCH=wasm#FuncOf), respectively. +This is a breaking change, but WebAssembly support is still experimental +and not yet subject to the +[Go 1 compatibility promise](/doc/go1compat). Any code using the +old names will need to be updated. - - If a type implements the new - [`Wrapper`](/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Wrapper) - interface, - [`ValueOf`](/pkg/syscall/js/?GOOS=js&GOARCH=wasm#ValueOf) - will use it to return the JavaScript value for that type. + +If a type implements the new +[`Wrapper`](/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Wrapper) +interface, +[`ValueOf`](/pkg/syscall/js/?GOOS=js&GOARCH=wasm#ValueOf) +will use it to return the JavaScript value for that type. - - The meaning of the zero - [`Value`](/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Value) - has changed. It now represents the JavaScript `undefined` value - instead of the number zero. - This is a breaking change, but WebAssembly support is still experimental - and not yet subject to the - [Go 1 compatibility promise](/doc/go1compat). Any code relying on - the zero [`Value`](/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Value) - to mean the number zero will need to be updated. + +The meaning of the zero +[`Value`](/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Value) +has changed. It now represents the JavaScript `undefined` value +instead of the number zero. +This is a breaking change, but WebAssembly support is still experimental +and not yet subject to the +[Go 1 compatibility promise](/doc/go1compat). Any code relying on +the zero [`Value`](/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Value) +to mean the number zero will need to be updated. - - The new - [`Value.Truthy`](/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Value.Truthy) - method reports the - [JavaScript "truthiness"](https://developer.mozilla.org/en-US/docs/Glossary/Truthy) - of a given value. + +The new +[`Value.Truthy`](/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Value.Truthy) +method reports the +[JavaScript "truthiness"](https://developer.mozilla.org/en-US/docs/Glossary/Truthy) +of a given value. -[testing](/pkg/testing/) +#### [testing](/pkg/testing/) -: - The [`-benchtime`](/cmd/go/#hdr-Testing_flags) flag now supports setting an explicit iteration count instead of a time when the value ends with an "`x`". For example, `-benchtime=100x` runs the benchmark 100 times. + +The [`-benchtime`](/cmd/go/#hdr-Testing_flags) flag now supports setting an explicit iteration count instead of a time when the value ends with an "`x`". For example, `-benchtime=100x` runs the benchmark 100 times. -[text/template](/pkg/text/template/) +#### [text/template](/pkg/text/template/) -: - When executing a template, long context values are no longer truncated in errors. + +When executing a template, long context values are no longer truncated in errors. - `executing "tmpl" at <.very.deep.context.v...>: map has no entry for key "notpresent"` +`executing "tmpl" at <.very.deep.context.v...>: map has no entry for key "notpresent"` - is now +is now - `executing "tmpl" at <.very.deep.context.value.notpresent>: map has no entry for key "notpresent"` +`executing "tmpl" at <.very.deep.context.value.notpresent>: map has no entry for key "notpresent"` - - If a user-defined function called by a template panics, the - panic is now caught and returned as an error by - the `Execute` or `ExecuteTemplate` method. + +If a user-defined function called by a template panics, the +panic is now caught and returned as an error by +the `Execute` or `ExecuteTemplate` method. -[time](/pkg/time/) +#### [time](/pkg/time/) -: - The time zone database in `$GOROOT/lib/time/zoneinfo.zip` - has been updated to version 2018i. Note that this ZIP file is - only used if a time zone database is not provided by the operating - system. + +The time zone database in `$GOROOT/lib/time/zoneinfo.zip` +has been updated to version 2018i. Note that this ZIP file is +only used if a time zone database is not provided by the operating +system. -[unsafe](/pkg/unsafe/) +#### [unsafe](/pkg/unsafe/) -: - It is invalid to convert a nil `unsafe.Pointer` to `uintptr` and back with arithmetic. - (This was already invalid, but will now cause the compiler to misbehave.) + +It is invalid to convert a nil `unsafe.Pointer` to `uintptr` and back with arithmetic. +(This was already invalid, but will now cause the compiler to misbehave.) diff --git a/_content/doc/go1.13.md b/_content/doc/go1.13.md index 1d37b781..e9e63bf3 100644 --- a/_content/doc/go1.13.md +++ b/_content/doc/go1.13.md @@ -478,434 +478,434 @@ As always, there are various minor changes and updates to the library, made with the Go 1 [promise of compatibility](/doc/go1compat) in mind. -[bytes](/pkg/bytes/) +#### [bytes](/pkg/bytes/) -: The new [`ToValidUTF8`](/pkg/bytes/#ToValidUTF8) function returns a - copy of a given byte slice with each run of invalid UTF-8 byte sequences replaced by a given slice. +The new [`ToValidUTF8`](/pkg/bytes/#ToValidUTF8) function returns a +copy of a given byte slice with each run of invalid UTF-8 byte sequences replaced by a given slice. -[context](/pkg/context/) +#### [context](/pkg/context/) -: - The formatting of contexts returned by [`WithValue`](/pkg/context/#WithValue) no longer depends on `fmt` and will not stringify in the same way. Code that depends on the exact previous stringification might be affected. + +The formatting of contexts returned by [`WithValue`](/pkg/context/#WithValue) no longer depends on `fmt` and will not stringify in the same way. Code that depends on the exact previous stringification might be affected. -[crypto/tls](/pkg/crypto/tls/) +#### [crypto/tls](/pkg/crypto/tls/) -: Support for SSL version 3.0 (SSLv3) [ - is now deprecated and will be removed in Go 1.14](/issue/32716). Note that SSLv3 is the - [cryptographically broken](https://tools.ietf.org/html/rfc7568) - protocol predating TLS. +Support for SSL version 3.0 (SSLv3) [ +is now deprecated and will be removed in Go 1.14](/issue/32716). Note that SSLv3 is the +[cryptographically broken](https://tools.ietf.org/html/rfc7568) +protocol predating TLS. - SSLv3 was always disabled by default, other than in Go 1.12, when it was - mistakenly enabled by default server-side. It is now again disabled by - default. (SSLv3 was never supported client-side.) +SSLv3 was always disabled by default, other than in Go 1.12, when it was +mistakenly enabled by default server-side. It is now again disabled by +default. (SSLv3 was never supported client-side.) - - Ed25519 certificates are now supported in TLS versions 1.2 and 1.3. + +Ed25519 certificates are now supported in TLS versions 1.2 and 1.3. -[crypto/x509](/pkg/crypto/x509/) +#### [crypto/x509](/pkg/crypto/x509/) -: - Ed25519 keys are now supported in certificates and certificate requests - according to [RFC 8410](https://www.rfc-editor.org/info/rfc8410), as well as by the - [`ParsePKCS8PrivateKey`](/pkg/crypto/x509/#ParsePKCS8PrivateKey), - [`MarshalPKCS8PrivateKey`](/pkg/crypto/x509/#MarshalPKCS8PrivateKey), - and [`ParsePKIXPublicKey`](/pkg/crypto/x509/#ParsePKIXPublicKey) functions. + +Ed25519 keys are now supported in certificates and certificate requests +according to [RFC 8410](https://www.rfc-editor.org/info/rfc8410), as well as by the +[`ParsePKCS8PrivateKey`](/pkg/crypto/x509/#ParsePKCS8PrivateKey), +[`MarshalPKCS8PrivateKey`](/pkg/crypto/x509/#MarshalPKCS8PrivateKey), +and [`ParsePKIXPublicKey`](/pkg/crypto/x509/#ParsePKIXPublicKey) functions. - - The paths searched for system roots now include `/etc/ssl/cert.pem` - to support the default location in Alpine Linux 3.7+. + +The paths searched for system roots now include `/etc/ssl/cert.pem` +to support the default location in Alpine Linux 3.7+. -[database/sql](/pkg/database/sql/) +#### [database/sql](/pkg/database/sql/) -: - The new [`NullTime`](/pkg/database/sql/#NullTime) type represents a `time.Time` that may be null. + +The new [`NullTime`](/pkg/database/sql/#NullTime) type represents a `time.Time` that may be null. - - The new [`NullInt32`](/pkg/database/sql/#NullInt32) type represents an `int32` that may be null. + +The new [`NullInt32`](/pkg/database/sql/#NullInt32) type represents an `int32` that may be null. -[debug/dwarf](/pkg/debug/dwarf/) +#### [debug/dwarf](/pkg/debug/dwarf/) -: - The [`Data.Type`](/pkg/debug/dwarf/#Data.Type) - method no longer panics if it encounters an unknown DWARF tag in - the type graph. Instead, it represents that component of the - type with - an [`UnsupportedType`](/pkg/debug/dwarf/#UnsupportedType) - object. + +The [`Data.Type`](/pkg/debug/dwarf/#Data.Type) +method no longer panics if it encounters an unknown DWARF tag in +the type graph. Instead, it represents that component of the +type with +an [`UnsupportedType`](/pkg/debug/dwarf/#UnsupportedType) +object. -[errors](/pkg/errors/) +#### [errors](/pkg/errors/) -: + - The new function [`As`](/pkg/errors/#As) finds the first - error in a given error’s chain (sequence of wrapped errors) - that matches a given target’s type, and if so, sets the target to that error value. +The new function [`As`](/pkg/errors/#As) finds the first +error in a given error’s chain (sequence of wrapped errors) +that matches a given target’s type, and if so, sets the target to that error value. - The new function [`Is`](/pkg/errors/#Is) reports whether a given error value matches an - error in another’s chain. +The new function [`Is`](/pkg/errors/#Is) reports whether a given error value matches an +error in another’s chain. - The new function [`Unwrap`](/pkg/errors/#Unwrap) returns the result of calling - `Unwrap` on a given error, if one exists. +The new function [`Unwrap`](/pkg/errors/#Unwrap) returns the result of calling +`Unwrap` on a given error, if one exists. -[fmt](/pkg/fmt/) +#### [fmt](/pkg/fmt/) -: + - The printing verbs `%x` and `%X` now format floating-point and - complex numbers in hexadecimal notation, in lower-case and upper-case respectively. +The printing verbs `%x` and `%X` now format floating-point and +complex numbers in hexadecimal notation, in lower-case and upper-case respectively. - + - The new printing verb `%O` formats integers in base 8, emitting the `0o` prefix. +The new printing verb `%O` formats integers in base 8, emitting the `0o` prefix. - + - The scanner now accepts hexadecimal floating-point values, digit-separating underscores - and leading `0b` and `0o` prefixes. - See the [Changes to the language](#language) for details. +The scanner now accepts hexadecimal floating-point values, digit-separating underscores +and leading `0b` and `0o` prefixes. +See the [Changes to the language](#language) for details. - + - The [`Errorf`](/pkg/fmt/#Errorf) function - has a new verb, `%w`, whose operand must be an error. - The error returned from `Errorf` will have an - `Unwrap` method which returns the operand of `%w`. +The [`Errorf`](/pkg/fmt/#Errorf) function +has a new verb, `%w`, whose operand must be an error. +The error returned from `Errorf` will have an +`Unwrap` method which returns the operand of `%w`. -[go/scanner](/pkg/go/scanner/) +#### [go/scanner](/pkg/go/scanner/) -: - The scanner has been updated to recognize the new Go number literals, specifically - binary literals with `0b`/`0B` prefix, octal literals with `0o`/`0O` prefix, - and floating-point numbers with hexadecimal mantissa. The imaginary suffix `i` may now be used with any number - literal, and underscores may be used as digit separators for grouping. - See the [Changes to the language](#language) for details. + +The scanner has been updated to recognize the new Go number literals, specifically +binary literals with `0b`/`0B` prefix, octal literals with `0o`/`0O` prefix, +and floating-point numbers with hexadecimal mantissa. The imaginary suffix `i` may now be used with any number +literal, and underscores may be used as digit separators for grouping. +See the [Changes to the language](#language) for details. -[go/types](/pkg/go/types/) +#### [go/types](/pkg/go/types/) -: The type-checker has been updated to follow the new rules for integer shifts. - See the [Changes to the language](#language) for details. +The type-checker has been updated to follow the new rules for integer shifts. +See the [Changes to the language](#language) for details. -[html/template](/pkg/html/template/) +#### [html/template](/pkg/html/template/) -: - When using a `