1
0
mirror of https://github.com/golang/go synced 2024-11-26 17:56:55 -07:00
go/doc/go1.8.html

1032 lines
33 KiB
HTML
Raw Normal View History

<!--{
"Title": "Go 1.8 Release Notes",
"Path": "/doc/go1.8",
"Template": true
}-->
<!--
NOTE: In this document and others in this directory, the convention is to
set fixed-width phrases with non-fixed-width spaces, as in
<code>hello</code> <code>world</code>.
Do not send CLs removing the interior tags from such phrases.
-->
<style>
ul li { margin: 0.5em 0; }
</style>
<h2 id="introduction">DRAFT RELEASE NOTES - Introduction to Go 1.8</h2>
<p><strong>
Go 1.8 is not yet released. These are work-in-progress
release notes. Go 1.8 is expected to be released in February 2017.
</strong></p>
<p>
The latest Go release, version 1.8, arrives six months after <a href="go1.7">Go 1.7</a>.
Most of its changes are in the implementation of the toolchain, runtime, and libraries.
There is one minor change to the language specification.
As always, the release maintains the Go 1 <a href="/doc/go1compat.html">promise of compatibility</a>.
We expect almost all Go programs to continue to compile and run as before.
</p>
<p>
The release <a href="#ports">adds support for 32-bit MIPS</a>,
<a href="#compiler">updates the compiler back end</a> to generate more efficient code,
<a href="#gc">reduces GC pauses</a> by eliminating stop-the-world stack rescanning,
<a href="#h2push">adds HTTP/2 Push support</a>,
<a href="#httpshutdown">adds HTTP graceful shutdown</a>,
and <a href="#sort">simplifies sorting slices</a>.
</p>
<h2 id="language">Changes to the language</h2>
<p>
When explicitly converting structs, tags are now ignored for structural type identity.
See <a href="/ref/spec#Conversions">language specification</a> for details.
</p>
<p> <!-- CL 17711 -->
The language specification now only requires that implementations
support up to 16-bit exponents in floating-point constants. This does not affect
either the <code>gc</code> or <code>gccgo</code> compilers, both of
which still support 32-bit exponents.
</p>
<h2 id="ports">Ports</h2>
<p>
Go now supports 32-bit MIPS on Linux for both big-endian
(<code>linux/mips</code>) and little-endian machines
(<code>linux/mipsle</code>).
</p>
<p>
Go now requires DragonFly BSD 4.4.4 or later. <!-- CL 29491 -->
</p>
<p>
The Plan 9 port's networking support is now much more complete
and matches the behavior of Unix and Windows with respect to deadlines
and cancelation.
</p>
<p>
Go 1.8 now only supports OS X 10.8 or later. This is likely the last
Go release to continue supporting 10.8. Compiling Go or running
binaries on older OS X versions is untested.
</p>
<h3 id="known_issues">Known Issues</h3>
<p>
There are some instabilities on FreeBSD and NetBSD that are known but not understood.
These can lead to program crashes in rare cases.
See
<a href="https://golang.org/issue/15658">issue 15658</a>,
<a href="https://golang.org/issue/16396">issue 16396</a>, and
<a href="https://golang.org/issue/16511">issue 16511</a>.
Any help in solving these issues would be appreciated.
</p>
<h2 id="tools">Tools</h2>
<h3 id="cmd_asm">Assembler</h3>
<p>
For 64-bit x86 systems, the following instructions have been added:
<code>VBROADCASTSD</code>,
<code>BROADCASTSS</code>,
<code>MOVDDUP</code>,
<code>MOVSHDUP</code>,
<code>MOVSLDUP</code>,
<code>VMOVDDUP</code>,
<code>VMOVSHDUP</code>,
and <code>VMOVSLDUP</code>.</p>
<p>
For 64-bit PPC systems, the common vector scalar instructions have been
added:
<code>LXS</code>,
<code>LXSDX</code>,
<code>LXSI</code>,
<code>LXSIWAX</code>,
<code>LXSIWZX</code>,
<code>LXV</code>,
<code>LXVD2X</code>,
<code>LXVDSX</code>,
<code>LXVW4X</code>,
<code>MFVSR</code>,
<code>MFVSRD</code>,
<code>MFVSRWZ</code>,
<code>MTVSR</code>,
<code>MTVSRD</code>,
<code>MTVSRWA</code>,
<code>MTVSRWZ</code>,
<code>STXS</code>,
<code>STXSDX</code>,
<code>STXSI</code>,
<code>STXSIWX</code>,
<code>STXV</code>,
<code>STXVD2X</code>,
<code>STXVW4X</code>,
<code>XSCV</code>,
<code>XSCVDPSP</code>,
<code>XSCVDPSPN</code>,
<code>XSCVDPSXDS</code>,
<code>XSCVDPSXWS</code>,
<code>XSCVDPUXDS</code>,
<code>XSCVDPUXWS</code>,
<code>XSCVSPDP</code>,
<code>XSCVSPDPN</code>,
<code>XSCVSXDDP</code>,
<code>XSCVSXDSP</code>,
<code>XSCVUXDDP</code>,
<code>XSCVUXDSP</code>,
<code>XSCVX</code>,
<code>XSCVXP</code>,
<code>XVCV</code>,
<code>XVCVDPSP</code>,
<code>XVCVDPSXDS</code>,
<code>XVCVDPSXWS</code>,
<code>XVCVDPUXDS</code>,
<code>XVCVDPUXWS</code>,
<code>XVCVSPDP</code>,
<code>XVCVSPSXDS</code>,
<code>XVCVSPSXWS</code>,
<code>XVCVSPUXDS</code>,
<code>XVCVSPUXWS</code>,
<code>XVCVSXDDP</code>,
<code>XVCVSXDSP</code>,
<code>XVCVSXWDP</code>,
<code>XVCVSXWSP</code>,
<code>XVCVUXDDP</code>,
<code>XVCVUXDSP</code>,
<code>XVCVUXWDP</code>,
<code>XVCVUXWSP</code>,
<code>XVCVX</code>,
<code>XVCVXP</code>,
<code>XXLAND</code>,
<code>XXLANDC</code>,
<code>XXLANDQ</code>,
<code>XXLEQV</code>,
<code>XXLNAND</code>,
<code>XXLNOR</code>,
<code>XXLOR</code>,
<code>XXLORC</code>,
<code>XXLORQ</code>,
<code>XXLXOR</code>,
<code>XXMRG</code>,
<code>XXMRGHW</code>,
<code>XXMRGLW</code>,
<code>XXPERM</code>,
<code>XXPERMDI</code>,
<code>XXSEL</code>,
<code>XXSI</code>,
<code>XXSLDWI</code>,
<code>XXSPLT</code>, and
<code>XXSPLTW</code>.
</p>
<h3 id="tool_yacc">Yacc</h3>
<p> <!-- CL 27324, CL 27325 -->
The <code>yacc</code> tool (previously available via
<code>go</code> <code>tool</code> <code>yacc</code>”)
has been removed. As of Go 1.7 it was no longer used by the Go compiler.
It has moved to the “tools” repository and is and is available via
<code>go</code> <code>get</code> <code><a href="https://godoc.org/golang.org/x/tools/cmd/goyacc">golang.org/x/tools/cmd/goyacc</a></code>.
</p>
<h3 id="compiler">Compiler Toolchain</h3>
<p>
Go 1.7 introduced a new compiler back end for 64-bit x86 systems.
In Go 1.8, that back end has been developed further and is now used for
all architectures.
</p>
<p>
The new back end, based on
<a href="https://en.wikipedia.org/wiki/Static_single_assignment_form">SSA</a>,
generates more compact, more efficient code
and provides a better platform for optimizations
such as bounds check elimination.
The new back end reduces the CPU time required by
<a href="https://golang.org/test/bench/go1/">our benchmark programs</a> by N-M%.
TODO: ARM binary size & perf numbers.
</p>
<p>
The temporary <code>-ssa=0</code> compiler flag introduced in Go 1.7
to disable the new backend has been removed in Go 1.8.
</p>
<p>
In addition to enabling the new compiler back end for all systems,
Go 1.8 also introduces a new compiler front end. The new compiler
front end should not be noticeable to users is the foundation for
future performance work.
</p>
<p>
The compiler and linker have been optimized and run faster in this
release than in Go 1.7, although they are still slower than we would
like and will continue to be optimized in future releases.
</p>
<p>
Due to changes across the compiler toolchain and standard library,
binaries built with this release should typically be smaller than
binaries built with Go 1.7, sometimes by as much as TODO numbers.
</p>
<h3 id="cmd_cgo">Cgo</h3>
<p>TODO</p>
<h3 id="gccgo">Gccgo</h3>
<p>TODO</p>
<h3 id="cmd_go">Go command</h3>
<p>
The <a href="/cmd/go/"><code>go</code></a> command's basic operation
is unchanged, but there are a number of changes worth noting.
</p>
<p>
A new
<a href="/cmd/go/#hdr-Print_information_for_bug_reports"><code>go</code>
<code>bug</code></a>” command helps users file bug reports.
</p>
<h3 id="cmd_doc">Go doc</h3>
<p> <!-- CL 25419 -->
The
<a href="/cmd/go/#hdr-Show_documentation_for_package_or_symbol"><code>go</code>
<code>doc</code></a>” command
now groups constants and variables with their type,
following the behavior of
<a href="/cmd/godoc/"><code>godoc</code></a>.
</p>
<p> <!-- CL 25420 -->
In order to improve the readability of the <code>doc</code>'s
output, each summary of the first-level items is guaranteed to
occupy a single line.
</p>
<p> <!-- CL 31852 -->
Documentation for interface methods is now only shown when requested
explicitly.
</p>
<h3 id="plugin">Plugins</h3>
<p>
Go now supports a “<code>plugin</code>” build mode for generating
plugins written in Go, and a
new <a href="/pkg/plugin/"><code>plugin</code></a> package for
loading such plugins at run time. Plugin support is only currently
available on Linux and macOS.
</p>
<h2 id="runtime">Runtime</h2>
<h3 id="liveness">Argument Liveness</h3>
<p>
<!-- Issue 15843 --> The garbage collector no longer considers
arguments live throughout the entirety of a function. For more
information, and for how to force a variable to remain live, see
the <a href="/pkg/runtime/#KeepAlive"><code>runtime.KeepAlive</code></a>
function added in Go 1.7.
</p>
<h3 id="memstats">MemStats Documentation</h3>
<p> <!-- CL 28972 -->
The runtime's <a href="/pkg/runtime/#MemStats"><code>MemStats</code></a>
type has been more thoroughly documented.
</p>
<h2 id="performance">Performance</h2>
<p>
As always, the changes are so general and varied that precise statements
about performance are difficult to make.
Most programs should run a bit faster,
due to speedups in the garbage collector and
optimizations in the standard library.
</p>
<p>
There have been significant optimizations bringing more than 10% improvements
to implementations in the
TODO TODO:
<a href="/pkg/foo/"><code>foo</code></a>,
<a href="/pkg/bar/"><code>bar</code></a>,
and
<a href="/pkg/quux/"><code>quux</code></a>
packages.
</p>
<h3 id="gc">Garbage Collector</h3>
<p>
Garbage collection pauses should be significantly shorter than they
were in Go 1.7, often as low as 10 microseconds and usually under 100
microseconds.
See the
<a href="https://github.com/golang/proposal/blob/master/design/17503-eliminate-rescan.md"
>document on eliminating stop-the-world stack re-scanning</a>
for details. More work remains for Go 1.9.
</p>
<h3 id="defer">Defer</h3>
<!-- CL 29656, CL 29656 -->
<p>
The overhead of <a href="/ref/spec/#Defer_statements">deferred
function calls</a> has been reduced by half.
</p>
<h3 id="cgoperf">Cgo</h3>
<p>Calls from Go into C are now TODO% faster.</p>
<h2 id="library">Standard library</h2>
<h3 id="examples">Examples</h3>
<p>
Examples have been added to the documentation across many packages.
</p>
<h3 id="sortslice">Sort</h3>
<p>
The <a href="/pkg/sort/">sort</a> package
now includes a convenience function
<a href="/pkg/sort/#Slice"><code>Slice</code></a> to sort a
slice given a <em>less</em> function.
In many cases this means that writing a new sorter type is not
necessary.
</p>
<p>
Also new are
<a href="/pkg/sort/#SliceStable"><code>SliceStable</code></a> and
<a href="/pkg/sort/#SliceIsSorted"><code>SliceIsSorted</code></a>.
</p>
<h3 id="h2push">HTTP/2 Push</h3>
<p>
The <a href="/pkg/net/http/">net/http</a> package now includes a
mechanism to
send HTTP/2 server pushes from a
<a href="/pkg/net/http/#Handler"><code>Handler</code></a>.
Similar to the existing <code>Flusher</code> and <code>Hijacker</code>
interfaces, an HTTP/2
<a href="/pkg/net/http/#ResponseWriter"><code>ResponseWriter</code></a>
now implements the new
<a href="/pkg/net/http/#Pusher"><code>Pusher</code></a> interface.
</p>
<h3 id="http_shutdown">HTTP Server Graceful Shutdown</h3>
<p> <!-- CL 32329 -->
The HTTP Server now has support for graceful shutdown using the new
<a href="/pkg/net/http/#Server.Shutdown"><code>Server.Shutdown</code></a>
method. The related and more abrupt
<a href="/pkg/net/http/#Server.Close"><code>Server.Close</code></a>
is also new.
</p>
<h3 id="minor_library_changes">Minor changes to the library</h3>
<p>
As always, there are various minor changes and updates to the library,
made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a>
in mind.
</p>
<dl id="archive_tar"><dt><a href="/pkg/archive/tar/">archive/tar</a></dt>
<dd>
<p> <!-- CL 28471, CL 31440, CL 31441, CL 31444, CL 28418, CL 31439 -->
The tar implementation corrects many bugs in corner cases of the file format.
The <a href="/pkg/archive/tar/#Reader"><code>Reader</code></a>
is now able to process tar files in the PAX format with entries larger than 8GB.
The <a href="/pkg/archive/tar/#Writer"><code>Writer</code></a>
no longer produces invalid tar files in some situations involving long pathnames.
</p>
</dd>
</dl>
<dl id="archive_zip"><dt><a href="/pkg/archive/zip/">archive/zip</a></dt>
<dd>
<p> <!-- CL 18274 -->
The zip <code>Reader</code> now supports modification times in
the NTFS, UNIX, and Extended Time Stamp metadata fields.
<!-- CL 30811 -->
When writing zip files, the Extended Time Stamp field is written
if TODO: validate implementation.
</p>
</dd>
</dl>
<dl id="compress_flate"><dt><a href="/pkg/compress/flate/">compress/flate</a></dt>
<dd>
<p> <!-- CL 31640, CL 31174, CL 32149 -->
There have been some minor fixes to the encoder to improve the
compression ratio in certain situations. As a result, the exact
encoded output of <code>DEFLATE</code> may be different from Go 1.7. Since
DEFLATE is the underlying compression of gzip, png, zlib, and zip,
those formats may have changed outputs.
</p>
<p>
The encoder, when operating in
<a href="/pkg/compress/flate/#NoCompression"><code>NoCompression</code></a>
mode, now produces a consistent output that is not dependent on
the size of the slices passed to the
<a href="/pkg/compress/flate/#Writer.Write"><code>Write</code></a>
method.
</p>
<p> <!-- CL 28216 -->
The decoder, upon encountering an error, now returns any
buffered data it had uncompressed along with the error.
</p>
</dd>
</dl>
<dl id="compress_gzip"><dt><a href="/pkg/compress/gzip/">compress/gzip</a></dt>
<dd>
<p>
The <a href="/pkg/compress/gzip/#Writer"><code>Writer</code></a>
now encodes a zero <code>MTIME</code> field when
the <a href="/pkg/compress/gzip/#Header"><code>Header.ModTime</code></a>
field is the zero value.
In previous releases of Go, the <code>Writer</code> would encode
a nonsensical value.
Similarly,
the <a href="/pkg/compress/gzip/#Reader"><code>Reader</code></a>
now updates the <code>Header.ModTime</code> field only if the
encoded <code>MTIME</code> field is non-zero.
</p>
</dd>
</dl>
<dl id="context"><dt><a href="/pkg/context/">context</a></dt>
<dd>
<p> <!-- CL 30370 -->
The <a href="/pkg/context#DeadlineExceeded"><code>DeadlineExceeded</code></a>
error now implements
<a href="/pkg/net/#Error"><code>net.Error</code></a>
and reports true for both the <code>Timeout</code> and
<code>Temporary</code> methods.
</p>
</dd>
</dl>
<dl id="database_sql"><dt><a href="/pkg/database/sql/">database/sql</a></dt>
<dd>
<p>
The package now supports <code>context.Context</code>. There are new methods
ending in <code>Context</code> such as
<a href="/pkg/database/sql/#DB.QueryContext"><code>DB.QueryContext</code></a> and
<a href="/pkg/database/sql/#DB.PrepareContext"><code>DB.PrepareContext</code></a>
that support <code>Context</code>. By using the new <code>Context</code> methods it ensures
connections are closed and returned to the connection pool when the
request is done. It also enables canceling in-progress queries
should the driver support it. Finally, using the <code>Context</code>
methods allows the database pool to cancel waiting for the next
available connection.
</p>
<p>
The <a href="/pkg/database/sql#IsolationLevel"><code>IsolationLevel</code></a>
can now be set when starting a transaction by setting the isolation level
on the <code>Context</code> then passing that <code>Context</code> to
<a href="/pkg/database/sql#DB.BeginContext"><code>DB.BeginContext</code></a>.
An error will be returned if an isolation level is selected that the driver
does not support. A read-only attribute may also be set on the transaction
with <a href="/pkg/database/sql/#ReadOnlyContext"><code>ReadOnlyContext</code></a>
</p>
<p>
Queries now expose the SQL column type information for drivers that support it.
Rows can return <a href="/pkg/database/sql#Rows.ColumnTypes"><code>ColumnTypes</code></a>
which can include SQL type information, column type lengths, and the Go type.
</p>
<p>
Multiple result sets are now supported on Rows. After
<a href="/pkg/database/sql/#Rows.Next"><code>Rows.Next</code></a> returns false
<a href="/pkg/database/sql/#Rows.NextResultSet"><code>Rows.NextResultSet</code></a>
may be called to advance to the next result set. The existing <code>Rows</code>
should be continued to be used after it advances to the next result set.
</p>
<p>
<a href="/pkg/database/sql/#NamedParam"><code>NamedParam</code></a> may be used
as query arguments. The new function <a href="/pkg/database/sql/#Param"><code>Param</code></a>
helps create a <a href="/pkg/database/sql/#NamedParam"><code>NamedParam</code></a>
more succinctly.
<p>
Drivers that support the new <a href="/pkg/database/sql/driver/#Pinger"><code>Pinger</code></a>
interface can now check if the server is still alive when the the
<a href="/pkg/database/sql/#DB.Ping"><code>DB.Ping</code></a>
or <a href="/pkg/database/sql/#DB.PingContext"><code>DB.PingContext</code></a>
is called.
</p>
<p>
The new <code>Context</code> query methods work for all drivers, but
<code>Context</code> cancelation is not responsive unless the driver has been
updated to used them. The other features require driver support in
<a href="/pkg/database/sql/driver"><code>database/sql/driver</code></a>.
Driver authors should review the new interfaces. Users of existing
driver should review the driver documentation to see what
it supports and any system specific documentation on each feature.
</p>
</dd>
</dl>
<dl id="debug_pe"><dt><a href="/pkg/debug/pe/">debug/pe</a></dt>
<dd>
<p> <!-- CL 22720, CL 27212, CL 22181, CL 22332, CL 22336, Issue 15345 -->
TODO: describe Issue 15345 and CL 22181, CL 22332, CL 22336
<pre>pkg debug/pe, method (*COFFSymbol) FullName(StringTable) (string, error)
pkg debug/pe, method (StringTable) String(uint32) (string, error)
pkg debug/pe, type File struct, COFFSymbols []COFFSymbol
pkg debug/pe, type File struct, StringTable StringTable
pkg debug/pe, type Reloc struct
pkg debug/pe, type Reloc struct, SymbolTableIndex uint32
pkg debug/pe, type Reloc struct, Type uint16
pkg debug/pe, type Reloc struct, VirtualAddress uint32
pkg debug/pe, type Section struct, Relocs []Reloc
pkg debug/pe, type StringTable []uint8</pre>
</p>
</dd>
</dl>
<dl id="encoding_base64"><dt><a href="/pkg/encoding/base64/">encoding/base64</a></dt>
<dd>
<p> <!-- CL 24964 -->
The new
<a href="/pkg/encoding/base64/#Encoding.Strict"><code>Encoding.Strict</code></a>
method returns an <code>Encoding</code> that causes the decoder
to return an error when the trailing padding bits are not zero.
</p>
</dd>
</dl>
<dl id="encoding_binary"><dt><a href="/pkg/encoding/binary/">encoding/binary</a></dt>
<dd>
<p> <!-- CL 28514 -->
The package now supports boolean values.
TODO: add docs in encoding/binary package, then link to package docs
here.
</p>
</dd>
</dl>
<dl id="encoding_json"><dt><a href="/pkg/encoding/json/">encoding/json</a></dt>
<dd>
<p> <!-- CL 18692 -->
<a href="/pkg/encoding/json/#UnmarshalTypeError"><code>UnmarshalTypeError</code></a>
now includes the struct and field name.
</p>
<p> <!-- CL 31932 -->
A <code>nil</code> <a href="/pkg/encoding/json/#Marshaler"><code>Marshaler</code></a>
now marshals as a JSON "<code>null</code>" value.
</p>
<p> <!-- CL 21811 -->
A <a href="/pkg/encoding/json/#RawMessage"><code>RawMessage</code></a> value now
marshals the same as its pointer type.
</p>
<p> <!-- CL 30371 -->
Marshal encodes floating-point numbers using the same format as in ES6,
preferring decimal (not exponential) notation for a wider range of values.
In particular, all floating-point integers up to 2<sup>64</sup> format the
same as the equivalent <code>int64</code> representation.
</p>
<p> <!-- CL 30944 -->
Implementations
of <a href="/pkg/encoding/json/#Unmarshaler"><code>Unmarshaler</code></a>
are now called with the literal "<code>null</code>" and can
decide how to handle it.
</p>
</dd>
</dl>
<dl id="encoding_pem"><dt><a href="/pkg/encoding/pem/">encoding/pem</a></dt>
<dd>
<p> <!-- CL 27391 -->
The PEM decoder is now strict about the format of the ending line.
</p>
</dd>
</dl>
<dl id="expvar"><dt><a href="/pkg/expvar/">expvar</a></dt>
<dd>
<p> <!-- CL 30917 -->
The new methods
<a href="/pkg/expvar/#Int.Value"><code>Int.Value</code></a>,
<a href="/pkg/expvar/#String.Value"><code>String.Value</code></a>,
<a href="/pkg/expvar/#Float.Value"><code>Float.Value</code></a>, and
<a href="/pkg/expvar/#Func.Value"><code>Func.Value</code></a>
report the current value of an exported variable.
</p>
<p> <!-- CL 24722 -->
The new
function <a href="/pkg/expvar/#Handler"><code>Handler</code></a>
returns the package's HTTP handler, to enable installing it in
non-standard locations.
</p>
</dd>
</dl>
<dl id="image_png"><dt><a href="/pkg/image/png/">image/png</a></dt>
<dd>
<p> <!-- CL 32143, CL 32140 -->
The PNG decoder now supports truecolor and grayscale transparency.
</p>
<p> <!-- CL 29872 -->
The PNG encoder is now faster and creates smaller output
when encoding paletted images.
</p>
</dd>
</dl>
<dl id="math_rand"><dt><a href="/pkg/math/rand/">math/rand</a></dt>
<dd>
<p><!-- CL 27253, CL 33456 -->
The new <a href="/pkg/math/rand/#Rand.Uint64"><code>Rand.Uint64</code></a>
method returns <code>uint64</code> values. The
new <a href="/pkg/math/rand/#Rand.Source64"><code>Rand.Source64</code></a>
interface describes sources capable of generating such values
directly; otherwise the <code>Rand.Uint64</code> method
constructs a <code>uint64</code> from two calls
to <code>Rand.Source</code>'s <code>Int63</code> method.
</p>
</dd>
</dl>
<dl id="mime_quotedprintable"><dt><a href="/pkg/mime/quotedprintable/">mime/quotedprintable</a></dt>
<dd>
<p>
The package's parsing has been relaxed in two ways to accept
more input seen in the wild. First, it now accepts
a <code>=</code> sign even if it's not followed by two hex
digits. <!-- CL 32174 -->
Second, it accepts a trailing soft line-break at the end of a
message. <!-- CL 27530 -->. That is, the final byte of the
message may be a <code>=</code> sign and it will now be ignored.
</p>
</dd>
</dl>
<dl id="net_http"><dt><a href="/pkg/net/http/">net/http</a></dt>
<dd>
<p>Server changes:</p>
<ul>
<li>The server now supports graceful shutdown support, <a href="#http_shutdown">mentioned above</a>.</li>
<li> <!-- CL 32024 -->
The <a href="/pkg/net/http/#Server"><code>Server</code></a>
adds configuration options
<code>ReadHeaderTimeout</code> and <code>IdleTimeout</code>
and documents <code>WriteTimeout</code>.
</li>
<li> <!-- CL 32014 -->
<a href="/pkg/net/http/#FileServer"><code>FileServer</code></a>
and
<a href="/pkg/net/http/#ServeContent"><code>ServeContent</code></a>
now support HTTP <code>If-Match</code> conditional requests,
in addition to the previous <code>If-None-Match</code>
support.
</li>
<li> <!-- CL 27950 -->
The server now logs bad requests.
</li>
</ul>
<p>
There are several additions to what a server's <code>Handler</code> can do:
</p>
<ul>
<li><!-- CL 31173 -->
The <a href="/pkg/context/#Context"><code>Context</code></a>
returned
by <a href="/pkg/net/http/#Request.Context"><code>Request.Context</code></a>
is canceled if the underlying <code>net.Conn</code>
closes. For instance, if the user closes their browser in the
middle of a slow request, the <code>Handler</code> can now
detect that the user is gone. This complements the
existing <a href="/pkg/net/http/#CloseNotifier"><code>CloseNotifier</code></a>
support.
</li>
<li><!-- CL 32479 -->
To serve trailers known after the header has been written,
see the new
<a href="/pkg/net/http/#TrailerPrefix"><code>TrailerPrefix</code></a>
mechanism.
</li>
<li><!-- CL 33099 -->
A <code>Handler</code> can now abort a response by panicking
with the error
<a href="/pkg/net/http/#ErrAbortHandler"><code>ErrAbortHandler</code></a>.
</li>
<li><!-- CL 30812 -->
A <code>Write</code> of zero bytes to a
<a href="/pkg/net/http/#ResponseWriter"><code>ResponseWriter</code></a>
is now defined as a
way to test whether a <code>ResponseWriter</code> has been hijacked:
if so, the <code>Write</code> returns
<a href="/pkg/net/http/#ErrHijacked"><code>ErrHijacked</code></a>
without printing an error
to the server's error log.
</li>
</ul>
<p>Client &amp; Transport changes:</p>
<ul>
<li><!-- CL 28930 -->
The <a href="/pkg/net/http/#Client"><code>Client</code></a>
now copies most request headers on redirect. Authentication-specific
headers are only sent to the same origin or subdomains thereof.
Cookies are not sent again, unless they were set explicitly.
TODO: verify this, and link to docs once https://github.com/golang/go/issues/18096
is fixed.
</li>
<li><!-- CL 29072 -->
The <a href="/pkg/net/http/#Transport"><code>Transport</code></a>
now supports international domain names. Consequently, so do
<a href="/pkg/net/http/#Get">Get</a> and other helpers.
</li>
<li><!-- CL 31733, CL 29852 -->
The <code>Client</code> now supports 307 and 308 redirects.
If the redirect requires resending the request body,
the request must have the new
<a href="/pkg/net/http/#Request"><code>Request.GetBody</code></a>
field defined.
<a href="pkg/net/http/#NewRequest"><code>NewRequest</code></a>
sets <code>Request.GetBody</code> automatically for common
body types.
</li>
<li><!-- CL 32482 -->
The <code>Transport</code> now rejects requests for URLs with
ports containing non-digit characters.
</li>
<li><!-- CL 27117 -->
The <code>Transport</code> will now retry non-idempotent
requests if no bytes were written before a network failure.
</li>
<li><!-- CL 32481 -->
The
new <a href="/pkg/net/http/#Transport"><code>Transport.ProxyConnectHeader</code></a>
allows configuration of header values to send to a proxy
during a <code>CONNECT</code> request.
</li>
<li> <!-- CL 28077 -->
The <a href="/pkg/net/http/#DefaultTransport"><code>DefaultTransport.Dialer</code></a>
now enables <code>DualStack</code> ("<a href="https://tools.ietf.org/html/rfc6555">Happy Eyeballs</a>") support,
to use IPv4 as a backup if it looks like IPv6 might be
failing.
</li>
</ul>
</dd>
</dl>
<dl id="net_mail"><dt><a href="/pkg/net/mail/">net/mail</a></dt>
<dd>
<p> <!-- CL 32176 -->
Empty quoted strings are once again allowed in the name part of
an address. That is, Go 1.4 and earlier accepted
<code>"" &lt;gopher@example.com&gt;</code>,
but Go 1.5 introduced a bug that rejected this address.
The address is recognized again.
</p>
<p> <!-- CL 31581 -->
The
<a href="/pkg/net/mail/#Header.Date"><code>Header.Date</code></a>
method has always provided a way to parse
the <code>Date:</code> header.
A new function
<a href="/pkg/net/mail/#ParseDate"><code>ParseDate</code></a>
allows parsing dates found in other
header lines, such as the <code>Resent-Date:</code> header.
</p>
</dd>
</dl>
<dl id="net_smtp"><dt><a href="/pkg/net/smtp/">net/smtp</a></dt>
<dd>
<p> <!-- CL 33143 -->
If an implementation of
the <a href="/pkg/net/smtp/#Auth"><code>Auth</code></a>
interface's <code>Start</code> method returns an
empty <code>toServer</code> value, the package no longer sends
trailing whitespace in the SMTP <code>AUTH</code> command,
which some servers rejected.
</p>
</dd>
</dl>
<dl id="net_url"><dt><a href="/pkg/net/url/">net/url</a></dt>
<dd>
<p> <!-- CL 31322 --> The new functions
<a href="/pkg/net/url/#PathEscape"><code>PathEscape</code></a>
and
<a href="/pkg/net/url/#PathUnescape"><code>PathUnescape</code></a>
are similar to the query escaping and unescaping functions but
for path elements.</p>
<p> <!-- CL 28933 --> The new methods
<a href="/pkg/net/url/#URL.Hostname"><code>URL.Hostname</code></a>
and
<a href="/pkg/net/url/#URL.Port"><code>URL.Port</code></a>
are accessors to the hostname and port fields of a URL
and deal with the case where the port may or may not be present.
</p>
<p> <!-- CL 28343 --> The existing method
<a href="/pkg/net/url/#URL.ResolveReference"><code>URL.ResolveReference</code></a>
now properly handles paths with escaped bytes without losing
the escaping.
</p>
<p> <!-- CL 31467 -->
The <code>URL</code> type now implements
<a href="/pkg/encoding/#BinaryMarshaler"><code>encoding.BinaryMarshaler</code></a> and
<a href="/pkg/encoding/#BinaryUnmarshaler"><code>encoding.BinaryUnmarshaler</code></a>,
making it possible to process URLs in <a href="/pkg/encoding/gob/">gob data</a>.
</p>
<p> <!-- CL 29610, CL 31582 -->
Following RFC 3986,
<a href="/pkg/net/url/#Parse"><code>Parse</code></a>
now rejects URLs like <code>this_that:other/thing</code> instead of
interpreting them as relative paths (<code>this_that</code> is not a valid scheme).
To force interpretation as a relative path,
such URLs should be prefixed with <code>"./"</code>.
The <code>URL.String</code> method now inserts this prefix as needed.
</p>
</dd>
</dl>
<dl id="os"><dt><a href="/pkg/os/">os</a></dt>
<dd>
<p>
The new function
<a href="/pkg/os/#Executable"><code>Executable</code></a> returns
the running executable path name.
</p>
</dd>
</dl>
<dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt>
<dd>
<p> <!-- CL 30088 -->
The new function
<a href="/pkg/reflect/#Swapper"><code>Swapper</code></a> was
added to support <a href="#sortslice"><code>sort.Slice</code></a>.
</p>
</dd>
</dl>
<dl id="strconv"><dt><a href="/pkg/strconv/">strconv</a></dt>
<dd>
<p> <!-- CL 31210 -->
The <a href="/pkg/strconv/#Unquote"><code>Unquote</code></a>
function now strips carriage returns (<code>\r</code>) in
backquoted raw strings, following the
<a href="/ref/spec#String_literals">Go language semantics</a>.
</p>
</dd>
</dl>
<dl id="time"><dt><a href="/pkg/time/">time</a></dt>
<dd>
<p> <!-- CL 20118 --> The new function
<a href="/pkg/time/#Until"><code>Until</code></a> complements
the analogous <code>Since</code> function.
</p>
<p> <!-- CL 29338 -->
<a href="/pkg/time/#ParseDuration"><code>ParseDuration</code></a>
now accepts long fractional parts.
</p>
<p> <!-- CL 33429 -->
<code>Parse</code> now validates days that are too small, in
addition to days that are too large.
</p>
<p> <!-- CL 33029 -->
The <code>tzdata</code> database has been updated to version
2016i for systems that don't already have a local time zone
database.
</p>
<p>
</dd>
</dl>
<dl id="testing"><dt><a href="/pkg/testing/">testing</a></dt>
<dd>
<p><!-- CL 29970 -->
The new method
<a href="/pkg/testing/#T.Name"><code>T.Name</code></a>
(and <code>B.Name</code>) returns the name of the current
test or benchmark.
</p>
<p><!-- CL 31724 -->
The new method
<a href="/pkg/testing/#T.Context"><code>T.Context</code></a>
(and <code>B.Context</code>) returns
a <a href="/pkg/context/#Context"><code>Context</code></a> for
the current running test or benchmark.
</p>
<p><!-- CL 32483 -->
The new function
<a href="/pkg/testing/#CoverMode"><code>CoverMode</code></a>
reports the test coverage mode.
</p>
<p><!-- CL 32615 -->
Tests and benchmarks are now marked as failed if the race
detector is enabled and a data race occurs during execution.
Previously, individual test cases would appear to pass,
and only the overall execution of the test binary would fail.
</p>
</dd>
</dl>
<dl id="unicode"><dt><a href="/pkg/unicode/">unicode</a></dt>
<dd>
<p><!-- CL 30935 -->
<code>SimpleFold</code> now returns its argument unchanged
if the provided input was an invalid rune.
Previously, the implementation failed with an index bounds check panic.
</p>
</dd>
</dl>