github.com/eun/go@v0.0.0-20170811110501-92cfd07a6cfd/doc/go1.9.html (about) 1 <!--{ 2 "Title": "Go 1.9 Release Notes", 3 "Path": "/doc/go1.9", 4 "Template": true 5 }--> 6 7 <!-- 8 NOTE: In this document and others in this directory, the convention is to 9 set fixed-width phrases with non-fixed-width spaces, as in 10 <code>hello</code> <code>world</code>. 11 Do not send CLs removing the interior tags from such phrases. 12 --> 13 14 <style> 15 ul li { margin: 0.5em 0; } 16 </style> 17 18 <h2 id="introduction">DRAFT RELEASE NOTES - Introduction to Go 1.9</h2> 19 20 <p><strong> 21 Go 1.9 is not yet released. These are work-in-progress 22 release notes. Go 1.9 is expected to be released in August 2017. 23 </strong></p> 24 25 <p> 26 The latest Go release, version 1.9, arrives six months 27 after <a href="go1.8">Go 1.8</a> and is the tenth release in 28 the <a href="https://golang.org/doc/devel/release.html">Go 1.x 29 series</a>. 30 There are two <a href="#language">changes to the language</a>: 31 adding support for type aliases and defining when implementations 32 may fuse floating point operations. 33 Most of the changes are in the implementation of the toolchain, 34 runtime, and libraries. 35 As always, the release maintains the Go 1 36 <a href="/doc/go1compat.html">promise of compatibility</a>. 37 We expect almost all Go programs to continue to compile and run as 38 before. 39 </p> 40 41 <p> 42 The release 43 adds <a href="#monotonic-time">transparent monotonic time support</a>, 44 <a href="#parallel-compile">parallelizes compilation of functions</a> within a package, 45 better supports <a href="#test-helper">test helper functions</a>, 46 includes a new <a href="#math-bits">bit manipulation package</a>, 47 and has a new <a href="#sync-map">concurrent map type</a>. 48 </p> 49 50 <h2 id="language">Changes to the language</h2> 51 52 <p> 53 There are two changes to the language. 54 </p> 55 <p> 56 Go now supports type aliases to support gradual code repair while 57 moving a type between packages. 58 The <a href="https://golang.org/design/18130-type-alias">type alias 59 design document</a> 60 and <a href="https://talks.golang.org/2016/refactor.article">an 61 article on refactoring</a> cover the problem in detail. 62 In short, a type alias declaration has the form: 63 </p> 64 65 <pre> 66 type T1 = T2 67 </pre> 68 69 <p> 70 This declaration introduces an alias name <code>T1</code>—an 71 alternate spelling—for the type denoted by <code>T2</code>; that is, 72 both <code>T1</code> and <code>T2</code> denote the same type. 73 </p> 74 75 <p> <!-- CL 40391 --> 76 A smaller language change is that the 77 <a href="/ref/spec#Floating_point_operators">language specification 78 now states</a> when implementations are allowed to fuse floating 79 point operations together, such as by using an architecture's "fused 80 multiply and add" (FMA) instruction to compute <code>x*y</code> <code>+</code> <code>z</code> 81 without rounding the intermediate result <code>x*y</code>. 82 To force the intermediate rounding, write <code>float64(x*y)</code> <code>+</code> <code>z</code>. 83 </p> 84 85 <h2 id="ports">Ports</h2> 86 87 <p> 88 There are no new supported operating systems or processor 89 architectures in this release. 90 </p> 91 92 <h3 id="power8">ppc64x requires POWER8</h3> 93 94 <p> <!-- CL 36725, CL 36832 --> 95 Both <code>GOARCH=ppc64</code> and <code>GOARCH=ppc64le</code> now 96 require at least POWER8 support. In previous releases, 97 only <code>GOARCH=ppc64le</code> required POWER8 and the big 98 endian <code>ppc64</code> architecture supported older 99 hardware. 100 <p> 101 102 <h3 id="freebsd">FreeBSD</h3> 103 104 <p> 105 Go 1.9 is the last release that will run on FreeBSD 9.3, 106 which is already 107 <a href="https://www.freebsd.org/security/unsupported.html">unsupported by FreeBSD</a>. 108 Go 1.10 will require FreeBSD 10.3+. 109 </p> 110 111 <h3 id="openbsd">OpenBSD 6.0</h3> 112 113 <p> <!-- CL 40331 --> 114 Go 1.9 now enables PT_TLS generation for cgo binaries and thus 115 requires OpenBSD 6.0 or newer. Go 1.9 no longer supports 116 OpenBSD 5.9. 117 <p> 118 119 <h3 id="known_issues">Known Issues</h3> 120 121 <p> 122 There are some instabilities on FreeBSD that are known but not understood. 123 These can lead to program crashes in rare cases. 124 See <a href="https://golang.org/issue/15658">issue 15658</a>. 125 Any help in solving this FreeBSD-specific issue would be appreciated. 126 </p> 127 128 <p> 129 Go stopped running NetBSD builders during the Go 1.9 development 130 cycle due to NetBSD kernel crashes, up to and including NetBSD 7.1. 131 As Go 1.9 is being released, NetBSD 7.1.1 is being released with a fix. 132 However, at this time we have no NetBSD builders passing our test suite. 133 Any help investigating the 134 <a href="https://github.com/golang/go/labels/OS-NetBSD">various NetBSD issues</a> 135 would be appreciated. 136 </p> 137 138 <h2 id="tools">Tools</h2> 139 140 <h3 id="parallel-compile">Parallel Compilation</h3> 141 142 <p> 143 The Go compiler now supports compiling a package's functions in parallel, taking 144 advantage of multiple cores. This is in addition to the <code>go</code> command's 145 existing support for parallel compilation of separate packages. 146 Parallel compilation is on by default, but it can be disabled by setting the 147 environment variable <code>GO19CONCURRENTCOMPILATION</code> to <code>0</code>. 148 </p> 149 150 <h3 id="vendor-dotdotdot">Vendor matching with ./...</h3> 151 152 <p><!-- CL 38745 --> 153 By popular request, <code>./...</code> no longer matches packages 154 in <code>vendor</code> directories in tools accepting package names, 155 such as <code>go</code> <code>test</code>. To match vendor 156 directories, write <code>./vendor/...</code>. 157 </p> 158 159 <h3 id="goroot">Moved GOROOT</h3> 160 161 <p><!-- CL 42533 --> 162 The <a href="/cmd/go/">go tool</a> will now use the path from which it 163 was invoked to attempt to locate the root of the Go install tree. 164 This means that if the entire Go installation is moved to a new 165 location, the go tool should continue to work as usual. 166 This may be overriden by setting <code>GOROOT</code> in the environment, 167 which should only be done in unusual circumstances. 168 Note that this does not affect the result of 169 the <a href="/pkg/runtime/#GOROOT">runtime.GOROOT</a> function, which 170 will continue to report the original installation location; 171 this may be fixed in later releases. 172 </p> 173 174 <h3 id="compiler">Compiler Toolchain</h3> 175 176 <p><!-- CL 37441 --> 177 Complex division is now C99-compatible. This has always been the 178 case in gccgo and is now fixed in the gc toolchain. 179 </p> 180 181 <p> <!-- CL 36983 --> 182 The linker will now generate DWARF information for cgo executables on Windows. 183 </p> 184 185 <p> <!-- CL 44210, CL 40095 --> 186 The compiler now includes lexical scopes in the generated DWARF if the 187 <code>-N -l</code> flags are provided, allowing 188 debuggers to hide variables that are not in scope. The <code>.debug_info</code> 189 section is now DWARF version 4. 190 </p> 191 192 <p> <!-- CL 43855 --> 193 The values of <code>GOARM</code> and <code>GO386</code> now affect a 194 compiled package's build ID, as used by the <code>go</code> tool's 195 dependency caching. 196 </p> 197 198 <h3 id="asm">Assembler</h3> 199 200 <p> <!-- CL 42028 --> 201 The four-operand ARM <code>MULA</code> instruction is now assembled correctly, 202 with the addend register as the third argument and the result 203 register as the fourth and final argument. 204 In previous releases, the two meanings were reversed. 205 The three-operand form, in which the fourth argument is implicitly 206 the same as the third, is unaffected. 207 Code using four-operand <code>MULA</code> instructions 208 will need to be updated, but we believe this form is very rarely used. 209 <code>MULAWT</code> and <code>MULAWB</code> were already 210 using the correct order in all forms and are unchanged. 211 </p> 212 213 <p> <!-- CL 42990 --> 214 The assembler now supports <code>ADDSUBPS/PD</code>, completing the 215 two missing x86 SSE3 instructions. 216 </p> 217 218 <h3 id="go-doc">Doc</h3> 219 220 <p><!-- CL 36031 --> 221 Long lists of arguments are now truncated. This improves the readability 222 of <code>go</code> <code>doc</code> on some generated code. 223 </p> 224 225 <p><!-- CL 38438 --> 226 Viewing documentation on struct fields is now supported. 227 For example, <code>go</code> <code>doc</code> <code>http.Client.Jar</code>. 228 </p> 229 230 <h3 id="go-env-json">Env</h3> 231 232 <p> <!-- CL 38757 --> 233 The new <code>go</code> <code>env</code> <code>-json</code> flag 234 enables JSON output, instead of the default OS-specific output 235 format. 236 </p> 237 238 <h3 id="go-test-list">Test</h3> 239 240 <p> <!-- CL 41195 --> 241 The <a href="/cmd/go/#hdr-Description_of_testing_flags"><code>go</code> <code>test</code></a> 242 command accepts a new <code>-list</code> flag, which takes a regular 243 expression as an argument and prints to stdout the name of any 244 tests, benchmarks, or examples that match it, without running them. 245 </p> 246 247 248 <h3 id="go-tool-pprof">Pprof</h3> 249 250 <p> <!-- CL 34192 --> 251 Profiles produced by the <code>runtime/pprof</code> package now 252 include symbol information, so they can be viewed 253 in <code>go</code> <code>tool</code> <code>pprof</code> 254 without the binary that produced the profile. 255 </p> 256 257 <p> <!-- CL 38343 --> 258 The <code>go</code> <code>tool</code> <code>pprof</code> command now 259 uses the HTTP proxy information defined in the environment, using 260 <a href="/pkg/net/http/#ProxyFromEnvironment"><code>http.ProxyFromEnvironment</code></a>. 261 </p> 262 263 <h3 id="vet">Vet</h3> 264 265 <!-- CL 40112 --> 266 <p> 267 The <a href="/cmd/vet/"><code>vet</code> command</a> 268 has been better integrated into the 269 <a href="/cmd/go/"><code>go</code> tool</a>, 270 so <code>go</code> <code>vet</code> now supports all standard build 271 flags while <code>vet</code>'s own flags are now available 272 from <code>go</code> <code>vet</code> as well as 273 from <code>go</code> <code>tool</code> <code>vet</code>. 274 </p> 275 276 <h3 id="gccgo">Gccgo</h3> 277 278 <p> 279 Due to the alignment of Go's semiannual release schedule with GCC's 280 annual release schedule, 281 GCC release 7 contains the Go 1.8.3 version of gccgo. 282 We expect that the next release, GCC 8, will contain the Go 1.10 283 version of gccgo. 284 </p> 285 286 <h2 id="runtime">Runtime</h2> 287 288 <h3 id="callersframes">Call stacks with inlined frames</h3> 289 290 <p> 291 Users of 292 <a href="/pkg/runtime#Callers"><code>runtime.Callers</code></a> 293 should avoid directly inspecting the resulting PC slice and instead use 294 <a href="/pkg/runtime#CallersFrames"><code>runtime.CallersFrames</code></a> 295 to get a complete view of the call stack, or 296 <a href="/pkg/runtime#Caller"><code>runtime.Caller</code></a> 297 to get information about a single caller. 298 This is because an individual element of the PC slice cannot account 299 for inlined frames or other nuances of the call stack. 300 </p> 301 302 <p> 303 Specifically, code that directly iterates over the PC slice and uses 304 functions such as 305 <a href="/pkg/runtime#FuncForPC"><code>runtime.FuncForPC</code></a> 306 to resolve each PC individually will miss inlined frames. 307 To get a complete view of the stack, such code should instead use 308 <code>CallersFrames</code>. 309 Likewise, code should not assume that the length returned by 310 <code>Callers</code> is any indication of the call depth. 311 It should instead count the number of frames returned by 312 <code>CallersFrames</code>. 313 </p> 314 315 <p> 316 Code that queries a single caller at a specific depth should use 317 <code>Caller</code> rather than passing a slice of length 1 to 318 <code>Callers</code>. 319 </p> 320 321 <p> 322 <a href="/pkg/runtime#CallersFrames"><code>runtime.CallersFrames</code></a> 323 has been available since Go 1.7, so code can be updated prior to 324 upgrading to Go 1.9. 325 </p> 326 327 <h2 id="performance">Performance</h2> 328 329 <p> 330 As always, the changes are so general and varied that precise 331 statements about performance are difficult to make. Most programs 332 should run a bit faster, due to speedups in the garbage collector, 333 better generated code, and optimizations in the core library. 334 </p> 335 336 <h3 id="gc">Garbage Collector</h3> 337 338 <p> <!-- CL 37520 --> 339 Library functions that used to trigger stop-the-world garbage 340 collection now trigger concurrent garbage collection. 341 342 Specifically, <a href="/pkg/runtime/#GC"><code>runtime.GC</code></a>, 343 <a href="/pkg/runtime/debug/#SetGCPercent"><code>debug.SetGCPercent</code></a>, 344 and 345 <a href="/pkg/runtime/debug/#FreeOSMemory"><code>debug.FreeOSMemory</code></a>, 346 now trigger concurrent garbage collection, blocking only the calling 347 goroutine until the garbage collection is done. 348 </p> 349 350 <p> <!-- CL 34103, CL 39835 --> 351 The 352 <a href="/pkg/runtime/debug/#SetGCPercent"><code>debug.SetGCPercent</code></a> 353 function only triggers a garbage collection if one is immediately 354 necessary because of the new GOGC value. 355 This makes it possible to adjust GOGC on-the-fly. 356 </p> 357 358 <p> <!-- CL 38732 --> 359 Large object allocation performance is significantly improved in 360 applications using large (>50GB) heaps containing many large 361 objects. 362 </p> 363 364 <p> <!-- CL 34937 --> 365 The <a href="/pkg/runtime/#ReadMemStats"><code>runtime.ReadMemStats</code></a> 366 function now takes less than 100µs even for very large heaps. 367 </p> 368 369 <h2 id="library">Core library</h2> 370 371 <h3 id="monotonic-time">Transparent Monotonic Time support</h3> 372 373 <p> <!-- CL 36255 --> 374 The <a href="/pkg/time/"><code>time</code></a> package now transparently 375 tracks monotonic time in each <a href="/pkg/time/#Time"><code>Time</code></a> 376 value, making computing durations between two <code>Time</code> values 377 a safe operation in the presence of wall clock adjustments. 378 See the <a href="/pkg/time/#hdr-Monotonic_Clocks">package docs</a> and 379 <a href="https://golang.org/design/12914-monotonic">design document</a> 380 for details. 381 </p> 382 383 <h3 id="math-bits">New bit manipulation package</h3> 384 385 <p> <!-- CL 36315 --> 386 Go 1.9 includes a new package, 387 <a href="/pkg/math/bits/"><code>math/bits</code></a>, with optimized 388 implementations for manipulating bits. On most architectures, 389 functions in this package are additionally recognized by the 390 compiler and treated as intrinsics for additional performance. 391 </p> 392 393 <h3 id="test-helper">Test Helper Functions</h3> 394 395 <p> <!-- CL 38796 --> 396 The 397 new <a href="/pkg/testing/#T.Helper"><code>(*T).Helper</code></a> 398 and <a href="/pkg/testing/#B.Helper"><code>(*B).Helper</code></a> 399 methods mark the calling function as a test helper function. When 400 printing file and line information, that function will be skipped. 401 This permits writing test helper functions while still having useful 402 line numbers for users. 403 </p> 404 405 <h3 id="sync-map">Concurrent Map</h3> 406 407 <p> <!-- CL 36617 --> 408 The new <a href="/pkg/sync/#Map"><code>Map</code></a> type 409 in the <a href="/pkg/sync/"><code>sync</code></a> package 410 is a concurrent map with amortized-constant-time loads, stores, and 411 deletes. It is safe for multiple goroutines to call a <code>Map</code>'s methods 412 concurrently. 413 </p> 414 415 <h3 id="pprof-labels">Profiler Labels</h3> 416 417 <p><!-- CL 34198 --> 418 The <a href="/pkg/runtime/pprof"><code>runtime/pprof</code> package</a> 419 now supports adding labels to <code>pprof</code> profiler records. 420 Labels form a key-value map that is used to distinguish calls of the 421 same function in different contexts when looking at profiles 422 with the <a href="/cmd/pprof/"><code>pprof</code> command</a>. 423 The <code>pprof</code> package's 424 new <a href="/pkg/runtime/pprof/#Do"><code>Do</code> function</a> 425 runs code associated with some provided labels. Other new functions 426 in the package help work with labels. 427 </p> 428 429 </dl><!-- runtime/pprof --> 430 431 432 <h3 id="minor_library_changes">Minor changes to the library</h3> 433 434 <p> 435 As always, there are various minor changes and updates to the library, 436 made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a> 437 in mind. 438 </p> 439 440 <dl id="archive/zip"><dt><a href="/pkg/archive/zip/">archive/zip</a></dt> 441 <dd> 442 <p><!-- CL 39570 --> 443 The 444 ZIP <a href="/pkg/archive/zip/#Writer"><code>Writer</code></a> 445 now sets the UTF-8 bit in 446 the <a href="/pkg/archive/zip/#FileHeader.Flags"><code>FileHeader.Flags</code></a> 447 when appropriate. 448 </p> 449 450 </dl><!-- archive/zip --> 451 452 <dl id="crypto/rand"><dt><a href="/pkg/crypto/rand/">crypto/rand</a></dt> 453 <dd> 454 <p><!-- CL 43852 --> 455 On Linux, Go now calls the <code>getrandom</code> system call 456 without the <code>GRND_NONBLOCK</code> flag; it will now block 457 until the kernel has sufficient randomness. On kernels predating 458 the <code>getrandom</code> system call, Go continues to read 459 from <code>/dev/urandom</code>. 460 </p> 461 462 </dl><!-- crypto/rand --> 463 464 <dl id="crypto/x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt> 465 <dd> 466 <p><!-- CL 36093 --> 467 468 On Unix systems the environment 469 variables <code>SSL_CERT_FILE</code> 470 and <code>SSL_CERT_DIR</code> can now be used to override the 471 system default locations for the SSL certificate file and SSL 472 certificate files directory, respectively. 473 </p> 474 475 <p>The FreeBSD file <code>/usr/local/etc/ssl/cert.pem</code> is 476 now included in the certificate search path. 477 </p> 478 479 <p><!-- CL 36900 --> 480 481 The package now supports excluded domains in name constraints. 482 In addition to enforcing such constraints, 483 <a href="/pkg/crypto/x509/#CreateCertificate"><code>CreateCertificate</code></a> 484 will create certificates with excluded name constraints 485 if the provided template certificate has the new 486 field 487 <a href="/pkg/crypto/x509/#Certificate.ExcludedDNSDomains"><code>ExcludedDNSDomains</code></a> 488 populated. 489 </p> 490 491 <p><!-- CL 36696 --> 492 493 If any SAN extension, including with no DSN names, is present 494 in the certificate, then the Common Name from 495 <a href="/pkg/crypto/x509/#Certificate.Subject"><code>Subject</code></a> is ignored. 496 In previous releases, the code tested only whether DNS-name SANs were 497 present in a certificate. 498 </p> 499 500 </dl><!-- crypto/x509 --> 501 502 <dl id="database/sql"><dt><a href="/pkg/database/sql/">database/sql</a></dt> 503 <dd> 504 <p><!-- CL 35476 --> 505 The package will now use a cached <a href="/pkg/database/sql/#Stmt"><code>Stmt</code></a> if 506 available in <a href="/pkg/database/sql/#Tx.Stmt"><code>Tx.Stmt</code></a>. 507 This prevents statements from being re-prepared each time 508 <a href="/pkg/database/sql/#Tx.Stmt"><code>Tx.Stmt</code></a> is called. 509 </p> 510 511 <p><!-- CL 38533 --> 512 The package now allows drivers to implement their own argument checkers by implementing 513 <a href="/pkg/database/sql/driver/#NamedValueChecker"><code>driver.NamedValueChecker</code></a>. 514 This also allows drivers to support <code>OUTPUT</code> and <code>INOUT</code> parameter types. 515 <a href="/pkg/database/sql/#Out"><code>Out</code></a> should be used to return output parameters 516 when supported by the driver. 517 </p> 518 519 <p><!-- CL 39031 --> 520 <a href="/pkg/database/sql/#Rows.Scan"><code>Rows.Scan</code></a> can now scan user-defined string types. 521 Previously the package supported scanning into numeric types like <code>type</code> <code>Int</code> <code>int64</code>. It now also supports 522 scanning into string types like <code>type</code> <code>String</code> <code>string</code>. 523 </p> 524 525 <p><!-- CL 40694 --> 526 The new <a href="/pkg/database/sql/#DB.Conn"><code>DB.Conn</code></a> method returns the new 527 <a href="/pkg/database/sql/#Conn"><code>Conn</code></a> type representing an 528 exclusive connection to the database from the connection pool. All queries run on 529 a <a href="/pkg/database/sql/#Conn"><code>Conn</code></a> will use the same underlying 530 connection until <a href="/pkg/database/sql/#Conn.Close"><code>Conn.Close</code></a> is called 531 to return the connection to the connection pool. 532 </p> 533 534 </dl><!-- database/sql --> 535 536 <dl id="encoding/asn1"><dt><a href="/pkg/encoding/asn1/">encoding/asn1</a></dt> 537 <dd> 538 <p><!-- CL 38660 --> 539 The new 540 <a href="/pkg/encoding/asn1/#NullBytes"><code>NullBytes</code></a> 541 and 542 <a href="/pkg/encoding/asn1/#NullRawValue"><code>NullRawValue</code></a> 543 represent the ASN.1 NULL type. 544 </p> 545 546 </dl><!-- encoding/asn1 --> 547 548 <dl id="encoding/base32"><dt><a href="/pkg/encoding/base32/">encoding/base32</a></dt> 549 <dd> 550 <p><!-- CL 38634 --> 551 The new <a href="/pkg/encoding/base32/#Encoding.WithPadding">Encoding.WithPadding</a> 552 method adds support for custom padding characters and disabling padding. 553 </p> 554 555 </dl><!-- encoding/base32 --> 556 557 <dl id="encoding/csv"><dt><a href="/pkg/encoding/csv/">encoding/csv</a></dt> 558 <dd> 559 <p><!-- CL 41730 --> 560 The new field 561 <a href="/pkg/encoding/csv/#Reader.ReuseRecord"><code>Reader.ReuseRecord</code></a> 562 controls whether calls to 563 <a href="/pkg/encoding/csv/#Reader.Read"><code>Read</code></a> 564 may return a slice sharing the backing array of the previous 565 call's returned slice for improved performance. 566 </p> 567 568 </dl><!-- encoding/csv --> 569 570 <dl id="fmt"><dt><a href="/pkg/fmt/">fmt</a></dt> 571 <dd> 572 <p><!-- CL 37051 --> 573 The sharp flag ('<code>#</code>') is now supported when printing 574 floating point and complex numbers. It will always print a 575 decimal point 576 for <code>%e</code>, <code>%E</code>, <code>%f</code>, <code>%F</code>, <code>%g</code> 577 and <code>%G</code>; it will not remove trailing zeros 578 for <code>%g</code> and <code>%G</code>. 579 </p> 580 581 </dl><!-- fmt --> 582 583 <dl id="hash/fnv"><dt><a href="/pkg/hash/fnv/">hash/fnv</a></dt> 584 <dd> 585 <p><!-- CL 38356 --> 586 The package now includes 128-bit FNV-1 and FNV-1a hash support with 587 <a href="/pkg/hash/fnv/#New128"><code>New128</code></a> and 588 <a href="/pkg/hash/fnv/#New128a"><code>New128a</code></a>, respectively. 589 </p> 590 591 </dl><!-- hash/fnv --> 592 593 <dl id="html/template"><dt><a href="/pkg/html/template/">html/template</a></dt> 594 <dd> 595 <p><!-- CL 37880, CL 40936 --> 596 The package now reports an error if a predefined escaper (one of 597 "html", "urlquery" and "js") is found in a pipeline and does not match 598 what the auto-escaper would have decided on its own. 599 This avoids certain security or correctness issues. 600 Now use of one of these escapers is always either a no-op or an error. 601 (The no-op case eases migration from <a href="/pkg/text/template/">text/template</a>.) 602 </p> 603 604 </dl><!-- html/template --> 605 606 <dl id="image"><dt><a href="/pkg/image/">image</a></dt> 607 <dd> 608 <p><!-- CL 36734 --> 609 The <a href="/pkg/image/#Rectangle.Intersect"><code>Rectangle.Intersect</code></a> 610 method now returns a zero <code>Rectangle</code> when called on 611 adjacent but non-overlapping rectangles, as documented. In 612 earlier releases it would incorrectly return an empty but 613 non-zero <code>Rectangle</code>. 614 </p> 615 616 </dl><!-- image --> 617 618 <dl id="image/color"><dt><a href="/pkg/image/color/">image/color</a></dt> 619 <dd> 620 <p><!-- CL 36732 --> 621 The YCbCr to RGBA conversion formula has been tweaked to ensure 622 that rounding adjustments span the complete [0, 0xffff] RGBA 623 range. 624 </p> 625 626 </dl><!-- image/color --> 627 628 <dl id="image/png"><dt><a href="/pkg/image/png/">image/png</a></dt> 629 <dd> 630 <p><!-- CL 34150 --> 631 The new <a href="/pkg/image/png/#Encoder.BufferPool"><code>Encoder.BufferPool</code></a> 632 field allows specifying an <a href="/pkg/image/png/#EncoderBufferPool"><code>EncoderBufferPool</code></a>, 633 that will be used by the encoder to get temporary <code>EncoderBuffer</code> 634 buffers when encoding a PNG image. 635 636 The use of a <code>BufferPool</code> reduces the number of 637 memory allocations performed while encoding multiple images. 638 </p> 639 640 <p><!-- CL 38271 --> 641 The package now supports the decoding of transparent 8-bit 642 grayscale ("Gray8") images. 643 </p> 644 645 </dl><!-- image/png --> 646 647 <dl id="math/big"><dt><a href="/pkg/math/big/">math/big</a></dt> 648 <dd> 649 <p><!-- CL 36487 --> 650 The new 651 <a href="/pkg/math/big/#Int.IsInt64"><code>IsInt64</code></a> 652 and 653 <a href="/pkg/math/big/#Int.IsUint64"><code>IsUint64</code></a> 654 methods report whether an <code>Int</code> 655 may be represented as an <code>int64</code> or <code>uint64</code> 656 value. 657 </p> 658 659 </dl><!-- math/big --> 660 661 <dl id="mime/multipart"><dt><a href="/pkg/mime/multipart/">mime/multipart</a></dt> 662 <dd> 663 <p><!-- CL 39223 --> 664 The new 665 <a href="/pkg/mime/multipart/#FileHeader.Size"><code>FileHeader.Size</code></a> 666 field describes the size of a file in a multipart message. 667 </p> 668 669 </dl><!-- mime/multipart --> 670 671 <dl id="net"><dt><a href="/pkg/net/">net</a></dt> 672 <dd> 673 <p><!-- CL 32572 --> 674 The new 675 <a href="/pkg/net/#Resolver.StrictErrors"><code>Resolver.StrictErrors</code></a> 676 provides control over how Go's built-in DNS resolver handles 677 temporary errors during queries composed of multiple sub-queries, 678 such as an A+AAAA address lookup. 679 </p> 680 681 <p><!-- CL 37260 --> 682 The new 683 <a href="/pkg/net/#Resolver.Dial"><code>Resolver.Dial</code></a> 684 allows a <code>Resolver</code> to use a custom dial function. 685 </p> 686 687 <p><!-- CL 40510 --> 688 <a href="/pkg/net/#JoinHostPort"><code>JoinHostPort</code></a> now only places an address in square brackets if the host contains a colon. 689 In previous releases it would also wrap addresses in square brackets if they contained a percent ('<code>%</code>') sign. 690 </p> 691 692 <p><!-- CL 37913 --> 693 The new methods 694 <a href="/pkg/net/#TCPConn.SyscallConn"><code>TCPConn.SyscallConn</code></a>, 695 <a href="/pkg/net/#IPConn.SyscallConn"><code>IPConn.SyscallConn</code></a>, 696 <a href="/pkg/net/#UDPConn.SyscallConn"><code>UDPConn.SyscallConn</code></a>, 697 and 698 <a href="/pkg/net/#UnixConn.SyscallConn"><code>UnixConn.SyscallConn</code></a> 699 provide access to the connections' underlying file descriptors. 700 </p> 701 702 <p><!-- 45088 --> 703 It is now safe to call <a href="/pkg/net/#Dial"><code>Dial</code></a> with the address obtained from 704 <code>(*TCPListener).String()</code> after creating the listener with 705 <code><a href="/pkg/net/#Listen">Listen</a>("tcp", ":0")</code>. 706 Previously it failed on some machines with half-configured IPv6 stacks. 707 </p> 708 709 </dl><!-- net --> 710 711 <dl id="net/http"><dt><a href="/pkg/net/http/">net/http</a></dt> 712 <dd> 713 714 <p><!-- CL 37328 --> 715 The <a href="/pkg/net/http/#Cookie.String"><code>Cookie.String</code></a> method, used for 716 <code>Cookie</code> and <code>Set-Cookie</code> headers, now encloses values in double quotes 717 if the value contains either a space or a comma. 718 </p> 719 720 <p>Server changes:</p> 721 <ul> 722 <li><!-- CL 38194 --> 723 <a href="/pkg/net/http/#ServeMux"><code>ServeMux</code></a> now ignores ports in the host 724 header when matching handlers. The host is matched unmodified for <code>CONNECT</code> requests. 725 </li> 726 727 <li><!-- CL 44074 --> 728 The new <a href="/pkg/net/http/#Server.ServeTLS"><code>Server.ServeTLS</code></a> method wraps 729 <a href="/pkg/net/http/#Server.Serve"><code>Server.Serve</code></a> with added TLS support. 730 </li> 731 732 <li><!-- CL 34727 --> 733 <a href="/pkg/net/http/#Server.WriteTimeout"><code>Server.WriteTimeout</code></a> 734 now applies to HTTP/2 connections and is enforced per-stream. 735 </li> 736 737 <li><!-- CL 43231 --> 738 HTTP/2 now uses the priority write scheduler by default. 739 Frames are scheduled by following HTTP/2 priorities as described in 740 <a href="https://tools.ietf.org/html/rfc7540#section-5.3">RFC 7540 Section 5.3</a>. 741 </li> 742 743 <li><!-- CL 36483 --> 744 The HTTP handler returned by <a href="/pkg/net/http/#StripPrefix"><code>StripPrefix</code></a> 745 now calls its provided handler with a modified clone of the original <code>*http.Request</code>. 746 Any code storing per-request state in maps keyed by <code>*http.Request</code> should 747 use 748 <a href="/pkg/net/http/#Request.Context"><code>Request.Context</code></a>, 749 <a href="/pkg/net/http/#Request.WithContext"><code>Request.WithContext</code></a>, 750 and 751 <a href="/pkg/context/#WithValue"><code>context.WithValue</code></a> instead. 752 </li> 753 </ul> 754 755 <p>Client & Transport changes:</p> 756 <ul> 757 <li><!-- CL 35488 --> 758 The <a href="/pkg/net/http/#Transport"><code>Transport</code></a> 759 now supports making requests via SOCKS5 proxy when the URL returned by 760 <a href="/pkg/net/http/#Transport.Proxy"><code>Transport.Proxy</code></a> 761 has the scheme <code>socks5</code>. 762 </li> 763 </ul> 764 765 </dl><!-- net/http --> 766 767 <dl id="net/http/fcgi"><dt><a href="/pkg/net/http/fcgi/">net/http/fcgi</a></dt> 768 <dd> 769 <p><!-- CL 40012 --> 770 The new 771 <a href="/pkg/net/http/fcgi/#ProcessEnv"><code>ProcessEnv</code></a> 772 function returns FastCGI environment variables associated with an HTTP request 773 for which there are no appropriate 774 <a href="/pkg/net/http/#Request"><code>http.Request</code></a> 775 fields, such as <code>REMOTE_USER</code>. 776 </p> 777 778 </dl><!-- net/http/fcgi --> 779 780 <dl id="net/http/httptest"><dt><a href="/pkg/net/http/httptest/">net/http/httptest</a></dt> 781 <dd> 782 <p><!-- CL 34639 --> 783 The new 784 <a href="/pkg/net/http/httptest/#Server.Client"><code>Server.Client</code></a> 785 method returns an HTTP client configured for making requests to the test server. 786 </p> 787 788 <p> 789 The new 790 <a href="/pkg/net/http/httptest/#Server.Certificate"><code>Server.Certificate</code></a> 791 method returns the test server's TLS certificate, if any. 792 </p> 793 794 </dl><!-- net/http/httptest --> 795 796 <dl id="net/http/httputil"><dt><a href="/pkg/net/http/httputil/">net/http/httputil</a></dt> 797 <dd> 798 <p><!-- CL 43712 --> 799 The <a href="/pkg/net/http/httputil/#ReverseProxy"><code>ReverseProxy</code></a> 800 now proxies all HTTP/2 response trailers, even those not declared in the initial response 801 header. Such undeclared trailers are used by the gRPC protocol. 802 </p> 803 804 </dl><!-- net/http/httputil --> 805 806 <dl id="os"><dt><a href="/pkg/os/">os</a></dt> 807 <dd> 808 <p><!-- CL 36800 --> 809 The <code>os</code> package now uses the internal runtime poller 810 for file I/O. 811 This reduces the number of threads required for read/write 812 operations on pipes, and it eliminates races when one goroutine 813 closes a file while another is using the file for I/O. 814 </p> 815 816 <dd> 817 <p><!-- CL 37915 --> 818 On Windows, 819 <a href="/pkg/os/#Args"><code>Args</code></a> 820 is now populated without <code>shell32.dll</code>, improving process start-up time by 1-7 ms. 821 </p> 822 823 </dl><!-- os --> 824 825 <dl id="os/exec"><dt><a href="/pkg/os/exec/">os/exec</a></dt> 826 <dd> 827 <p><!-- CL 37586 --> 828 The <code>os/exec</code> package now prevents child processes from being created with 829 any duplicate environment variables. 830 If <a href="/pkg/os/exec/#Cmd.Env"><code>Cmd.Env</code></a> 831 contains duplicate environment keys, only the last 832 value in the slice for each duplicate key is used. 833 </p> 834 835 </dl><!-- os/exec --> 836 837 <dl id="os/user"><dt><a href="/pkg/os/user/">os/user</a></dt> 838 <dd> 839 <p><!-- CL 37664 --> 840 <a href="/pkg/os/user/#Lookup"><code>Lookup</code></a> and 841 <a href="/pkg/os/user/#LookupId"><code>LookupId</code></a> now 842 work on Unix systems when <code>CGO_ENABLED=0</code> by reading 843 the <code>/etc/passwd</code> file. 844 </p> 845 846 <p><!-- CL 33713 --> 847 <a href="/pkg/os/user/#LookupGroup"><code>LookupGroup</code></a> and 848 <a href="/pkg/os/user/#LookupGroupId"><code>LookupGroupId</code></a> now 849 work on Unix systems when <code>CGO_ENABLED=0</code> by reading 850 the <code>/etc/group</code> file. 851 </p> 852 853 </dl><!-- os/user --> 854 855 <dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt> 856 <dd> 857 <p><!-- CL 38335 --> 858 The new 859 <a href="/pkg/reflect/#MakeMapWithSize"><code>MakeMapWithSize</code></a> 860 function creates a map with a capacity hint. 861 </p> 862 863 </dl><!-- reflect --> 864 865 <dl id="runtime"><dt><a href="/pkg/runtime/">runtime</a></dt> 866 <dd> 867 <p><!-- CL 37233, CL 37726 --> 868 Tracebacks generated by the runtime and recorded in profiles are 869 now accurate in the presence of inlining. 870 To retrieve tracebacks programmatically, applications should use 871 <a href="/pkg/runtime/#CallersFrames"><code>runtime.CallersFrames</code></a> 872 rather than directly iterating over the results of 873 <a href="/pkg/runtime/#Callers"><code>runtime.Callers</code></a>. 874 </p> 875 876 <p><!-- CL 38403 --> 877 On Windows, Go no longer forces the system timer to run at high 878 resolution when the program is idle. 879 This should reduce the impact of Go programs on battery life. 880 </p> 881 882 <p><!-- CL 29341 --> 883 On FreeBSD, <code>GOMAXPROCS</code> and 884 <a href="/pkg/runtime/#NumCPU"><code>runtime.NumCPU</code></a> 885 are now based on the process' CPU mask, rather than the total 886 number of CPUs. 887 </p> 888 889 <p><!-- CL 43641 --> 890 The runtime has preliminary support for Android O. 891 </p> 892 893 </dl><!-- runtime --> 894 895 <dl id="runtime/debug"><dt><a href="/pkg/runtime/debug/">runtime/debug</a></dt> 896 <dd> 897 <p><!-- CL 34013 --> 898 Calling 899 <a href="/pkg/runtime/debug/#SetGCPercent"><code>SetGCPercent</code></a> 900 with a negative value no longer runs an immediate garbage collection. 901 </p> 902 903 </dl><!-- runtime/debug --> 904 905 <dl id="runtime/trace"><dt><a href="/pkg/runtime/trace/">runtime/trace</a></dt> 906 <dd> 907 <p><!-- CL 36015 --> 908 The execution trace now displays mark assist events, which 909 indicate when an application goroutine is forced to assist 910 garbage collection because it is allocating too quickly. 911 </p> 912 913 <p><!-- CL 40810 --> 914 "Sweep" events now encompass the entire process of finding free 915 space for an allocation, rather than recording each individual 916 span that is swept. 917 This reduces allocation latency when tracing allocation-heavy 918 programs. 919 The sweep event shows how many bytes were swept and how many 920 were reclaimed. 921 </p> 922 923 </dl><!-- runtime/trace --> 924 925 <dl id="sync"><dt><a href="/pkg/sync/">sync</a></dt> 926 <dd> 927 <p><!-- CL 34310 --> 928 <a href="/pkg/sync/#Mutex"><code>Mutex</code></a> is now more fair. 929 </p> 930 931 </dl><!-- sync --> 932 933 <dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt> 934 <dd> 935 <p><!-- CL 36697 --> 936 The new field 937 <a href="/pkg/syscall/#Credential.NoSetGroups"><code>Credential.NoSetGroups</code></a> 938 controls whether Unix systems make a <code>setgroups</code> system call 939 to set supplementary groups when starting a new process. 940 </p> 941 942 <p><!-- CL 43512 --> 943 The new field 944 <a href="/pkg/syscall/#SysProcAttr.AmbientCaps"><code>SysProcAttr.AmbientCaps</code></a> 945 allows setting ambient capabilities on Linux 4.3+ when creating 946 a new process. 947 </p> 948 949 <p><!-- CL 37439 --> 950 On 64-bit x86 Linux, process creation latency has been optimized with 951 use of <code>CLONE_VFORK</code> and <code>CLONE_VM</code>. 952 </p> 953 954 <p><!-- CL 37913 --> 955 The new 956 <a href="/pkg/syscall/#Conn"><code>Conn</code></a> 957 interface describes some types in the 958 <a href="/pkg/net/"><code>net</code></a> 959 package that can provide access to their underlying file descriptor 960 using the new 961 <a href="/pkg/syscall/#RawConn"><code>RawConn</code></a> 962 interface. 963 </p> 964 965 </dl><!-- syscall --> 966 967 968 <dl id="testing/quick"><dt><a href="/pkg/testing/quick/">testing/quick</a></dt> 969 <dd> 970 <p><!-- CL 39152 --> 971 The package now chooses values in the full range when 972 generating <code>int64</code> and <code>uint64</code> random 973 numbers; in earlier releases generated values were always 974 limited to the [-2<sup>62</sup>, 2<sup>62</sup>) range. 975 </p> 976 977 <p> 978 In previous releases, using a nil 979 <a href="/pkg/testing/quick/#Config.Rand"><code>Config.Rand</code></a> 980 value caused a fixed deterministic random number generator to be used. 981 It now uses a random number generator seeded with the current time. 982 For the old behavior, set <code>Config.Rand</code> to <code>rand.New(rand.NewSource(0))</code>. 983 </p> 984 985 </dl><!-- testing/quick --> 986 987 <dl id="text/template"><dt><a href="/pkg/text/template/">text/template</a></dt> 988 <dd> 989 <p><!-- CL 38420 --> 990 The handling of empty blocks, which was broken by a Go 1.8 991 change that made the result dependent on the order of templates, 992 has been fixed, restoring the old Go 1.7 behavior. 993 </p> 994 995 </dl><!-- text/template --> 996 997 <dl id="time"><dt><a href="/pkg/time/">time</a></dt> 998 <dd> 999 <p><!-- CL 36615 --> 1000 The new methods 1001 <a href="/pkg/time/#Duration.Round"><code>Duration.Round</code></a> 1002 and 1003 <a href="/pkg/time/#Duration.Truncate"><code>Duration.Truncate</code></a> 1004 handle rounding and truncating durations to multiples of a given duration. 1005 </p> 1006 1007 <p><!-- CL 35710 --> 1008 Retrieving the time and sleeping now work correctly under Wine. 1009 </p> 1010 1011 <p> 1012 If a <code>Time</code> value has a monotonic clock reading, its 1013 string representation (as returned by <code>String</code>) now includes a 1014 final field <code>"m=±value"</code>, where <code>value</code> is the 1015 monotonic clock reading formatted as a decimal number of seconds. 1016 </p> 1017 1018 <p><!-- CL 44832 --> 1019 The included <code>tzdata</code> timezone database has been 1020 updated to version 2017b. As always, it is only used if the 1021 system does not already have the database available. 1022 </p> 1023 1024 </dl><!-- time -->