github.com/mh-cbon/go@v0.0.0-20160603070303-9e112a3fe4c0/doc/go1.7.html (about) 1 <!--{ 2 "Title": "Go 1.7 Release Notes DRAFT", 3 "Path": "/doc/go1.7", 4 "Template": true 5 }--> 6 7 <!-- 8 for acme: 9 Edit .,s;^PKG:([a-z][A-Za-z0-9_/]+);<a href="/pkg/\1/"><code>\1</code></a>;g 10 Edit .,s;^([a-z][A-Za-z0-9_/]+)\.([A-Z][A-Za-z0-9_]+\.)?([A-Z][A-Za-z0-9_]+)([ .',)]|$);<a href="/pkg/\1/#\2\3"><code>\3</code></a>\4;g 11 Edit .,s;^FULL:([a-z][A-Za-z0-9_/]+)\.([A-Z][A-Za-z0-9_]+\.)?([A-Z][A-Za-z0-9_]+)([ .',)]|$);<a href="/pkg/\1/#\2\3"><code>\1.\2\3</code></a>\4;g 12 Edit .,s;^DPKG:([a-z][A-Za-z0-9_/]+);<dl id="\1"><a href="/pkg/\1/">\1</a></dl>;g 13 14 rsc last updated through 6729576 15 --> 16 17 <!-- 18 NOTE: In this document and others in this directory, the convention is to 19 set fixed-width phrases with non-fixed-width spaces, as in 20 <code>hello</code> <code>world</code>. 21 Do not send CLs removing the interior tags from such phrases. 22 --> 23 24 <style> 25 ul li { margin: 0.5em 0; } 26 </style> 27 28 <p> 29 <!-- TODO: REMOVE THIS COMMENT --> 30 <!-- TODO: Also remove "DRAFT" in the "Title" at the top of this file. --> 31 <i>NOTE: This is a DRAFT of the Go 1.7 release notes, prepared for the Go 1.7 beta. 32 Go 1.7 has NOT yet been released. 33 By our regular schedule, it is expected some time in August 2016. 34 </i> 35 </p> 36 37 <h2 id="introduction">Introduction to Go 1.7</h2> 38 39 <p> 40 The latest Go release, version 1.7, arrives six months after 1.6. 41 Most of its changes are in the implementation of the toolchain, runtime, and libraries. 42 There is one minor change to the language specification. 43 As always, the release maintains the Go 1 <a href="/doc/go1compat.html">promise of compatibility</a>. 44 We expect almost all Go programs to continue to compile and run as before. 45 </p> 46 47 <p> 48 The release <a href="#ports">adds a port to IBM LinuxOne</a>; 49 <a href="#compiler">updates the x86-64 compiler back end</a> to generate more efficient code; 50 includes the <a href="#context">context package</a>, promoted from the 51 <a href="https://golang.org/x/net/context">x/net subrepository</a> 52 and now used in the standard library; 53 and <a href="#testing">adds support in the testing package</a> for 54 creating hierarchies of tests and benchmarks. 55 The release also <a href="#cmd/go">finalizes the vendoring support</a> 56 started in Go 1.5, making it a standard feature. 57 </p> 58 59 <h2 id="language">Changes to the language</h2> 60 61 <p> 62 There is one tiny language change in this release. 63 The section on <a href="/ref/spec#Terminating_statements">terminating statements</a> 64 clarifies that to determine whether a statement list ends in a terminating statement, 65 the “final non-empty statement” is considered the end, 66 matching the existing behavior of the gc and gccgo compiler toolchains. 67 In earlier releases the definition referred only to the “final statement,” 68 leaving the effect of trailing empty statements at the least unclear. 69 The <a href="/pkg/go/types/"><code>go/types</code></a> 70 package has been updated to match the gc and gccgo compiler toolchains 71 in this respect. 72 This change has no effect on the correctness of existing programs. 73 </p> 74 75 <h2 id="ports">Ports</h2> 76 77 <p> 78 Go 1.7 adds an experimental port to <a href="https://en.wikipedia.org/wiki/Linux_on_z_Systems">Linux on z Systems</a> (<code>linux/s390x</code>) 79 and the beginning of a port to Plan 9 on ARM (<code>plan9/arm</code>). 80 </p> 81 82 <p> 83 The experimental ports to Linux on 64-bit MIPS (<code>linux/mips64</code> and <code>linux/mips64le</code>) 84 added in Go 1.6 now have full support for cgo and external linking. 85 </p> 86 87 <p> 88 The experimental port to Linux on big-endian 64-bit PowerPC (<code>linux/ppc64</code>) 89 now requires the POWER8 architecture or later. 90 </p> 91 92 <p> 93 The OpenBSD port now requires OpenBSD 5.6 or later, for access to the <a href="http://man.openbsd.org/getentropy.2"><i>getentropy</i>(2)</a> system call. 94 </p> 95 96 <h2 id="tools">Tools</h2> 97 98 <h3 id="cmd/asm">Assembler</h3> 99 100 <p> 101 For 64-bit ARM systems, the vector register names have been 102 corrected to <code>V0</code> through <code>V31</code>; 103 previous releases incorrectly referred to them as <code>V32</code> through <code>V63</code>. 104 </p> 105 106 <p> 107 For 64-bit x86 systems, the following instructions have been added: 108 <code>PCMPESTRI</code>, 109 <code>RORXL</code>, 110 <code>RORXQ</code>, 111 <code>VINSERTI128</code>, 112 <code>VPADDD</code>, 113 <code>VPADDQ</code>, 114 <code>VPALIGNR</code>, 115 <code>VPBLENDD</code>, 116 <code>VPERM2F128</code>, 117 <code>VPERM2I128</code>, 118 <code>VPOR</code>, 119 <code>VPSHUFB</code>, 120 <code>VPSHUFD</code>, 121 <code>VPSLLD</code>, 122 <code>VPSLLDQ</code>, 123 <code>VPSLLQ</code>, 124 <code>VPSRLD</code>, 125 <code>VPSRLDQ</code>, 126 and 127 <code>VPSRLQ</code>. 128 </p> 129 130 <h3 id="compiler">Compiler Toolchain</h3> 131 132 <p> 133 This release includes a new code generation back end for 64-bit x86 systems, 134 following a <a href="https://golang.org/s/go17ssa">proposal from 2015</a> 135 that has been under development since then. 136 The new back end, based on 137 <a href="https://en.wikipedia.org/wiki/Static_single_assignment_form">SSA</a>, 138 generates more compact, more efficient code 139 and provides a better platform for optimizations 140 such as bounds check elimination. 141 The new back end reduces the CPU time required by 142 <a href="https://golang.org/test/bench/go1/">our benchmark programs</a> by 5-35%. 143 </p> 144 145 <p> 146 For this release, the new back end can be disabled by passing 147 <code>-ssa=0</code> to the compiler. 148 If you find that your program compiles or runs successfully 149 only with the new back end disabled, please 150 <a href="https://golang.org/issue/new">file a bug report</a>. 151 </p> 152 153 <p> 154 The format of exported metadata written by the compiler in package archives has changed: 155 the old textual format has been replaced by a more compact binary format. 156 This results in somewhat smaller package archives and fixes a few 157 long-standing corner case bugs. 158 </p> 159 160 <p> 161 For this release, the new export format can be disabled by passing 162 <code>-newexport=0</code> to the compiler. 163 If you find that your program compiles or runs successfully 164 only with the new export format disabled, please 165 <a href="https://golang.org/issue/new">file a bug report</a>. 166 </p> 167 168 <p> 169 The linker's <code>-X</code> option no longer supports the unusual two-argument form 170 <code>-X</code> <code>name</code> <code>value</code>, 171 as <a href="/doc/go1.6#compiler">announced</a> in the Go 1.6 release 172 and in warnings printed by the linker. 173 Use <code>-X</code> <code>name=value</code> instead. 174 </p> 175 176 <p> 177 The compiler and linker have been optimized and run significantly faster in this release than in Go 1.6, 178 although they are still slower than we would like and will continue to be optimized in future releases. 179 </p> 180 181 <p> 182 Due to changes across the compiler toolchain and standard library, 183 binaries built with this release should typically be smaller than binaries 184 built with Go 1.6, 185 sometimes by as much as 20-30%. 186 </p> 187 188 <p> 189 On x86-64 systems, Go programs now maintain stack frame pointers 190 as expected by profiling tools like Linux's perf and Intel's VTune, 191 making it easier to analyze and optimize Go programs using these tools. 192 The frame pointer maintenance has a small run-time overhead that varies 193 but averages around 2%. We hope to reduce this cost in future releases. 194 To build a toolchain that does not use frame pointers, set 195 <code>GOEXPERIMENT=noframepointer</code> when running 196 <code>make.bash</code>, <code>make.bat</code>, or <code>make.rc</code>. 197 </p> 198 199 <h3 id="cmd/cgo">Cgo</h3> 200 201 <p> 202 Packages using <a href="/cmd/cgo/">cgo</a> may now include 203 Fortran source files (in addition to C, C++, Objective C, and SWIG), 204 although the Go bindings must still use C language APIs. 205 </p> 206 207 <p> 208 Go bindings may now use a new helper function <code>C.CBytes</code>. 209 In contrast to <code>C.CString</code>, which takes a Go <code>string</code> 210 and returns a <code>*C.byte</code> (a C <code>char*</code>), 211 <code>C.CBytes</code> takes a Go <code>[]byte</code> 212 and returns an <code>unsafe.Pointer</code> (a C <code>void*</code>). 213 </p> 214 215 <p> 216 Packages and binaries built using <code>cgo</code> have in past releases 217 produced different output on each build, 218 due to the embedding of temporary directory names. 219 When using this release with 220 new enough versions of GCC or Clang 221 (those that support the <code>-fdebug-prefix-map</code> option), 222 those builds should finally be deterministic. 223 </p> 224 225 <h3 id="gccgo">Gccgo</h3> 226 227 <p> 228 Due to the alignment of Go's semiannual release schedule with GCC's annual release schedule, 229 GCC release 6 contains the Go 1.6.1 version of gccgo. 230 The next release, GCC 7, will likely have the Go 1.8 version of gccgo. 231 </p> 232 233 <h3 id="cmd/go">Go command</h3> 234 235 <p> 236 The <a href="/cmd/go/"><code>go</code></a> command's basic operation 237 is unchanged, but there are a number of changes worth noting. 238 </p> 239 240 <p> 241 This release removes support for the <code>GO15VENDOREXPERIMENT</code> environment variable, 242 as <a href="/doc/go1.6#go_command">announced</a> in the Go 1.6 release. 243 <a href="https://golang.org/s/go15vendor">Vendoring support</a> 244 is now a standard feature of the <code>go</code> command and toolchain. 245 </p> 246 247 <p> 248 The <code>Package</code> data structure made available to 249 “<code>go</code> <code>list</code>” now includes a 250 <code>StaleReason</code> field explaining why a particular package 251 is or is not considered stale (in need of rebuilding). 252 This field is available to the <code>-f</code> or <code>-json</code> 253 options and is useful for understanding why a target is being rebuilt. 254 </p> 255 256 <p> 257 The “<code>go</code> <code>get</code>” command now supports 258 import paths referring to <code>git.openstack.org</code>. 259 </p> 260 261 <p> 262 This release adds experimental, minimal support for building programs using 263 <a href="/pkg/go/build#hdr-Binary_Only_Packages">binary-only packages</a>, 264 packages distributed in binary form 265 without the corresponding source code. 266 This feature is needed in some commercial settings 267 but is not intended to be fully integrated into the rest of the toolchain. 268 For example, tools that assume access to complete source code 269 will not work with such packages, and there are no plans to support 270 such packages in the “<code>go</code> <code>get</code>” command. 271 </p> 272 273 <h3 id="cmd/doc">Go doc</h3> 274 275 <p> 276 The “<code>go</code> <code>doc</code>” command 277 now groups constructors with the type they construct, 278 following <a href="/cmd/godoc/"><code>godoc</code></a>. 279 </p> 280 281 <h3 id="cmd/vet">Go vet</h3> 282 283 <p> 284 The “<code>go</code> <code>vet</code>” command 285 has more accurate analysis in its <code>-copylock</code> and <code>-printf</code> checks, 286 and a new <code>-tests</code> check that checks the name and signature of likely test functions. 287 To avoid confusion with the new <code>-tests</code> check, the old, unadvertised 288 <code>-test</code> option has been removed; it was equivalent to <code>-all</code> <code>-shadow</code>. 289 </p> 290 291 <h3 id="cmd/dist">Go tool dist</h3> 292 293 <p> 294 The new subcommand “<code>go</code> <code>tool</code> <code>dist</code> <code>list</code>” 295 prints all supported operating system/architecture pairs. 296 </p> 297 298 <h3 id="cmd/trace">Go tool trace</h3> 299 300 <p> 301 The “<code>go</code> <code>tool</code> <code>trace</code>” command, 302 <a href="/doc/go1.5#trace_command">introduced in Go 1.5</a>, 303 has been refined in various ways. 304 </p> 305 306 <p> 307 First, collecting traces is significantly more efficient than in past releases. 308 In this release, the typical execution-time overhead of collecting a trace is about 25%; 309 in past releases it was at least 400%. 310 Second, trace files now include file and line number information, 311 making them more self-contained and making the 312 original executable optional when running the trace tool. 313 Third, the trace tool now breaks up large traces to avoid limits 314 in the browser-based viewer. 315 </p> 316 317 <p> 318 Although the trace file format has changed in this release, 319 the Go 1.7 tools can still read traces from earlier releases. 320 </p> 321 322 <h2 id="performance">Performance</h2> 323 324 <p> 325 As always, the changes are so general and varied that precise statements 326 about performance are difficult to make. 327 Most programs should run a bit faster, 328 due to speedups in the garbage collector and 329 optimizations in the core library. 330 On x86-64 systems, many programs will run significantly faster, 331 due to improvements in generated code brought by the 332 new compiler back end. 333 As noted above, in our own benchmarks, 334 the code generation changes alone typically reduce program CPU time by 5-35%. 335 </p> 336 337 <p> 338 <!-- git log --grep '-[0-9][0-9]\.[0-9][0-9]%' go1.6.. --> 339 There have been significant optimizations bringing more than 10% improvements 340 to implementations in the 341 <a href="/pkg/crypto/sha1/"><code>crypto/sha1</code></a>, 342 <a href="/pkg/crypto/sha256/"><code>crypto/sha256</code></a>, 343 <a href="/pkg/encoding/binary/"><code>encoding/binary</code></a>, 344 <a href="/pkg/fmt/"><code>fmt</code></a>, 345 <a href="/pkg/hash/adler32/"><code>hash/adler32</code></a>, 346 <a href="/pkg/hash/crc32/"><code>hash/crc32</code></a>, 347 <a href="/pkg/hash/crc64/"><code>hash/crc64</code></a>, 348 <a href="/pkg/image/color/"><code>image/color</code></a>, 349 <a href="/pkg/math/big/"><code>math/big</code></a>, 350 <a href="/pkg/strconv/"><code>strconv</code></a>, 351 <a href="/pkg/strings/"><code>strings</code></a>, 352 <a href="/pkg/unicode/"><code>unicode</code></a>, 353 and 354 <a href="/pkg/unicode/utf16/"><code>unicode/utf16</code></a> 355 packages. 356 </p> 357 358 <h2 id="library">Core library</h2> 359 360 <h3 id="context">Context</h3> 361 362 <p> 363 Go 1.7 moves the <code>golang.org/x/net/context</code> package 364 into the standard library as <a href="/pkg/context/"><code>context</code></a>. 365 This allows the use of contexts for cancelation, timeouts, and passing 366 request-scoped data in other standard library packages, 367 including 368 <a href="#net">net</a>, 369 <a href="#net/http">net/http</a>, 370 and 371 <a href="#os/exec">os/exec</a>, 372 as noted below. 373 </p> 374 375 <p> 376 For more information about contexts, see the 377 <a href="/pkg/context/">package documentation</a> 378 and the Go blog post 379 “<a href="https://blog.golang.org/context">Go Concurrent Patterns: Context</a>.” 380 </p> 381 382 <h3 id="httptrace">HTTP Tracing</h3> 383 384 <p> 385 Go 1.7 introduces <a href="/pkg/net/http/httptrace/"><code>net/http/httptrace</code></a>, 386 a package that provides mechanisms for tracing events within HTTP requests. 387 </p> 388 389 <h3 id="testing">Testing</h3> 390 391 <p> 392 The <code>testing</code> package now supports the definition 393 of tests with subtests and benchmarks with sub-benchmarks. 394 This support makes it easy to write table-driven benchmarks 395 and to create hierarchical tests. 396 It also provides a way to share common setup and tear-down code. 397 See the <a href="/pkg/testing/#hdr-Subtests_and_Sub_benchmarks">package documentation</a> for details. 398 </p> 399 400 <h3 id="runtime">Runtime</h3> 401 402 <p> 403 All panics started by the runtime now use panic values 404 that implement both the builtin <a href="/ref/spec#Errors">error</code>, 405 and 406 <a href="/pkg/runtime/#Error"><code>runtime.Error</code></a>, 407 as 408 <a href="/ref/spec#Run_time_panics">required by the language specification</a>. 409 </p> 410 411 <p> 412 During panics, if a signal's name is known, it will be printed in the stack trace. 413 Otherwise, the signal's number will be used, as it was before Go1.7. 414 </p> 415 416 <p> 417 The new function 418 <a href="/pkg/runtime/#KeepAlive"><code>KeepAlive</code></a> 419 provides an explicit mechanism for declaring 420 that an allocated object must be considered reachable 421 at a particular point in a program, 422 typically to delay the execution of an associated finalizer. 423 </p> 424 425 <p> 426 The new function 427 <a href="/pkg/runtime/#CallersFrames"><code>CallersFrames</code></a> 428 translates a PC slice obtained from 429 <a href="/pkg/runtime/#Callers"><code>Callers</code></a> 430 into a sequence of frames corresponding to the call stack. 431 This new API should be preferred instead of direct use of 432 <a href="/pkg/runtime/#FuncForPC"><code>FuncForPC</code></a>, 433 because the frame sequence can more accurately describe 434 call stacks with inlined function calls. 435 </p> 436 437 <p> 438 The new function 439 <a href="/pkg/runtime/#SetCgoTraceback"><code>SetCgoTraceback</code></a> 440 facilitates tighter integration between Go and C code executing 441 in the same process called using cgo. 442 </p> 443 444 <p> 445 On 32-bit systems, the runtime can now use memory allocated 446 by the operating system anywhere in the address space, 447 eliminating the 448 “memory allocated by OS not in usable range” failure 449 common in some environments. 450 </p> 451 452 <p> 453 On Windows, Go programs in Go 1.5 and earlier forced 454 the global Windows timer resolution to 1ms at startup 455 by calling <code>timeBeginPeriod(1)</code>. 456 Changing the global timer resolution caused problems on some systems, 457 and testing suggested that the call was not needed for good scheduler performance, 458 so Go 1.6 removed the call. 459 Go 1.7 brings the call back: under some workloads the call 460 is still needed for good scheduler performance. 461 </p> 462 463 464 <h3 id="minor_library_changes">Minor changes to the library</h3> 465 466 <p> 467 As always, there are various minor changes and updates to the library, 468 made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a> 469 in mind. 470 </p> 471 472 <dl id="bufio"><a href="/pkg/bufio/">bufio</a></dl> 473 474 <dd> 475 <p> 476 In previous releases of Go, if 477 <a href="/pkg/bufio/#Reader"><code>Reader</code></a>'s 478 <a href="/pkg/bufio/#Reader.Peek"><code>Peek</code></a> method 479 were asked for more bytes than fit in the underlying buffer, 480 it would return an empty slice and the error <code>ErrBufferFull</code>. 481 Now it returns the entire underlying buffer, still accompanied by the error <code>ErrBufferFull</code>. 482 </p> 483 </dd> 484 485 <dl id="bytes"><a href="/pkg/bytes/">bytes</a></dl> 486 487 <dd> 488 <p> 489 The new functions 490 <a href="/pkg/bytes/#ContainsAny"><code>ContainsAny</code></a> and 491 <a href="/pkg/bytes/#ContainsRune"><code>ContainsRune</code></a> 492 have been added for symmetry with 493 the <a href="/pkg/strings/"><code>strings</code></a> package. 494 </p> 495 496 <p> 497 In previous releases of Go, if 498 <a href="/pkg/bytes/#Reader"><code>Reader</code></a>'s 499 <a href="/pkg/bytes/#Reader.Read"><code>Read</code></a> method 500 were asked for zero bytes with no data remaining, it would 501 return a count of 0 and no error. 502 Now it returns a count of 0 and the error 503 <a href="/pkg/io/#EOF"><code>io.EOF</code></a>. 504 </p> 505 506 <p> 507 The 508 <a href="/pkg/bytes/#Reader"><code>Reader</code></a> type has a new method 509 <a href="/pkg/bytes/#Reader.Reset"><code>Reset</code></a> to allow reuse of a <code>Reader</code>. 510 </p> 511 </dd> 512 513 <dl id="compress/flate"><a href="/pkg/compress/flate/">compress/flate</a></dl> 514 515 <dd> 516 <p> 517 As noted above, 518 there are significant performance optimizations throughout the package. 519 Decompression speed is improved by about 10%, 520 while compression speed for <code>DefaultCompression</code> is roughly doubled. 521 </p> 522 523 <p> 524 In addition to those general improvements, 525 the 526 <code>BestSpeed</code> 527 compressor has been replaced entirely and uses an 528 algorithm similar to <a href="https://github.com/google/snappy">Snappy</a>, 529 resulting in about a 2.5X speed increase, 530 although the output can be 5-10% larger than with the previous algorithm. 531 </p> 532 533 <p> 534 There is also a new compression level 535 <code>HuffmanOnly</code> 536 that applies Huffman but not Lempel-Ziv encoding. 537 <a href="https://blog.klauspost.com/constant-time-gzipzip-compression/">Forgoing Lempel-Ziv encoding</a> means that 538 <code>HuffmanOnly</code> runs about 3X faster than the new <code>BestSpeed</code> 539 but at the cost of producing compressed outputs that are 20-40% larger than those 540 generated by the new <code>BestSpeed</code>. 541 </p> 542 543 <p> 544 It is important to note that both 545 <code>BestSpeed</code> and <code>HuffmanOnly</code> produce a compressed output that is 546 <a href="https://tools.ietf.org/html/rfc1951">RFC 1951</a> compliant. 547 In other words, any valid DEFLATE decompressor will continue to be able to decompress these outputs. 548 </p> 549 550 <p> 551 Lastly, there is a minor change to the decompressor's implementation of 552 <a href="/pkg/io/#Reader"><code>io.Reader</code></a>. In previous versions, 553 the decompressor deferred reporting 554 <a href="/pkg/io/#EOF"><code>io.EOF</code></a> until exactly no more bytes could be read. 555 Now, it reports 556 <a href="/pkg/io/#EOF"><code>io.EOF</code></a> more eagerly when reading the last set of bytes. 557 </p> 558 </dd> 559 560 <dl id="crypto/tls"><a href="/pkg/crypto/tls/">crypto/tls</a></dl> 561 562 <dd> 563 <p> 564 The TLS implementation sends the first few data packets on each connection 565 using small record sizes, gradually increasing to the TLS maximum record size. 566 This heuristic reduces the amount of data that must be received before 567 the first packet can be decrypted, improving communication latency over 568 low-bandwidth networks. 569 Setting 570 <a href="/pkg/crypto/tls/#Config"><code>Config</code></a>'s 571 <code>DynamicRecordSizingDisabled</code> field to true 572 forces the behavior of Go 1.6 and earlier, where packets are 573 as large as possible from the start of the connection. 574 </p> 575 576 <p> 577 The TLS client now has optional, limited support for server-initiated renegotiation, 578 enabled by setting the 579 <a href="/pkg/crypto/tls/#Config"><code>Config</code></a>'s 580 <code>Renegotiation</code> field. 581 This is needed for connecting to many Microsoft Azure servers. 582 </p> 583 584 <p> 585 The errors returned by the package now consistently begin with a 586 <code>tls:</code> prefix. 587 In past releases, some errors used a <code>crypto/tls:</code> prefix, 588 some used a <code>tls:</code> prefix, and some had no prefix at all. 589 </p> 590 591 <p> 592 When generating self-signed certificates, the package no longer sets the 593 “Authority Key Identifier” field by default. 594 </p> 595 </dd> 596 597 <dl id="crypto/x509"><a href="/pkg/crypto/x509/">crypto/x509</a></dl> 598 599 <dd> 600 <p> 601 The new function 602 <a href="/pkg/crypto/x509/#SystemCertPool"><code>SystemCertPool</code></a> 603 provides access to the entire system certificate pool if available. 604 There is also a new associated error type 605 <a href="/pkg/crypto/x509/#SystemRootsError"><code>SystemRootsError</code></a>. 606 </p> 607 </dd> 608 609 <dl id="debug/dwarf"><a href="/pkg/debug/dwarf/">debug/dwarf</a></dl> 610 611 <dd> 612 <p> 613 The 614 <a href="/pkg/debug/dwarf/#Reader"><code>Reader</code></a> type's new 615 <a href="/pkg/debug/dwarf/#Reader.SeekPC"><code>SeekPC</code></a> method and the 616 <a href="/pkg/debug/dwarf/#Data"><code>Data</code></a> type's new 617 <a href="/pkg/debug/dwarf/#Ranges"><code>Ranges</code></a> method 618 help to find the compilation unit to pass to a 619 <a href="/pkg/debug/dwarf/#LineReader"><code>LineReader</code></a> 620 and to identify the specific function for a given program counter. 621 </p> 622 </dd> 623 624 <dl id="debug/elf"><a href="/pkg/debug/elf/">debug/elf</a></dl> 625 626 <dd> 627 <p> 628 The new 629 <a href="/pkg/debug/elf/#R_390"><code>R_390</code></a> relocation type 630 and its many predefined constants 631 support the S390 port. 632 </p> 633 </dd> 634 635 <dl id="encoding/asn1"><a href="/pkg/encoding/asn1/">encoding/asn1</a></dl> 636 637 <dd> 638 <p> 639 The ASN.1 decoder now rejects non-minimal integer encodings. 640 This may cause the package to reject some invalid but formerly accepted ASN.1 data. 641 </p> 642 </dd> 643 644 <dl id="encoding/json"><a href="/pkg/encoding/json/">encoding/json</a></dl> 645 646 <dd> 647 <p> 648 The 649 <a href="/pkg/encoding/json/#Encoder"><code>Encoder</code></a>'s new 650 <a href="/pkg/encoding/json/#Encoder.SetIndent"><code>SetIndent</code></a> method 651 sets the indentation parameters for JSON encoding, 652 like in the top-level 653 <a href="/pkg/encoding/json/#Indent"><code>Indent</code></a> function. 654 </p> 655 656 <p> 657 The 658 <a href="/pkg/encoding/json/#Encoder"><code>Encoder</code></a>'s new 659 <a href="/pkg/encoding/json/#Encoder.SetEscapeHTML"><code>SetEscapeHTML</code></a> method 660 controls whether the 661 <code>&</code>, <code><</code>, and <code>></code> 662 characters in quoted strings should be escaped as 663 <code>\u0026</code>, <code>\u003c</code>, and <code>\u003e</code>, 664 respectively. 665 As in previous releases, the encoder defaults to applying this escaping, 666 to avoid certain problems that can arise when embedding JSON in HTML. 667 </p> 668 669 <p> 670 In earlier versions of Go, this package only supported encoding and decoding 671 maps using keys with string types. 672 Go 1.7 adds support for maps using keys with integer types: 673 the encoding uses a quoted decimal representation as the JSON key. 674 Go 1.7 also adds support for encoding maps using non-string keys that implement 675 the <code>MarshalText</code> 676 (see 677 <a href="/pkg/encoding/#TextMarshaler"><code>encoding.TextMarshaler</code></a>) 678 method, 679 as well as support for decoding maps using non-string keys that implement 680 the <code>UnmarshalText</code> 681 (see 682 <a href="/pkg/encoding/#TextUnmarshaler"><code>encoding.TextUnmarshaler</code></a>) 683 method. 684 These methods are ignored for keys with string types in order to preserve 685 the encoding and decoding used in earlier versions of Go. 686 </p> 687 688 <p> 689 When encoding a slice of typed bytes, 690 <a href="/pkg/encoding/json/#Marshal"><code>Marshal</code></a> 691 now generates an array of elements encoded using 692 that byte type's 693 <code>MarshalJSON</code> 694 or 695 <code>MarshalText</code> 696 method if present, 697 only falling back to the default base64-encoded string data if neither method is available. 698 Earlier versions of Go accept both the original base64-encoded string encoding 699 and the array encoding (assuming the byte type also implements 700 <code>UnmarshalJSON</code> 701 or 702 <code>UnmarshalText</code> 703 as appropriate), 704 so this change should be semantically backwards compatible with earlier versions of Go, 705 even though it does change the chosen encoding. 706 </p> 707 </dd> 708 709 <dl id="go/build"><a href="/pkg/go/build/">go/build</a></dl> 710 711 <dd> 712 <p> 713 To implement the go command's new support for binary-only packages 714 and for Fortran code in cgo-based packages, 715 the 716 <a href="/pkg/go/build/#Package"><code>Package</code></a> type 717 adds new fields <code>BinaryOnly</code>, <code>CgoFFLAGS</code>, and <code>FFiles</code>. 718 </p> 719 </dd> 720 721 <dl id="go/doc"><a href="/pkg/go/doc/">go/doc</a></dl> 722 723 <dd> 724 <p> 725 To support the corresponding change in <code>go</code> <code>test</code> described above, 726 <a href="/pkg/go/doc/#Example"><code>Example</code></a> struct adds a Unordered field 727 indicating whether the example may generate its output lines in any order. 728 </p> 729 </dd> 730 731 <dl id="io"><a href="/pkg/io/">io</a></dl> 732 733 <dd> 734 <p> 735 The package adds new constants 736 <code>SeekStart</code>, <code>SeekCurrent</code>, and <code>SeekEnd</code>, 737 for use with 738 <a href="/pkg/io/#Seeker"><code>Seeker</code></a> 739 implementations. 740 These constants are preferred over <code>os.SEEK_SET</code>, <code>os.SEEK_CUR</code>, and <code>os.SEEK_END</code>, 741 but the latter will be preserved for compatibility. 742 </p> 743 </dd> 744 745 <dl id="math/big"><a href="/pkg/math/big/">math/big</a></dl> 746 747 <dd> 748 <p> 749 The 750 <a href="/pkg/math/big/#Float"><code>Float</code></a> type adds 751 <a href="/pkg/math/big/#Float.GobEncode"><code>GobEncode</code></a> and 752 <a href="/pkg/math/big/#Float.GobDecode"><code>GobDecode</code></a> methods, 753 so that values of type <code>Float</code> can now be encoded and decoded using the 754 <a href="/pkg/encoding/gob/"><code>encoding/gob</code></a> 755 package. 756 </p> 757 </dd> 758 759 <dl id="mime/multipart"><a href="/pkg/mime/multipart/">mime/multipart</a></dl> 760 761 <dd> 762 <p> 763 The 764 <a href="/pkg/mime/multipart/#Writer"><code>Writer</code></a> 765 implementation now emits each multipart section's header sorted by key. 766 Previously, iteration over a map caused the section header to use a 767 non-deterministic order. 768 </p> 769 </dd> 770 771 <dl id="net"><a href="/pkg/net/">net</a></dl> 772 773 <dd> 774 <p> 775 As part of the introduction of <a href="#context">context</a>, the 776 <a href="/pkg/net/#Dialer"><code>Dialer</code></a> type has a new method 777 <a href="/pkg/net/#Dialer.DialContext"><code>DialContext</code></a>, like 778 <a href="/pkg/net/#Dialer.Dial"><code>Dial</code></a> but adding the 779 <a href="/pkg/context/#Context"><code>context.Context</code></a> 780 for the dial operation. 781 The context is intended to obsolete the <code>Dialer</code>'s 782 <code>Cancel</code> and <code>Deadline</code> fields, 783 but the implementation continues to respect them, 784 for backwards compatibility. 785 </p> 786 787 <p> 788 The 789 <a href="/pkg/net/#IP"><code>IP</code></a> type's 790 <a href="/pkg/net/#IP.String"><code>String</code></a> method has changed its result for invalid <code>IP</code> addresses. 791 In past releases, if an <code>IP</code> byte slice had length other than 0, 4, or 16, <code>String</code> 792 returned <code>"?"</code>. 793 Go 1.7 adds the hexadecimal encoding of the bytes, as in <code>"?12ab"</code>. 794 </p> 795 796 <p> 797 The pure Go <a href="/pkg/net/#hdr-Name_Resolution">name resolution</a> 798 implementation now respects <code>nsswitch.conf</code>'s 799 stated preference for the priority of DNS lookups compared to 800 local file (that is, <code>/etc/hosts</code>) lookups. 801 </p> 802 </dd> 803 804 <dl id="net/http"><a href="/pkg/net/http/">net/http</a></dl> 805 806 <dd> 807 <p> 808 <a href="/pkg/net/http/#ResponseWriter"><code>ResponseWriter</code></a>'s 809 documentation now makes clear that beginning to write the response 810 may prevent future reads on the request body. 811 For maximal compatibility, implementations are encouraged to 812 read the request body completely before writing any part of the response. 813 </p> 814 815 <p> 816 As part of the introduction of <a href="#context">context</a>, the 817 <a href="/pkg/net/http/#Request"><code>Request</code></a> has a new methods 818 <a href="/pkg/net/http/#Request.Context"><code>Context</code></a>, to retrieve the associated context, and 819 <a href="/pkg/net/http/#Request.WithContext"><code>WithContext</code></a>, to construct a copy of <code>Request</code> 820 with a modified context. 821 </p> 822 823 <p> 824 In the 825 <a href="/pkg/net/http/#Server"><code>Server</code></a> implementation, 826 <a href="/pkg/net/http/#Server.Serve"><code>Serve</code></a> records in the request context 827 both the underlying <code>*Server</code> using the key <code>ServerContextKey</code> 828 and the local address on which the request was received (a 829 <a href="/pkg/net/#Addr"><code>Addr</code></a>) using the key <code>LocalAddrContextKey</code>. 830 For example, the address on which a request received is 831 <code>req.Context().Value(http.LocalAddrContextKey).(net.Addr)</code>. 832 </p> 833 834 <p> 835 The server implementation now 836 pads response codes less than 100 to three digits 837 as required by the protocol, 838 so that <code>w.WriteHeader(5)</code> uses the HTTP response 839 status <code>005</code>, not just <code>5</code>. 840 </p> 841 842 <p> 843 In the client, the 844 <a href="/pkg/net/http/#Transport"><code>Transport</code></a> implementation passes the request context 845 to any dial operation connecting to the remote server. 846 If a custom dialer is needed, the new <code>Transport</code> field 847 <code>DialContext</code> is preferred over the existing <code>Dial</code> field, 848 to allow the transport to supply a context. 849 </p> 850 851 <p> 852 The 853 <a href="/pkg/net/http/#Transport"><code>Transport</code></a> also adds fields 854 <code>IdleConnTimeout</code>, 855 <code>MaxIdleConns</code>, 856 and 857 <code>MaxResponseHeaderBytes</code> 858 to help control client resources consumed 859 by idle or chatty servers. 860 </p> 861 862 <p> 863 A 864 <a href="/pkg/net/http/#Client"><code>Client</code></a>'s configured <code>CheckRedirect</code> function can now 865 return <code>ErrUseLastResponse</code> to indicate that the 866 most recent redirect response should be returned as the 867 result of the HTTP request. 868 That response is now available to the <code>CheckRedirect</code> function 869 as <code>req.Response</code>. 870 </p> 871 872 <p> 873 Since Go 1, the default behavior of the HTTP client is 874 to request server-side compression 875 using the <code>Accept-Encoding</code> request header 876 and then to decompress the response body transparently, 877 and this behavior is adjustable using the 878 <a href="/pkg/net/http/#Transport"><code>Transport</code></a>'s <code>DisableCompression</code> field. 879 In Go 1.7, to aid the implementation of HTTP proxies, the 880 <a href="/pkg/net/http/#Response"><code>Response</code></a>'s new 881 <code>Uncompressed</code> field reports whether 882 this transparent decompression took place. 883 </p> 884 885 <p> 886 <a href="/pkg/net/http/#DetectContentType"><code>DetectContentType</code></a> 887 adds support for a few new audio and video content types. 888 </p> 889 </dd> 890 891 <dl id="net/http/cgi"><a href="/pkg/net/http/cgi/">net/http/cgi</a></dl> 892 893 <dd> 894 <p> 895 The 896 <a href="/pkg/net/http/cgi/#Handler"><code>Handler</code></a> 897 adds a new field 898 <code>Stderr</code> 899 that allows redirection of the child process's 900 standard error away from the host process's 901 standard error. 902 </p> 903 </dd> 904 905 <dl id="net/http/httptest"><a href="/pkg/net/http/httptest/">net/http/httptest</a></dl> 906 907 <dd> 908 <p> 909 The new function 910 <a href="/pkg/net/http/httptest/#NewRequest"><code>NewRequest</code></a> 911 prepares a new 912 <a href="/pkg/net/http/#Request"><code>http.Request</code></a> 913 suitable for passing to an 914 <a href="/pkg/net/http/#Handler"><code>http.Handler</code></a> during a test. 915 </p> 916 917 <p> 918 The 919 <a href="/pkg/net/http/httptest/#ResponseRecorder"><code>ResponseRecorder</code></a>'s new 920 <a href="/pkg/net/http/httptest/#ResponseRecorder.Result"><code>Result</code></a> method 921 returns the recorded 922 <a href="/pkg/net/http/#Response"><code>http.Response</code></a>. 923 Tests that need to check the response's headers or trailers 924 should call <code>Result</code> and inspect the response fields 925 instead of accessing 926 <code>ResponseRecorder</code>'s <code>HeaderMap</code> directly. 927 </p> 928 </dd> 929 930 <dl id="net/http/httputil"><a href="/pkg/net/http/httputil/">net/http/httputil</a></dl> 931 932 <dd> 933 <p> 934 The 935 <a href="/pkg/net/http/httputil/#ReverseProxy"><code>ReverseProxy</code></a> implementation now responds with “502 Bad Gateway” 936 when it cannot reach a back end; in earlier releases it responded with “500 Internal Server Error.” 937 </p> 938 939 <p> 940 Both 941 <a href="/pkg/net/http/httputil/#ClientConn"><code>ClientConn</code></a> and 942 <a href="/pkg/net/http/httputil/#ServerConn"><code>ServerConn</code></a> have been documented as deprecated. 943 They are low-level, old, and unused by Go's current HTTP stack 944 and will no longer be updated. 945 Programs should use 946 <a href="/pkg/net/http/#Client"><code>http.Client</code></a>, 947 <a href="/pkg/net/http/#Transport"><code>http.Transport</code></a>, 948 and 949 <a href="/pkg/net/http/#Server"><code>http.Server</code></a> 950 instead. 951 </p> 952 </dd> 953 954 <dl id="net/http/pprof"><a href="/pkg/net/http/pprof/">net/http/pprof</a></dl> 955 956 <dd> 957 <p> 958 The runtime trace HTTP handler, installed to handle the path <code>/debug/pprof/trace</code>, 959 now accepts a fractional number in its <code>seconds</code> query parameter, 960 allowing collection of traces for intervals smaller than one second. 961 This is especially useful on busy servers. 962 </p> 963 </dd> 964 965 <dl><a href="/pkg/net/mail/">net/mail</a></dl> 966 967 <dd> 968 <p> 969 The address parser now allows unescaped UTF-8 text in addresses 970 following <a href="https://tools.ietf.org/html/rfc6532">RFC 6532</a>, 971 but it does not apply any normalization to the result. 972 For compatibility with older mail parsers, 973 the address encoder, namely 974 <a href="/pkg/net/mail/#Address"><code>Address</code></a>'s 975 <a href="/pkg/net/mail/#Address.String"><code>String</code></a> method, 976 continues to escape all UTF-8 text following <a href="https://tools.ietf.org/html/rfc5322">RFC 5322</a>. 977 </p> 978 979 <p> 980 The <a href="/pkg/net/mail/#ParseAddress"><code>ParseAddress</code></a> 981 function and 982 the <a href="/pkg/net/mail/#AddressParser.Parse"><code>AddressParser.Parse</code></a> 983 method are stricter. 984 They used to ignore any characters following an e-mail address, but 985 will now return an error for anything other than whitespace. 986 </p> 987 </dd> 988 989 <dl id="net/url"><a href="/pkg/net/url/">net/url</a></dl> 990 991 <dd> 992 <p> 993 The 994 <a href="/pkg/net/url/#URL"><code>URL</code></a>'s 995 new <code>ForceQuery</code> field 996 records whether the URL must have a query string, 997 in order to distinguish URLs without query strings (like <code>/search</code>) 998 from URLs with empty query strings (like <code>/search?</code>). 999 </p> 1000 </dd> 1001 1002 <dl id="os"><a href="/pkg/os/">os</a></dl> 1003 1004 <dd> 1005 <p> 1006 <a href="/pkg/os/#IsExists"><code>IsExists</code></a> now returns true for <code>syscall.ENOTEMPTY</code>, 1007 on systems where that error exists. 1008 </p> 1009 1010 <p> 1011 On Windows, 1012 <a href="/pkg/os/#Remove"><code>Remove</code></a> now removes read-only files when possible, 1013 making the implementation behave as on 1014 non-Windows systems. 1015 </p> 1016 </dd> 1017 1018 <dl id="os/exec"><a href="/pkg/os/exec/">os/exec</a></dl> 1019 1020 <dd> 1021 <p> 1022 As part of the introduction of <a href="#context">context</a>, 1023 the new constructor 1024 <a href="/pkg/os/exec/#CommandContext"><code>CommandContext</code></a> 1025 is like 1026 <a href="/pkg/os/exec/#Command"><code>Command</code></a> but includes a context that can be used to cancel the command execution. 1027 </p> 1028 </dd> 1029 1030 <dl id="os/user"><a href="/pkg/os/user/">os/user</a></dl> 1031 1032 <dd> 1033 <p> 1034 The 1035 <a href="/pkg/os/user/#Current"><code>Current</code></a> 1036 function is now implemented even when cgo is not available. 1037 </p> 1038 1039 <p> 1040 The new 1041 <a href="/pkg/os/user/#Group"><code>Group</code></a> type, 1042 along with the lookup functions 1043 <a href="/pkg/os/user/#LookupGroup"><code>LookupGroup</code></a> and 1044 <a href="/pkg/os/user/#LookupGroupId"><code>LookupGroupId</code></a> 1045 and the new field <code>GroupIds</code> in the <code>User</code> struct, 1046 provides access to system-specific user group information. 1047 </p> 1048 </dd> 1049 1050 <dl id="reflect"><a href="/pkg/reflect/">reflect</a></dl> 1051 1052 <dd> 1053 <p> 1054 Although 1055 <a href="/pkg/reflect/#Value"><code>Value</code></a>'s 1056 <a href="/pkg/reflect/#Value.Field"><code>Field</code></a> method has always been documented to panic 1057 if the given field number <code>i</code> is out of range, it has instead 1058 silently returned a zero 1059 <a href="/pkg/reflect/#Value"><code>Value</code></a>. 1060 Go 1.7 changes the method to behave as documented. 1061 </p> 1062 1063 <p> 1064 The new 1065 <a href="/pkg/reflect/#StructOf"><code>StructOf</code></a> 1066 function constructs a struct type at run time. 1067 It completes the set of type constructors, joining 1068 <a href="/pkg/reflect/#ArrayOf"><code>ArrayOf</code></a>, 1069 <a href="/pkg/reflect/#ChanOf"><code>ChanOf</code></a>, 1070 <a href="/pkg/reflect/#FuncOf"><code>FuncOf</code></a>, 1071 <a href="/pkg/reflect/#MapOf"><code>MapOf</code></a>, 1072 <a href="/pkg/reflect/#PtrTo"><code>PtrTo</code></a>, 1073 and 1074 <a href="/pkg/reflect/#SliceOf"><code>SliceOf</code></a>. 1075 </p> 1076 1077 <p> 1078 <a href="/pkg/reflect/#StructTag"><code>StructTag</code></a>'s 1079 new method 1080 <a href="/pkg/reflect/#StructTag.Lookup"><code>Lookup</code></a> 1081 is like 1082 <a href="/pkg/reflect/#StructTag.Get"><code>Get</code></a> 1083 but distinguishes the tag not containing the given key 1084 from the tag associating an empty string with the given key. 1085 </p> 1086 1087 <p> 1088 The 1089 <a href="/pkg/reflect/#Type.Method"><code>Method</code></a> and 1090 <a href="/pkg/reflect/#Type.NumMethod"><code>NumMethod</code></a> 1091 methods of 1092 <a href="/pkg/reflect/#Type"><code>Type</code></a> and 1093 <a href="/pkg/reflect/#Value"><code>Value</code></a> 1094 no longer return or count unexported methods. 1095 </p> 1096 </dd> 1097 1098 <dl id="strings"><a href="/pkg/strings/">strings</a></dl> 1099 1100 <dd> 1101 <p> 1102 In previous releases of Go, if 1103 <a href="/pkg/strings/#Reader"><code>Reader</code></a>'s 1104 <a href="/pkg/strings/#Reader.Read"><code>Read</code></a> method 1105 were asked for zero bytes with no data remaining, it would 1106 return a count of 0 and no error. 1107 Now it returns a count of 0 and the error 1108 <a href="/pkg/io/#EOF"><code>io.EOF</code></a>. 1109 </p> 1110 1111 <p> 1112 The 1113 <a href="/pkg/strings/#Reader"><code>Reader</code></a> type has a new method 1114 <a href="/pkg/strings/#Reader.Reset"><code>Reset</code></a> to allow reuse of a <code>Reader</code>. 1115 </p> 1116 </dd> 1117 1118 <dl id="time"><a href="/pkg/time/">time</a></dl> 1119 1120 <dd> 1121 <p> 1122 <a href="/pkg/time/#Duration"><code>Duration</code></a>'s 1123 time.Duration.String method now reports the zero duration as <code>"0s"</code>, not <code>"0"</code>. 1124 <a href="/pkg/time/#ParseDuration"><code>ParseDuration</code></a> continues to accept both forms. 1125 </p> 1126 1127 <p> 1128 The method call <code>time.Local.String()</code> now returns <code>"Local"</code> on all systems; 1129 in earlier releases, it returned an empty string on Windows. 1130 </p> 1131 1132 <p> 1133 The time zone database in 1134 <code>$GOROOT/lib/time</code> has been updated 1135 to IANA release 2016d. 1136 This fallback database is only used when the system time zone database 1137 cannot be found, for example on Windows. 1138 The Windows time zone abbreviation list has also been updated. 1139 </p> 1140 </dd> 1141 1142 <dl id="syscall"><a href="/pkg/syscall/">syscall</a></dl> 1143 1144 <dd> 1145 <p> 1146 On Linux, the 1147 <a href="/pkg/syscall/#SysProcAttr"><code>SysProcAttr</code></a> struct 1148 (as used in 1149 <a href="/pkg/os/exec/#Cmd"><code>os/exec.Cmd</code></a>'s <code>SysProcAttr</code> field) 1150 has a new <code>Unshareflags</code> field. 1151 If the field is nonzero, the child process created by 1152 <a href="/pkg/syscall/#ForkExec"><code>ForkExec</code></a> 1153 (as used in <code>exec.Cmd</code>'s <code>Run</code> method) 1154 will call the 1155 <a href="http://man7.org/linux/man-pages/man2/unshare.2.html"><i>unshare</i>(2)</a> 1156 system call before executing the new program. 1157 </p> 1158 </dd>