go1.8.html 54.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
<!--{
	"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.
28
There are <a href="#language">two minor changes</a> to the language specification.
29 30 31 32 33 34 35 36 37
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>,
38
<a href="#http_shutdown">adds HTTP graceful shutdown</a>,
Brad Fitzpatrick's avatar
Brad Fitzpatrick committed
39 40
<a href="#more_context">adds more context support</a>,
<a href="#mutex_prof">enables profiling mutexes</a>,
41
and <a href="#sort_slice">simplifies sorting slices</a>.
42 43 44 45 46
</p>

<h2 id="language">Changes to the language</h2>

<p>
47 48 49
  When explicitly converting a value from one struct type to another,
  as of Go 1.8 the tags are ignored. Thus two structs that differ
  only in their tags may be converted from one to the other:
50 51
</p>

52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
<pre>
func example() {
	type T1 struct {
		X int `json:"foo"`
	}
	type T2 struct {
		X int `json:"bar"`
	}
	var v1 T1
	var v2 T2
	v1 = T1(v2) // now legal
}
</pre>


67 68
<p> <!-- CL 17711 -->
  The language specification now only requires that implementations
69
  support up to 16-bit exponents in floating-point constants.  This does not affect
70 71
  either the “<a href="/cmd/compile/"><code>gc</code></a>” or
  <code>gccgo</code> compilers, both of
72
  which still support 32-bit exponents.
73 74 75 76 77 78 79
</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
80 81 82
(<code>linux/mipsle</code>) that implement the MIPS32r1 instruction set with FPU
or kernel FPU emulation. Note that many common MIPS-based routers lack an FPU and
have firmware that doesn't enable kernel FPU emulation; Go won't run on such machines.
83 84 85
</p>

<p>
86
On DragonFly BSD, Go now requires DragonFly 4.4.4 or later. <!-- CL 29491, CL 29971 -->
87 88 89 90 91 92 93 94
</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>

95 96
<p>
  Go 1.8 now only supports OS X 10.8 or later. This is likely the last
97
  Go release to support 10.8. Compiling Go or running
98 99 100
  binaries on older OS X versions is untested.
</p>

101 102 103 104 105 106 107 108 109 110 111
<p>
  Go 1.8 will be the last release to support Linux on ARMv5E and ARMv6 processors:
  Go 1.9 will likely require the ARMv6K (as found in the Raspberry Pi 1) or later.
  To identify whether a Linux system is ARMv6K or later, run <code>go tool dist -check-armv6k</code>
  (to facilitate testing, it is also possible to just copy the dist command to the
  system without installing a full copy of Go 1.8)
  and if the program terminates with output "ARMv6K supported." then the system
  implements ARMv6K or later.
  Go on non-Linux ARM systems already requires ARMv6K or later.
</p>

112 113 114 115

<h3 id="known_issues">Known Issues</h3>

<p>
116
There are some instabilities on FreeBSD and NetBSD that are known but not understood.
117 118
These can lead to program crashes in rare cases.
See
119 120 121 122
<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.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
</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
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
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>.
222 223 224 225
</p>

<h3 id="tool_yacc">Yacc</h3>

226
<p> <!-- CL 27324, CL 27325 -->
227
The <code>yacc</code> tool (previously available by running
228 229
<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.
230 231
It has moved to the “tools” repository and is now available at
<code><a href="https://godoc.org/golang.org/x/tools/cmd/goyacc">golang.org/x/tools/cmd/goyacc</a></code>.
232 233
</p>

234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
<h3 id="tool_fix">Fix</h3>

<p> <!-- CL 28872 -->
  The <code>fix</code> tool has a new “<code>context</code>
  fix to change imports from “<code>golang.org/x/net/context</code>
  to “<a href="/pkg/context/"><code>context</code></a>”.
</p>

<h3 id="tool_pprof">Pprof</h3>

<p> <!-- CL 33157 -->
  The <code>pprof</code> tool can now profile TLS servers
  and skip certificate validation by using the "<code>https+insecure</code>"
  URL scheme.
</p>

<p> <!-- CL 23781 -->
  The callgrind output now has instruction-level granularity.
</p>

<p>
  TODO: more. proto? standalone profiles with symbols?
Brad Fitzpatrick's avatar
Brad Fitzpatrick committed
256 257 258 259
<pre>
runtime/pprof: output CPU profiles in pprof protobuf format (CL 33071)
runtime/pprof: write profiles in protobuf format. (CL 32257)
</pre>
260 261 262 263 264 265 266 267 268 269
</p>

<h3 id="tool_trace">Trace</h3>

<p>TODO:</p>
<pre>
cmd/trace: add option to output pprof files (CL 23324)
cmd/trace: fix a runnable goroutine count bug (CL 25552)
cmd/trace: move process-wide GC events to their own row (CL 30017)
internal/trace: fix analysis of EvGoWaiting/EvGoInSyscall events (CL 25572)
Brad Fitzpatrick's avatar
Brad Fitzpatrick committed
270
cmd/trace: annotate different mark worker types (CL 30702)
271 272 273 274
</pre>

<h3 id="tool_vet">Vet</h3>

275 276
<p>Vet is stricter in some ways and looser where it
  previously caused false positives.</p>
277 278 279 280 281 282 283 284 285

<p>Vet now checks copying of array of locks,
  duplicate JSON and XML struct field tags,
  non-space-separated struct tags,
  deferred calls to HTTP <code>Response.Body.Close</code>
  before checking errors,
  indexed arguments in <code>Printf</code>,
  and improves existing checks.</p>
</p>
286

287 288 289 290 291 292 293 294 295 296
<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
297
<a href="https://en.wikipedia.org/wiki/Static_single_assignment_form">static single assignment form</a> (SSA),
298 299 300 301
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
302 303 304 305
<a href="https://golang.org/test/bench/go1/">our benchmark programs</a> by 20-30%
on 32-bit ARM systems. For 64-bit x86 systems, which already used the SSA backend in
Go 1.7, the gains are a more modest 0-10%. Other architectures will likely
see improvements closer to the 32-bit ARM numbers.
306 307 308
</p>

<p>
309 310
  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.
311 312 313
</p>

<p>
314 315
  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
316
  front end should not be noticeable to users but is the foundation for
317 318 319 320 321 322 323
  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.
324 325
  Compared to the previous release, Go 1.8 is
  <a href="https://dave.cheney.net/2016/11/19/go-1-8-toolchain-improvements">about 15% faster</a>.
326 327 328 329
</p>

<h3 id="cmd_cgo">Cgo</h3>

330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
<p> <!-- CL 29991 -->
The environment variable <code>PKG_CONFIG</code> may now be used to
set the program to run to handle <code>#cgo pkg-config</code>
directives.  The default is <code>pkg-config</code>, the program
always used by earlier releases.  This is intended to make it easier
to cross-compile
<a href="/cmd/cgo/">cgo</a> code.
</p>

<p> <!-- CL 32354 -->
The <a href="/cmd/cgo/">cgo</a> tool now supports a <code>-srcdir</code>
option, which is used by the <a href="/cmd/go/">go</a> command.
</p>

<p> <!-- CL 31768, 31811 -->
If <a href="/cmd/cgo/">cgo</a> code calls <code>C.malloc</code>, and
<code>malloc</code> returns <code>NULL</code>, the program will now
crash with an out of memory error.
<code>C.malloc</code> will never return <code>nil</code>.
Unlike most C functions, <code>C.malloc</code> may not be used in a
two-result form returning an errno value.
</p>

<p> <!-- CL 33237 -->
If <a href="/cmd/cgo/">cgo</a> is used to call a C function passing a
pointer to a C union, and if the C union can contain any pointer
values, and if <a href="/cmd/cgo/#hdr-Passing_pointers">cgo pointer
checking</a> is enabled (as it is by default), the union value is now
checked for Go pointers.
</p>
360 361 362

<h3 id="gccgo">Gccgo</h3>

363 364 365 366 367 368 369
<p>
Due to the alignment of Go's semiannual release schedule with GCC's
annual release schedule,
GCC release 6 contains the Go 1.6.1 version of gccgo.
We expect that the next release, GCC 7, will contain the Go 1.8
version of gccgo.
</p>
370

371
<h3 id="gopath">Default GOPATH</h3>
372 373

<p>
374 375 376 377 378 379
  The
  <a href="/cmd/go/#hdr-GOPATH_environment_variable"><code>GOPATH</code>
  environment variable</a> now has a default value if it
  is unset. It defaults to
  <code>$HOME/go</code> on Unix and
  <code>%USERPROFILE%/go</code> on Windows.
380 381
</p>

382 383
<h3 id="go_bug">Go bug</h3>

384
<p>
385
  The new
386
<a href="/cmd/go/#hdr-Print_information_for_bug_reports"><code>go</code>
387
   <code>bug</code></a>” command starts a bug report on GitHub, prefilled
388
  with information about the current system.
389 390
</p>

391 392
<h3 id="cmd_doc">Go doc</h3>

393
<p> <!-- CL 25419 -->
394 395 396
  The
<a href="/cmd/go/#hdr-Show_documentation_for_package_or_symbol"><code>go</code>
   <code>doc</code></a>” command
397 398 399 400 401
  now groups constants and variables with their type,
  following the behavior of
  <a href="/cmd/godoc/"><code>godoc</code></a>.
</p>

402
<p> <!-- CL 25420 -->
403
  In order to improve the readability of <code>doc</code>'s
404 405 406
  output, each summary of the first-level items is guaranteed to
  occupy a single line.
</p>
407

408
<p> <!-- CL 31852 -->
409 410 411
  Documentation for a specific method in an interface definition can
  now be requested, as in
<code>go</code> <code>doc</code> <code>net.Conn.SetDeadline</code>”.
412 413
</p>

414
<h3 id="plugin">Plugins</h3>
415 416 417

<p>
  Go now supports a “<code>plugin</code>” build mode for generating
418
  plugins written in Go, and a
419
  new <a href="/pkg/plugin/"><code>plugin</code></a> package for
420 421
  loading such plugins at run time. Plugin support is only currently
  available on Linux and macOS.
422 423 424 425 426 427 428 429 430 431 432 433 434 435
</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>

436
<p>
437 438 439 440 441 442 443 444
  <i>Updating:</i>
  Code that sets a finalizer on an allocated object may need to add
  calls to <code>runtime.KeepAlive</code> in functions or methods
  using that object.
  Read the
  <a href="/pkg/runtime/#KeepAlive"><code>KeepAlive</code>
  documentation</a> and its example for more details.
</p>
445

446 447 448 449
<h3 id="memstats">MemStats Documentation</h3>

<p> <!-- CL 28972 -->
  The runtime's <a href="/pkg/runtime/#MemStats"><code>MemStats</code></a>
Joe Tsai's avatar
Joe Tsai committed
450
  type has been more thoroughly documented.
451 452
</p>

453 454 455 456 457 458 459
<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
460
optimizations in the standard library.
461 462 463
</p>

<p>
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
There have been optimizations to implementations in the
<a href="/pkg/bytes/"><code>bytes</code></a>,
<a href="/pkg/crypto/aes/"><code>crypto/aes</code></a>,
<a href="/pkg/crypto/cipher/"><code>crypto/cipher</code></a>,
<a href="/pkg/crypto/elliptic/"><code>crypto/elliptic</code></a>,
<a href="/pkg/crypto/sha256/"><code>crypto/sha256</code></a>,
<a href="/pkg/crypto/sha512/"><code>crypto/sha512</code></a>,
<a href="/pkg/encoding/asn1/"><code>encoding/asn1</code></a>,
<a href="/pkg/encoding/csv/"><code>encoding/csv</code></a>,
<a href="/pkg/encoding/hex/"><code>encoding/hex</code></a>,
<a href="/pkg/encoding/json/"><code>encoding/json</code></a>,
<a href="/pkg/hash/crc32/"><code>hash/crc32</code></a>,
<a href="/pkg/image/color/"><code>image/color</code></a>,
<a href="/pkg/image/draw/"><code>image/draw</code></a>,
<a href="/pkg/math/"><code>math</code></a>,
<a href="/pkg/math/big/"><code>math/big</code></a>,
<a href="/pkg/reflect/"><code>reflect</code></a>,
<a href="/pkg/regexp/"><code>regexp</code></a>,
<a href="/pkg/runtime/"><code>runtime</code></a>,
<a href="/pkg/strconv/"><code>strconv</code></a>,
<a href="/pkg/strings/"><code>strings</code></a>,
<a href="/pkg/syscall/"><code>syscall</code></a>,
<a href="/pkg/text/template/"><code>text/template</code></a>, and
<a href="/pkg/unicode/utf8/"><code>unicode/utf8</code></a>,
488 489 490 491 492 493
packages.
</p>

<h3 id="gc">Garbage Collector</h3>

<p>
494
  Garbage collection pauses should be significantly shorter than they
495 496
  were in Go 1.7, usually under 100 microseconds and often as low as
  10 microseconds.
497 498 499 500
  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.
501 502 503 504
</p>

<h3 id="defer">Defer</h3>

505
<!-- CL 29656, CL 29656 -->
506 507
<p>
  The overhead of <a href="/ref/spec/#Defer_statements">deferred
508
  function calls</a> has been reduced by about half.
509
</p>
510 511 512

<h3 id="cgoperf">Cgo</h3>

513
<p>The overhead of calls from Go into C has been reduced by about half.</p>
514

515
<h2 id="library">Standard library</h2>
516 517 518 519

<h3 id="examples">Examples</h3>

<p>
520
Examples have been added to the documentation across many packages.
521 522
</p>

523
<h3 id="sort_slice">Sort</h3>
524 525 526 527

<p>
The <a href="/pkg/sort/">sort</a> package
now includes a convenience function
528
<a href="/pkg/sort/#Slice"><code>Slice</code></a> to sort a
529 530 531 532 533 534 535 536
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
537 538
<a href="/pkg/sort/#SliceStable"><code>SliceStable</code></a> and
<a href="/pkg/sort/#SliceIsSorted"><code>SliceIsSorted</code></a>.
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554
</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>

555 556 557 558 559
<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>
560
  method and abrupt shutdown using the new
561
  <a href="/pkg/net/http/#Server.Close"><code>Server.Close</code></a>
562 563 564 565 566 567 568 569 570 571
  method.
</p>

<h3 id="more_context">More Context Support</h3>

<p>
  Continuing <a href="/doc/go1.7#context">Go 1.7's adoption</a>
  of <a href="/pkg/context/#Context"><code>context.Context</code></a>
  into the standard library, Go 1.8 adds more context support
  to existing packages:
572
</p>
573

574 575 576 577 578 579 580 581 582 583 584 585 586
<ul>
  <li>The new <a href="/pkg/net/http/#Server.Shutdown"><code>Server.Shutdown</code></a>
    takes a context argument.</li>
  <li>There have been <a href="#database_sql">significant additions</a> to the
    <a href="/pkg/database/sql/">database/sql</a> package with context support.</li>
  <li>The new <a href="/pkg/testing/#T.Context"><code>T.Context</code></a>
    method in the <a href="/pkg/testing/">testing</a> package now returns a context for
    the active test or benchmark.</li>
  <li>All nine of the new <code>Lookup</code> methods on the new
    <a href="/pkg/net/#Resolver"><code>net.Resolver</code></a> now
    take a context.</li>
  </ul>

Brad Fitzpatrick's avatar
Brad Fitzpatrick committed
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605
<h3 id="mutex_prof">Mutex Contention Profiling</h3>

<p>
  The runtime and tools now support profiling contended mutexes.
</p>

<p>
  Most users will want to use the new <code>-mutexprofile</code>
  flag with <a href="/cmd/go/#hdr-Description_of_testing_flags"><code>go</code> <code>test</code></a>,
  and then use <a href="/cmd/pprof/">pprof</a> on the resultant file.
</p>

<p>
  Lower-level support is also available via the new
  <a href="/pkg/runtime/#MutexProfile"><code>MutexProfile</code></a>
  and
  <a href="/pkg/runtime/#SetMutexProfileFraction"><code>SetMutexProfileFraction</code></a>.
</p>

606 607 608 609 610
<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>
611 612
in mind. The follow sections list the user visible changes and additions.
Optimizations and bug fixes are not listed.
613 614
</p>

615 616
<dl id="archive_tar"><dt><a href="/pkg/archive/tar/">archive/tar</a></dt>
  <dd>
617

618
    <p> <!-- CL 28471, CL 31440, CL 31441, CL 31444, CL 28418, CL 31439 -->
619
      The tar implementation corrects many bugs in corner cases of the file format.
Joe Tsai's avatar
Joe Tsai committed
620 621 622 623
      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.
624 625 626 627 628
    </p>

  </dd>
</dl>

629 630 631 632
<dl id="archive_zip"><dt><a href="/pkg/archive/zip/">archive/zip</a></dt>
  <dd>

    <p> <!-- CL 18274 -->
633 634 635
      The
      <a href="/pkg/archive/zip/#Reader"><code>Reader</code></a>
      now supports modification times in
636 637
      the NTFS, UNIX, and Extended Time Stamp metadata fields.
      <!-- CL 30811 -->
638 639 640
      The
      <a href="/pkg/archive/zip/#Writer"><code>Writer</code></a>
      now writes Extended Time Stamp fields.
641 642 643 644
    </p>

  </dd>
</dl>
645 646 647 648

<dl id="compress_flate"><dt><a href="/pkg/compress/flate/">compress/flate</a></dt>
  <dd>

649
    <p> <!-- CL 31640, CL 31174, CL 32149 -->
650 651
      There have been some minor fixes to the encoder to improve the
      compression ratio in certain situations. As a result, the exact
Joe Tsai's avatar
Joe Tsai committed
652 653
      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,
654 655 656 657 658 659 660
      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
661
      the size of the slices passed to the
662 663 664 665
      <a href="/pkg/compress/flate/#Writer.Write"><code>Write</code></a>
      method.
    </p>

666 667 668 669 670
    <p> <!-- CL 28216 -->
      The decoder, upon encountering an error, now returns any
      buffered data it had uncompressed along with the error.
    </p>

671 672 673 674 675 676 677 678 679 680 681 682 683 684
  </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
685
      a nonsensical value.
686 687 688

      Similarly,
      the <a href="/pkg/compress/gzip/#Reader"><code>Reader</code></a>
689 690
      now reports a zero encoded <code>MTIME</code> field as a zero
      <code>Header.ModTime</code>.
691 692 693 694
    </p>

  </dd>
</dl>
695

Joe Tsai's avatar
Joe Tsai committed
696
<dl id="context"><dt><a href="/pkg/context/">context</a></dt>
697 698
  <dd>
    <p> <!-- CL 30370 -->
Joe Tsai's avatar
Joe Tsai committed
699 700
      The <a href="/pkg/context#DeadlineExceeded"><code>DeadlineExceeded</code></a>
      error now implements
701 702 703 704 705 706 707
      <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>

708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723
<dl id="crypto_tls"><dt><a href="/pkg/crypto/tls/">crypto/tls</a></dt>
  <dd>
    <p> <!-- CL 25159, CL 31318 -->
      The new method
      <a href="/pkg/crypto/tls/#Conn.CloseWrite"><code>Conn.CloseWrite</code></a>
      allows TLS connections to be half closed.
    </p>

    <p> <!-- CL 28075 -->
      The new method
      <a href="/pkg/crypto/tls/#Config.Clone"><code>Config.Clone</code></a>
      clones a TLS configuration.
    </p>

    <p>
      <!-- CL 30790 -->
724
      The new <a href="/pkg/crypto/tls/#Config.GetConfigForClient"><code>Config.GetConfigForClient</code></a>
725 726 727 728 729 730 731 732 733 734 735 736 737 738
      callback allows selecting a configuration for a client dynamically, based
      on the client's
      <a href="/pkg/crypto/tls/#ClientHelloInfo"><code>ClientHelloInfo</code></a>.

      <!-- CL 31391, CL 32119 -->
      The <a href="/pkg/crypto/tls/#ClientHelloInfo"><code>ClientHelloInfo</code></a>
      struct now has new
      fields <code>Conn</code>, <code>SignatureSchemes</code> (using
      the new
      type <a href="/kg/crypto/tls/#SignatureScheme"><code>SignatureScheme</code></a>),
      <code>SupportedProtos</code>, and <code>SupportedVersions</code>.
    </p>

    <p> <!-- CL 32115 -->
739
      The new <a href="/pkg/crypto/tls/#Config.GetClientCertificate"><code>Config.GetClientCertificate</code></a>
740 741 742 743 744 745 746 747
      callback allows selecting a client certificate based on the server's
      TLS <code>CertificateRequest</code> message, represented by the new
      <a href="/pkg/crypto/tls/#CertificateRequestInfo"><code>CertificateRequestInfo</code></a>.
    </p>

    <p> <!-- CL 27434 -->
      The new
      <a href="/pkg/crypto/tls/#Config.KeyLogWriter"><code>Config.KeyLogWriter</code></a>
748
      allows debugging TLS connections
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770
      in <a href="https://www.wireshark.org/">WireShark</a> and
      similar tools.
    </p>

    <p> <!-- CL 32115 -->
      The new
      <a href="/pkg/crypto/tls/#Config.VerifyPeerCertificate"><code>Config.VerifyPeerCertificate</code></a>
      callback allows additional validation of a peer's presented certificate.
    </p>

    <p> <!-- CL 18130 -->
      The <code>crypto/tls</code> package now implements basic
      countermeasures against CBC padding oracles. There should be
      no explicit secret-dependent timings, but it does not attempt to
      normalize memory accesses to prevent cache timing leaks.
    </p>

    <p>
      The <code>crypto/tls</code> package now supports
      X25519 and <!-- CL 30824, CL 30825 -->
      ChaCha20-Poly1305.  <!-- CL 30957, CL 30958 -->
      ChaCha20-Poly1305 is now prioritized unless <!-- CL 32871 -->
771
      hardware support for AES-GCM is present.
772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822
    </p>

    <p> <!-- CL 27315 -->
      AES-128-CBC cipher suites with SHA-256 are also
      now supported.
    </p>
    
  </dd>
</dl>

<dl id="crypto_x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt>
  <dd>
    <p> <!-- CL 30578 -->
      <a href="/pkg/crypto/x509/#SystemCertPool"><code>SystemCertPool</code></a>
      is now implemented on Windows.
    </p>

    <p> <!-- CL 24743 -->
      PSS signatures are now supported.
    </p>

    <p> <!-- CL 32644 -->
      <a href="/pkg/crypto/x509/#UnknownAuthorityError"><code>UnknownAuthorityError</code></a>
      now has a <code>Cert</code> field, reporting the untrusted
      certificate.
    </p>

    <p>
      Certificate validation is more permissive in a few cases and
      stricter in a few other cases.
    <!--
crypto/x509: allow a leaf certificate to be specified directly as root (CL 27393)
crypto/x509: check that the issuer name matches the issuer's subject name (CL 23571)
crypto/x509: don't accept a root that already appears in a chain. (CL 32121)
crypto/x509: fix name constraints handling (CL 30155)
crypto/x509: parse all names in an RDN (CL 30810)
crypto/x509: recognise ISO OID for RSA+SHA1 (CL 27394)
crypto/x509: require a NULL parameters for RSA public keys (CL 16166, CL 27312)
crypto/x509: return error for missing SerialNumber (CL 27238)
-->
    </p>

    <p><!-- CL 30375 -->
      Root certificates will now also be looked for
      at <code>/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem</code>
      on Linux, to support RHEL and CentOS.
    </p>
    
  </dd>
</dl>
    
823 824 825 826 827 828 829
<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>
830
	  that take context arguments. Using the new <code>Context</code> methods ensures that
831
	  connections are closed and returned to the connection pool when the
832 833 834
	  request is done; enables canceling in-progress queries
	  should the driver support that; and allows the database
	  pool to cancel waiting for the next available connection.
835 836 837 838 839 840 841 842
    </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
843
	  with <a href="/pkg/database/sql/#ReadOnlyContext"><code>ReadOnlyContext</code></a>.
844 845 846 847 848 849 850
	</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>
851 852 853
          A <a href="/pkg/database/sql/#Rows"><code>Rows</code></a>
          can now represent multiple result sets. After
	  <a href="/pkg/database/sql/#Rows.Next"><code>Rows.Next</code></a> returns false,
854 855
	  <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>
856
	  should continue to be used after it advances to the next result set.
857 858
    </p>
	<p>
859 860 861
	  <a href="/pkg/database/sql/#NamedArg"><code>NamedArg</code></a> may be used
	  as query arguments. The new function <a href="/pkg/database/sql/#Named"><code>Named</code></a>
	  helps create a <a href="/pkg/database/sql/#NamedArg"><code>NamedArg</code></a>
862 863
	  more succinctly.
	<p>
864 865 866
          If a driver supports the new
          <a href="/pkg/database/sql/driver/#Pinger"><code>Pinger</code></a>
          interface, the <code>DB</code>'s
867
	  <a href="/pkg/database/sql/#DB.Ping"><code>DB.Ping</code></a>
868 869 870 871
	  and
          <a href="/pkg/database/sql/#DB.PingContext"><code>DB.PingContext</code></a>
          methods will use that interface to check whether a
          database connection is still valid.
872 873 874 875
	</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
876
	  updated to use them. The other features require driver support in
877 878 879 880 881 882 883 884
	  <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>

885 886 887
<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 -->
888 889 890 891 892 893 894 895 896 897 898 899
      The package has been fleshed out and is now used by <a href="/cmd/link/">the Go linker</a>.
      New are
      <a href="/pkg/debug/pe/#Reloc"><code>Reloc</code></a>,
      <a href="/pkg/debug/pe/#Section"><code>Section</code></a>,
      <a href="/pkg/debug/pe/#StringTable"><code>StringTable</code></a>,
      the method
      <a href="/pkg/debug/pe/#COFFSymbol.FullName"><code>COFFSymbol.FullName</code></a>,
      and
      <a href="/pkg/debug/pe/#File"><code>File</code></a>
      fields
      <a href="/pkg/debug/pe/#File.COFFSymbols"><code>COFFSymbols</code></a> and
      <a href="/pkg/debug/pe/#File.StringTable"><code>StringTable</code></a>.
900 901 902 903 904 905 906
      </p>
  </dd>
</dl>

<dl id="encoding_base64"><dt><a href="/pkg/encoding/base64/">encoding/base64</a></dt>
  <dd>
    <p> <!-- CL 24964 -->
907 908 909 910
      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.
911 912 913 914 915
    </p>
  </dd>
</dl>

<dl id="encoding_binary"><dt><a href="/pkg/encoding/binary/">encoding/binary</a></dt>
916 917
  <dd>
    <p> <!-- CL 28514 -->
918 919 920 921
      <a href="/pkg/encoding/binary/#Read"><code>Read</code></a>
      and
      <a href="/pkg/encoding/binary/#Write"><code>Write</code></a>
      now support booleans.
922 923 924 925
    </p>
  </dd>
</dl>

926 927 928 929 930 931 932 933 934
<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 -->
935 936
      A nil <a href="/pkg/encoding/json/#Marshaler"><code>Marshaler</code></a>
      now marshals as a JSON <code>null</code> value.
937 938 939 940 941 942 943 944
    </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 -->
945 946
      <a href="/pkg/encoding/json/#Marshal"><code>Marshal</code></a>
      encodes floating-point numbers using the same format as in ES6,
947 948 949
      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.
950 951 952
    </p>

    <p> <!-- CL 30944 -->
953 954

      In previous versions of Go, unmarshaling a JSON <code>null</code> into an
Chris Broadfoot's avatar
Chris Broadfoot committed
955
      <a href="/pkg/encoding/json/#Unmarshaler"><code>Unmarshaler</code></a>
956 957 958
      was considered a no-op; now the <code>Unmarshaler</code>'s
      <code>UnmarshalJSON</code> method is called with the JSON literal
      <code>null</code> and can define the semantics of that case.
959 960 961 962 963 964 965 966
    </p>

  </dd>
</dl>

<dl id="encoding_pem"><dt><a href="/pkg/encoding/pem/">encoding/pem</a></dt>
  <dd>
    <p> <!-- CL 27391 -->
967 968
      <a href="/pkg/encoding/pem/#Decode"><code>Decode</code></a>
      is now strict about the format of the ending line.
969 970 971 972
    </p>
  </dd>
</dl>

973 974 975 976 977 978 979 980 981 982
<dl id="encoding_xml"><dt><a href="/pkg/encoding/xml/">encoding/xml</a></dt>
  <dd>
    <p> <!-- CL 30946 -->
      <a href="/pkg/encoding/xml/#Unmarshal"><code>Unmarshal</code></a>
      now has wildcard support for collecting all attributes using
      the new <code>",any,attr"</code> struct tag.
    </p>
  </dd>
</dl>

983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002
<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>

Brad Fitzpatrick's avatar
Brad Fitzpatrick committed
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016
<dl id="fmt"><dt><a href="/pkg/fmt/">fmt</a></dt>
  <dd>
    <p><!-- CL 30611 -->
      <a href="/pkg/fmt/#Scanf"><code>Scanf</code></a>,
      <a href="/pkg/fmt/#Fscanf"><code>Fscanf</code></a>, and
      <a href="/pkg/fmt/#Sscanf"><code>Sscanf</code></a> now
      handle spaces differently and more consistently than
      previous releases. See the
      <a href="/pkg/fmt/#hdr-Scanning">scanning documentation</a>
      for details.
    </p>
  </dd>
</dl>

1017 1018 1019 1020 1021 1022 1023 1024
<dl id="go_doc"><dt><a href="/pkg/go/doc/">go/doc</a></dt>
  <dd>
    <p><!-- CL 29870 -->
      The new <a href="/pkg/go/doc/#IsPredeclared"><code>IsPredeclared</code></a>
      function reports whether a string is a predeclared identifier.
    </p>
  </dd>
</dl>
1025

Brad Fitzpatrick's avatar
Brad Fitzpatrick committed
1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
<dl id="go_types"><dt><a href="/pkg/go/types/">go/types</a></dt>
  <dd>
    <p><!-- CL 30715 -->
      The new function
      <a href="/pkg/go/types/#Default"><code>Default</code></a>
      returns the default "typed" type for an "untyped" type.
    </p>

    <p><!-- CL 31939 -->
      The alignment of <code>complex64</code> now matches
      the <a href="/cmd/compile/">Go compiler</a>.
    </p>
  </dd>
</dl>

<dl id="html_template"><dt><a href="/pkg/html/template/">html/template</a></dt>
  <dd>
    <p><!-- CL 14336 -->
      The package now validates
      the <code>"type"</code> attribute on
      a <code>&lt;script&gt;</code> tag.
    </p>
  </dd>
</dl>

1051 1052 1053
<dl id="image_png"><dt><a href="/pkg/image/png/">image/png</a></dt>
  <dd>
    <p> <!-- CL 32143, CL 32140 -->
1054 1055 1056
      <a href="/pkg/image/png/#Decode"><code>Decode</code></a>
      (and <code>DecodeConfig</code>)
      now supports True Color and grayscale transparency.
1057 1058
    </p>
    <p> <!-- CL 29872 -->
1059 1060
      <a href="/pkg/image/png/#Encoder"><code>Encoder</code></a>
      is now faster and creates smaller output
1061 1062 1063 1064 1065
      when encoding paletted images.
      </p>
  </dd>
</dl>

1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088
<dl id="math_big"><dt><a href="/pkg/math/big/">math/big</a></dt>
  <dd>
    <p><!-- CL 30706 -->
      The new method
      <a href="/pkg/math/big/#Int.Sqrt"><code>Int.Sqrt</code></a>
      calculates ⌊√x⌋.
    </p>

    <p>
      The new method
      <a href="/pkg/math/big/#Float.Scan"><code>Float.Scan</code></a>
      is a support routine for
      <a href="/pkg/fmt/#Scanner"><code>fmt.Scanner</code></a>.
    </p>

    <p>
      <a href="/pkg/math/big/#Int.ModInverse"><code>Int.ModInverse</code></a>
      now supports negative numbers.
    </p>
    
  </dd>
</dl>

1089 1090 1091
<dl id="math_rand"><dt><a href="/pkg/math/rand/">math/rand</a></dt>
  <dd>

1092 1093
    <p><!-- CL 27253, CL 33456 -->
      The new <a href="/pkg/math/rand/#Rand.Uint64"><code>Rand.Uint64</code></a>
1094 1095
      method returns <code>uint64</code> values. The
      new <a href="/pkg/math/rand/#Source64"><code>Source64</code></a>
1096 1097 1098
      interface describes sources capable of generating such values
      directly; otherwise the <code>Rand.Uint64</code> method
      constructs a <code>uint64</code> from two calls
1099 1100
      to <a href="/pkg/math/rand/#Source"><code>Source</code></a>'s
      <code>Int63</code> method.
1101 1102 1103 1104 1105
    </p>

  </dd>
</dl>

1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122
<dl id="mime"><dt><a href="/pkg/mime/">mime</a></dt>
  <dd>
    <p> <!-- CL 32175 -->
    <a href="/pkg/mime/#ParseMediaType"><code>ParseMediaType</code></a>
    now preserves unnecessary backslash escapes as literals,
    in order to support MSIE.
    When MSIE sends a full file path (in "intranet mode"), it does not
    escape backslashes: <code>"C:\dev\go\foo.txt"</code>, not
    <code>"C:\\dev\\go\\foo.txt"</code>.
    If we see an unnecessary backslash escape, we now assume it is from MSIE
    and intended as a literal backslash.
    No known MIME generators emit unnecessary backslash escapes
    for simple token characters like numbers and letters.
    </p>
  </dd>
</dl>

1123 1124 1125 1126
<dl id="mime_quotedprintable"><dt><a href="/pkg/mime/quotedprintable/">mime/quotedprintable</a></dt>
  <dd>

    <p>
1127 1128 1129
      The
      <a href="/pkg/mime/quotedprintable/#Reader"><code>Reader</code></a>'s
      parsing has been relaxed in two ways to accept
1130 1131 1132 1133 1134
      more input seen in the wild.

      <!-- CL 32174 -->
      First, it accepts an equals sign (<code>=</code>) not followed
      by two hex digits as a literal equal sign.
1135

1136 1137 1138
      <!-- CL 27530 -->
      Second, it silently ignores a trailing equals sign at the end of
      an encoded input.
1139 1140 1141 1142 1143
    </p>

  </dd>
</dl>

1144 1145 1146 1147 1148 1149 1150 1151 1152 1153
<dl id="net"><dt><a href="/pkg/net/">net</a></dt>
  <dd>
    
    <p><!-- CL 30164, CL 33473 -->
      The <a href="/pkg/net/#Conn"><code>Conn</code></a> documentation
      has been updated to clarify expectations of an interface
      implementation. Updates in the <code>net/http</code> packages
      depend on implementations obeying the documentation.
    </p>
    <p><i>Updating:</i> implementations of the <code>Conn</code> interface should verify
1154 1155 1156
      they implement the documented semantics. The
      <a href="https://godoc.org/golang.org/x/net/nettest">golang.org/x/net/nettest</a>
      package will exercise a <code>Conn</code> and validate it behaves properly.
1157 1158
    </p>

1159 1160 1161 1162 1163 1164 1165
    <p><!-- CL 32099 -->
      The new method
      <a href="/pkg/net/#UnixListener.SetUnlinkOnClose"><code>UnixListener.SetUnlinkOnClose</code></a>
      sets whether the underlying socket file should be removed from the file system when
      the listener is closed.
    </p>

1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188
    <p><!-- CL 29951 -->
      The new <a href="/pkg/net/#Buffers"><code>Buffers</code></a> types permits
      more efficiently writing to the network from multiple discontiguous buffers
      in memory. On certain machines, for certain types of connections,
      this is optimized into an OS-specific batch write operation (such as <code>writev</code>).
    </p>

    <p><!-- CL 29440 -->
      The new <a href="/pkg/net/#Resolver"><code>Resolver</code></a> looks up names and numbers
      and supports <a href="/pkg/context/#Context"><code>context.Context</code></a>.
      The <a href="/pkg/net/#Dialer"><code>Dialer</code></a> now has an optional
      <a href="/pkg/net/#Dialer.Resolver"><code>Resolver</code> field</a>.
    </p>

    <p><!-- CL 29892 -->
      <a href="/pkg/net/#Interfaces"><code>Interfaces</code></a> is now supported on Solaris.
    </p>

    <p><!-- CL 29233, CL 24901 -->
      The Go DNS resolver now supports <code>resolv.conf</code>'s "<code>rotate</code>"
      and "<code>option ndots:0</code>" options. The "<code>ndots</code>" option is
      now respected in the same way as <code>libresolve</code>.
    </p>
1189 1190 1191

  </dd>
</dl>
1192 1193 1194 1195

<dl id="net_http"><dt><a href="/pkg/net/http/">net/http</a></dt>
  <dd>

1196 1197 1198 1199 1200
    <p>Server changes:</p>
    <ul>
      <li>The server now supports graceful shutdown support, <a href="#http_shutdown">mentioned above</a>.</li>

      <li> <!-- CL 32024 -->
1201 1202 1203 1204
        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>.
1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216
      </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>
    </ul>

1217
    <p>
1218
      There are several additions to what a server's <code>Handler</code> can do:
1219 1220
    </p>

1221 1222 1223 1224 1225 1226 1227 1228 1229 1230
    <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>
1231 1232 1233
        support. This functionality requires that the underlying
        <a href="/pkg/net/#Conn"><code>net.Conn</code></a> implements
        <a href="#net">recently-clarified interface documentation</a>.
1234 1235
      </li>

1236 1237 1238 1239 1240 1241
      <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>
1242 1243

      <li><!-- CL 33099 -->
1244 1245
        A <code>Handler</code> can now abort a response by panicking
        with the error
1246 1247 1248 1249
        <a href="/pkg/net/http/#ErrAbortHandler"><code>ErrAbortHandler</code></a>.
      </li>

      <li><!-- CL 30812 -->
1250 1251 1252 1253 1254 1255 1256 1257
        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.
1258 1259 1260 1261 1262 1263 1264
      </li>

    </ul>

    <p>Client &amp; Transport changes:</p>
    <ul>
      <li><!-- CL 28930 -->
1265
        The <a href="/pkg/net/http/#Client"><code>Client</code></a>
1266 1267 1268
        now copies most request headers on redirect. See
        <a href="/pkg/net/http/#Client">the documentation</a>
        on the <code>Client</code> type for details.
1269 1270 1271
      </li>

      <li><!-- CL 29072 -->
1272 1273 1274
        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.
1275 1276 1277 1278
      </li>

      <li><!-- CL 31733, CL 29852 -->
        The <code>Client</code> now supports 307 and 308 redirects.
1279
        If the redirect requires resending the request body,
1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306
        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>
1307
        now enables <code>DualStack</code> ("<a href="https://tools.ietf.org/html/rfc6555">Happy Eyeballs</a>") support,
1308 1309 1310 1311 1312
        to use IPv4 as a backup if it looks like IPv6 might be
        failing.
      </li>
    </ul>

1313 1314 1315
  </dd>
</dl>

1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339
<dl id="net_http_httptrace"><dt><a href="/pkg/net/http/httptrace/">net/http/httptrace</a></dt>
  <dd>
    <p> <!-- CL 30359 -->
    There is now support for tracing a client request's TLS handshakes with
    the new
    <a href="/pkg/net/http/httptrace/#ClientTrace.TLSHandshakeStart"><code>ClientTrace.TLSHandshakeStart</code></a>
    and
    <a href="/pkg/net/http/httptrace/#ClientTrace.TLSHandshakeDone"><code>ClientTrace.TLSHandshakeDone</code></a>.
    </p>
  </dd>
</dl>

<dl id="net_http_httputil"><dt><a href="/pkg/net/http/httputil/">net/http/httputil</a></dt>
  <dd>
    <p> <!-- CL 32356 -->
    The <a href="/pkg/net/http/httputil/#ReverseProxy"><code>ReverseProxy</code></a>
    has a new optional hook,
    <a href="/pkg/net/http/httputil/#ReverseProxy.ModifyResponse"><code>ModifyResponse</code></a>,
    for modifying the response from the backend before proxying it to the client.
    </p>
    
  </dd>
</dl>

1340 1341 1342 1343
<dl id="net_mail"><dt><a href="/pkg/net/mail/">net/mail</a></dt>
  <dd>

    <p> <!-- CL 32176 -->
1344 1345 1346 1347 1348
      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.
1349 1350 1351
    </p>

    <p> <!-- CL 31581 -->
1352 1353 1354 1355 1356 1357 1358 1359
      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.
1360 1361 1362 1363 1364 1365 1366 1367 1368
    </p>
    
  </dd>
</dl>

<dl id="net_smtp"><dt><a href="/pkg/net/smtp/">net/smtp</a></dt>
  <dd>

    <p> <!-- CL 33143 -->
1369 1370 1371 1372 1373 1374
      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.
1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386
    </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>
1387
      are similar to the query escaping and unescaping functions but
1388
      for path elements.</p>
1389 1390 1391 1392 1393

    <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>
1394 1395
      return the hostname and port fields of a URL,
      correctly handling the case where the port may not be present.
1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406
    </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
1407 1408
      <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>.
1409 1410 1411
    </p>

    <p> <!-- CL 29610, CL 31582 -->
1412 1413 1414 1415 1416 1417 1418
      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.
1419 1420 1421 1422 1423
    </p>

  </dd>
</dl>

1424 1425 1426 1427 1428
<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
1429
      the path name of the running executable.
1430
    </p>
1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473

    <p> <!-- CL 30614 -->
      An attempt to call a method on
      an <a href="/pkg/os/#File"><code>os.File</code></a> that has
      already been closed will now return the new error
      value <a href="/pkg/os/#ErrClosed"><code>os.ErrClosed</code></a>.
      Previously it returned a system-specific error such
      as <code>syscall.EBADF</code>.
    </p>

    <p> <!-- CL 31358 -->
      On Unix systems, <a href="/pkg/os/#Rename"><code>os.Rename</code></a>
      will now return an error when used to rename a directory to an
      existing empty directory.
      Previously it would fail when renaming to a non-empty directory
      but succeed when renaming to an empty directory.
      This makes the behavior on Unix correspond to that on other systems.
    </p>

    <p> <!-- CL 32451 -->
      On Windows, long absolute paths are now transparently converted to
      extended-length paths (paths that start with <code>\\?\</code>).
      This permits the package to work with files whose path names are
      longer than 260 characters.
    </p>

    <p> <!-- CL 29753 -->
      On Windows, <a href="/pkg/os/#IsExist"><code>os.IsExist</code></a>
      will now return <code>true</code> for the system
      error <code>ERROR_DIR_NOT_EMPTY</code>.
      This roughly corresponds to the existing handling of the Unix
      error <code>ENOTEMPTY</code>.
    </p>

    <p> <!-- CL 32152 -->
      On Plan 9, files that are not served by <code>#M</code> will now
      have <a href="/pkg/os/#ModeDevice"><code>ModeDevice</code></a> set in
      the value returned
      by <a href="/pkg/os/#FileInfo"><code>FileInfo.Mode</code></a>.
    </p>
  </dd>
</dl>

1474 1475 1476 1477 1478 1479 1480 1481 1482
<dl id="path_filepath"><dt><a href="/pkg/path/filepath/">path/filepath</a></dt>
  <dd>
    <p>
    <p>A number of bugs and corner cases on Windows were fixed:
      <a href="/pkg/path/filepath/#Abs"><code>Abs</code></a> now calls <code>Clean</code> paths as documented,
      <a href="/pkg/path/filepath/#Glob"><code>Glob</code></a> now matches
      "<code>\\?\c:\*</code>",
      <a href="/pkg/path/filepath/#EvalSymlinks"><code>EvalSymlinks</code></a> now
      correctly handles "<code>C:.</code>", and
1483 1484
      <a href="/pkg/path/filepath/#Clean"><code>Clean</code></a> now properly
      handles a leading "<code>..</code>" in the path.
1485 1486 1487 1488 1489
    <p>

  </dd>
</dl>

1490 1491 1492 1493 1494
<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
1495
      added to support <a href="#sortslice"><code>sort.Slice</code></a>.
1496 1497 1498 1499 1500 1501 1502 1503 1504
    </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
1505 1506
      backquoted raw strings, following the
      <a href="/ref/spec#String_literals">Go language semantics</a>.
1507 1508 1509 1510
    </p>
  </dd>
</dl>

Brad Fitzpatrick's avatar
Brad Fitzpatrick committed
1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533
<dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt>
  <dd>
    <p> <!-- CL 25050, CL 25022 -->
      The <a href="/pkg/syscall/#Getpagesize"><code>Getpagesize</code></a>
      now returns the system's size, rather than a constant value.
      Previously it always returned 4KB.
    </p>

    <p> <!-- CL 31446 -->
      The signature
      of <a href="/pkg/syscall/#Utimes"><code>Utimes</code></a> has
      changed on Solaris to match all the other Unix systems'
      signature. Portable code should continue to use
      <a href="/pkg/os/#Chtimes"><code>os.Chtimes</code></a> instead.
    </p>

    <p> <!-- CL 32319 -->
      The <code>X__cmsg_data</code> field has been removed from
      <a href="/pkg/syscall/#Cmsghdr"><code>Cmsghdr</code></a>.
      </p>
  </dd>
</dl>

1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547
<dl id="text_template"><dt><a href="/pkg/text/template/">text/template</a></dt>
  <dd>
    <p> <!-- CL 31462 -->
      <a href="/pkg/text/template/#Template.Execute"><code>Template.Execute</code></a>
      can now take a
      <a href="/pkg/reflect/#Value"><code>reflect.Value</code></a> as its data
      argument, and
      <a href="/pkg/text/template/#FuncMap"><code>FuncMap</code></a>
      functions can also accept and return <code>reflect.Value</code>.
    </p>

  </dd>
</dl>

1548 1549 1550 1551 1552 1553 1554 1555
<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>

1556 1557 1558 1559
    <p> <!-- CL 29338 -->
      <a href="/pkg/time/#ParseDuration"><code>ParseDuration</code></a>
      now accepts long fractional parts.
    </p>
1560 1561

    <p> <!-- CL 33429 -->
1562 1563 1564 1565
      <a href="/pkg/time/#Parse"><code>Parse</code></a>
      now rejects dates before the start of a month, such as June 0;
      it already rejected dates beyond the end of the month, such as
      June 31 and July 32.
1566 1567
    </p>

1568 1569 1570 1571 1572 1573
    <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>

1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593
    <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>
1594

1595 1596 1597
    <p><!-- CL 32483 -->
      The new function
      <a href="/pkg/testing/#CoverMode"><code>CoverMode</code></a>
1598
      reports the test coverage mode.
1599 1600 1601 1602 1603
    </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.
1604 1605
      Previously, individual test cases would appear to pass,
      and only the overall execution of the test binary would fail.
1606 1607 1608 1609 1610 1611 1612 1613 1614 1615
    </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.
1616
      Previously, the implementation failed with an index bounds check panic.
1617 1618 1619
    </p>
  </dd>
</dl>