github.com/stingnevermore/go@v0.0.0-20180120041312-3810f5bfed72/doc/go1.10.html (about) 1 <!--{ 2 "Title": "Go 1.10 Release Notes", 3 "Path": "/doc/go1.10", 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.10</h2> 19 20 <p><strong> 21 Go 1.10 is not yet released. These are work-in-progress 22 release notes. Go 1.10 is expected to be released in February 2018. 23 </strong></p> 24 25 <p> 26 The latest Go release, version 1.10, arrives six months after <a href="go1.9">go1.9</a>. 27 Most of its changes are in the implementation of the toolchain, runtime, and libraries. 28 As always, the release maintains the Go 1 <a href="/doc/go1compat.html">promise of compatibility</a>. 29 We expect almost all Go programs to continue to compile and run as before. 30 </p> 31 32 <p> 33 OVERVIEW HERE 34 </p> 35 36 <h2 id="language">Changes to the language</h2> 37 38 <p> 39 There are no significant changes to the language. 40 </p> 41 42 <p><!-- CL 60230 --> 43 A corner case involving shifts by untyped constants has been clarified, 44 and as a result the compilers have been updated to allow the index expression 45 <code>x[1.0</code> <code><<</code> <code>s]</code> where <code>s</code> is an untyped constant; 46 the <a href="/pkg/go/types/">go/types</a> package already did. 47 </p> 48 49 <p><!-- CL 73233 --> 50 The grammar for method expressions has been updated to relax the 51 syntax to allow any type expression as a receiver; 52 this matches what the compilers were already implementing. 53 For example, <code>struct{io.Reader}.Read</code> is a valid, if unusual, 54 method expression that the compilers already accepted and is 55 now permitted by the language grammar. 56 </p> 57 58 <h2 id="ports">Ports</h2> 59 60 <p> 61 There are no new supported operating systems or processor architectures in this release. 62 Most of the work has focused on strengthening the support for existing ports, 63 in particular <a href="#asm">new instructions in the assembler</a> 64 and improvements to the code generated by the compilers. 65 </p> 66 67 <p id="freebsd"> 68 As <a href="go1.9#freebsd">announced in the Go 1.9 release notes</a>, 69 Go 1.10 now requires FreeBSD 10.3 or later; 70 support for FreeBSD 9.3 has been removed. 71 </p> 72 73 <p id="netbsd"> 74 Go now runs on NetBSD again but requires the unreleased NetBSD 8. 75 Only <code>GOARCH</code> <code>amd64</code> and <code>386</code> have 76 been fixed. The <code>arm</code> port is still broken. 77 </p> 78 79 <p id="mips"> 80 On 32-bit MIPS systems, the new environment variable settings 81 <code>GOMIPS=hardfloat</code> (the default) and 82 <code>GOMIPS=softfloat</code> select whether to use 83 hardware instructions or software emulation for floating-point computations. 84 </p> 85 86 <p id="openbsd"> 87 Go 1.10 is the last release that will run on OpenBSD 6.0. 88 Go 1.11 will require OpenBSD 6.2. 89 </p> 90 91 <p id="darwin"> 92 Go 1.10 is the last release that will run on OS X 10.8 Mountain Lion or OS X 10.9 Mavericks. 93 Go 1.11 will require OS X 10.10 Yosemite or later. 94 </p> 95 96 <p id="windows"> 97 Go 1.10 is the last release that will run on Windows XP or Windows Vista. 98 Go 1.11 will require Windows 7 or later. 99 </p> 100 101 <h2 id="tools">Tools</h2> 102 103 <h3 id="goroot">Default GOROOT & GOTMPDIR</h3> 104 105 <p> 106 If the environment variable <code>$GOROOT</code> is unset, 107 the go tool previously used the default <code>GOROOT</code> 108 set during toolchain compilation. 109 Now, before falling back to that default, the go tool attempts to 110 deduce <code>GOROOT</code> from its own executable path. 111 This allows binary distributions to be unpacked anywhere in the 112 file system and then be used without setting <code>GOROOT</code> 113 explicitly. 114 </p> 115 116 <p> 117 By default, the go tool creates its temporary files and directories 118 in the system temporary directory (for example, <code>$TMPDIR</code> on Unix). 119 If the new environment variable <code>$GOTMPDIR</code> is set, 120 the go tool will creates its temporary files and directories in that directory instead. 121 </p> 122 123 <h3 id="build">Build & Install</h3> 124 125 <p> 126 The <code>go</code> <code>build</code> command now detects out-of-date packages 127 purely based on the content of source files, specified build flags, and metadata stored in the compiled packages. 128 Modification times are no longer consulted or relevant. 129 The old advice to add <code>-a</code> to force a rebuild in cases where 130 the modification times were misleading for one reason or another 131 (for example, changes in build flags) is no longer necessary: 132 builds now always detect when packages must be rebuilt. 133 (If you observe otherwise, please file a bug.) 134 </p> 135 136 <p> 137 The <code>go</code> <code>build</code> <code>-asmflags</code>, <code>-gcflags</code>, <code>-gccgoflags</code>, and <code>-ldflags</code> options 138 now apply by default only to the packages listed directly on the command line. 139 For example, <code>go</code> <code>build</code> <code>-gcflags=-m</code> <code>mypkg</code> 140 passes the compiler the <code>-m</code> flag when building <code>mypkg</code> 141 but not its dependencies. 142 The new, more general form <code>-asmflags=pattern=flags</code> (and similarly for the others) 143 applies the <code>flags</code> only to the packages matching the pattern. 144 For example: <code>go</code> <code>install</code> <code>-ldflags=cmd/gofmt=-X=main.version=1.2.3</code> <code>cmd/...</code> 145 installs all the commands matching <code>cmd/...</code> but only applies the <code>-X</code> option 146 to the linker flags for <code>cmd/gofmt</code>. 147 For more details, see <a href="/cmd/go/#hdr-Compile_packages_and_dependencies"><code>go</code> <code>help</code> <code>build</code></a>. 148 </p> 149 150 <p> 151 The <code>go</code> <code>build</code> command now maintains a cache of 152 recently built packages, separate from the installed packages in <code>$GOROOT/pkg</code> or <code>$GOPATH/pkg</code>. 153 The effect of the cache should be to speed builds that do not explicitly install packages 154 or when switching between different copies of source code (for example, when changing 155 back and forth between different branches in a version control system). 156 The old advice to add the <code>-i</code> flag for speed, as in <code>go</code> <code>build</code> <code>-i</code> 157 or <code>go</code> <code>test</code> <code>-i</code>, 158 is no longer necessary: builds run just as fast without <code>-i</code>. 159 For more details, see <a href="/cmd/go/#hdr-Build_and_test_caching"><code>go</code> <code>help</code> <code>cache</code></a>. 160 </p> 161 162 <p> 163 The <code>go</code> <code>install</code> command now installs only the 164 packages and commands listed directly on the command line. 165 For example, <code>go</code> <code>install</code> <code>cmd/gofmt</code> 166 installs the gofmt program but not any of the packages on which it depends. 167 The new build cache makes future commands still run as quickly as if the 168 dependencies had been installed. 169 To force the installation of dependencies, use the new 170 <code>go</code> <code>install</code> <code>-i</code> flag. 171 Installing dependency packages should not be necessary in general, 172 and the very concept of installed packages may disappear in a future release. 173 </p> 174 175 <p> 176 Many details of the <code>go</code> <code>build</code> implementation have changed to support these improvements. 177 One new requirement implied by these changes is that 178 binary-only packages must now declare accurate import blocks in their 179 stub source code, so that those imports can be made available when 180 linking a program using the binary-only package. 181 For more details, see <a href="/cmd/go/#hdr-File_types"><code>go</code> <code>help</code> <code>filetype</code></a>. 182 </p> 183 184 <h3 id="test">Test</h3> 185 186 <p> 187 The <code>go</code> <code>test</code> command now caches test results: 188 if the test executable and command line match a previous run 189 and the files and environment variables consulted by that run 190 have not changed either, <code>go</code> <code>test</code> will print 191 the previous test output, replacing the elapsed time with the string “(cached).” 192 Test caching applies only to successful test results; 193 only to <code>go</code> <code>test</code> 194 commands with an explicit list of packages; and 195 only to command lines using a subset of the 196 <code>-cpu</code>, <code>-list</code>, <code>-parallel</code>, 197 <code>-run</code>, <code>-short</code>, and <code>-v</code> test flags. 198 The idiomatic way to bypass test caching is to use <code>-count=1</code>. 199 </p> 200 201 <p> 202 The <code>go</code> <code>test</code> command now automatically runs 203 <code>go</code> <code>vet</code> on the package being tested, 204 to identify significant problems before running the test. 205 Any such problems are treated like build errors and prevent execution of the test. 206 Only a high-confidence subset of the available <code>go</code> <code>vet</code> 207 checks are enabled for this automatic check. 208 To disable the running of <code>go</code> <code>vet</code>, use 209 <code>go</code> <code>test</code> <code>-vet=off</code>. 210 </p> 211 212 <p> 213 The <code>go</code> <code>test</code> <code>-coverpkg</code> flag now 214 interprets its argument as a comma-separated list of patterns to match against 215 the dependencies of each test, not as a list of packages to load anew. 216 For example, <code>go</code> <code>test</code> <code>-coverpkg=all</code> 217 is now a meaningful way to run a test with coverage enabled for the test package 218 and all its dependencies. 219 Also, the <code>go</code> <code>test</code> <code>-coverprofile</code> option is now 220 supported when running multiple tests. 221 </p> 222 223 <p> 224 In case of failure due to timeout, tests are now more likely to write their profiles before exiting. 225 </p> 226 227 <p> 228 The <code>go</code> <code>test</code> command now always 229 merges the standard output and standard error from a given test binary execution 230 and writes both to <code>go</code> <code>test</code>'s standard output. 231 In past releases, <code>go</code> <code>test</code> only applied this 232 merging most of the time. 233 </p> 234 235 <p> 236 The <code>go</code> <code>test</code> <code>-v</code> output 237 now includes <code>PAUSE</code> and <code>CONT</code> status update 238 lines to mark when <a href="/pkg/testing/#T.Parallel">parallel tests</a> pause and continue. 239 </p> 240 241 <p> 242 The new <code>go</code> <code>test</code> <code>-failfast</code> flag 243 disables running additional tests after any test fails. 244 Note that tests running in parallel with the failing test are allowed to complete. 245 </p> 246 247 <p> 248 Finally, the new <code>go</code> <code>test</code> <code>-json</code> flag 249 filters test output through the new command 250 <code>go</code> <code>tool</code> <code>test2json</code> 251 to produce a machine-readable JSON-formatted description of test execution. 252 This allows the creation of rich presentations of test execution 253 in IDEs and other tools. 254 </p> 255 256 257 <p> 258 For more details about all these changes, 259 see <a href="/cmd/go/#hdr-Test_packages"><code>go</code> <code>help</code> <code>test</code></a> 260 and the <a href="/cmd/test2json/">test2json documentation</a>. 261 </p> 262 263 <h3 id="cgo">Cgo</h3> 264 265 <p> 266 Cgo now implements a C typedef like “<code>typedef</code> <code>X</code> <code>Y</code>;” using a Go type alias, 267 so that Go code may use the types <code>C.X</code> and <code>C.Y</code> interchangeably. 268 It also now supports the use of niladic function-like macros. 269 Also, the documentation has been updated to clarify that 270 Go structs and Go arrays are not supported in the type signatures of cgo-exported functions. 271 </p> 272 273 <p> 274 TODO: CL 70890 "permit passing string values directly between Go and C." 275 </p> 276 277 <p> 278 During toolchain bootstrap, the environment variables <code>CC</code> and <code>CC_FOR_TARGET</code> specify 279 the default C compiler that the resulting toolchain will use for host and target builds, respectively. 280 However, if the toolchain will be used with multiple targets, it may be necessary to specify a different C compiler for each 281 (for example, a different compiler for <code>darwin/arm64</code> versus <code>linux/ppc64le</code>). 282 The new set of environment variables <code>CC_FOR_<i>goos</i>_<i>goarch</i></code> 283 allows specifying a different default C compiler for each target. 284 Note that these variables only apply during toolchain bootstrap, 285 to set the defaults used by the resulting toolchain. 286 Later <code>go</code> <code>build</code> commands refer to the <code>CC</code> environment 287 variable or else the built-in default. 288 </p> 289 290 <p> 291 Cgo now translates some C types that would normally map to a pointer 292 type in Go, to a <code>uintptr</code> instead. These types include 293 the <code>CFTypeRef</code> hierarchy in Darwin's CoreFoundation 294 framework and the <code>jobject</code> hierarchy in Java's JNI 295 interface. 296 </p> 297 298 <p> 299 These types must be <code>uintptr</code> on the Go side because they 300 would otherwise confuse the Go garbage collector; they are sometimes 301 not really pointers but data structures encoded in a pointer type. 302 </p> 303 304 <p> 305 Because of this change, values of the affected types need to be 306 zero-initialized with the constant <code>0</code> instead of the 307 constant <code>nil</code>. Go 1.10 provides <code>gofix</code> 308 modules to help with that rewrite: 309 </p> 310 311 <pre> 312 go tool fix -r cftype <pkg> 313 go tool fix -r jni <pkg> 314 </pre> 315 316 <p> 317 For more details, see the <a href="/cmd/cgo/">cgo documentation</a>. 318 </p> 319 320 <h3 id="doc">Doc</h3> 321 322 <p> 323 The <code>go</code> <code>doc</code> tool now adds functions returning slices of <code>T</code> or <code>*T</code> 324 to the display of type <code>T</code>, similar to the existing behavior for functions returning single <code>T</code> or <code>*T</code> results. 325 For example: 326 </p> 327 328 <pre> 329 $ go doc mail.Address 330 package mail // import "net/mail" 331 332 type Address struct { 333 Name string 334 Address string 335 } 336 Address represents a single mail address. 337 338 func ParseAddress(address string) (*Address, error) 339 func ParseAddressList(list string) ([]*Address, error) 340 func (a *Address) String() string 341 $ 342 </pre> 343 344 <p> 345 Previously, <code>ParseAddressList</code> was only shown in the package overview (<code>go</code> <code>doc</code> <code>mail</code>). 346 </p> 347 348 <h3 id="fix">Fix</h3> 349 350 <p> 351 The <code>go</code> <code>fix</code> tool now replaces imports of <code>"golang.org/x/net/context"</code> 352 with <code>"context"</code>. 353 (Forwarding aliases in the former make it completely equivalent to the latter when using Go 1.9 or later.) 354 </p> 355 356 <h3 id="get">Get</h3> 357 358 <p> 359 The <code>go</code> <code>get</code> command now supports Fossil source code repositories. 360 </p> 361 362 <h3 id="pprof">Pprof</h3> 363 364 <p> 365 The blocking and mutex profiles produced by the <code>runtime/pprof</code> package 366 now include symbol information, so they can be viewed 367 in <code>go</code> <code>tool</code> <code>pprof</code> 368 without the binary that produced the profile. 369 (All other profile types were changed to include symbol information in Go 1.9.) 370 </p> 371 372 <p> 373 The <a href="/cmd/pprof/"><code>go</code> <code>tool</code> <code>pprof</code></a> 374 profile visualizer has been updated to git version 9e20b5b (2017-11-08) 375 from <a href="https://github.com/google/pprof">github.com/google/pprof</a>, 376 which includes an updated web interface. 377 </p> 378 379 <h3 id="vet">Vet</h3> 380 381 <p> 382 The <a href="/cmd/vet/"><code>go</code> <code>vet</code></a> command now always has access to 383 complete, up-to-date type information when checking packages, even for packages using cgo or vendored imports. 384 The reports should be more accurate as a result. 385 Note that only <code>go</code> <code>vet</code> has access to this information; 386 the more low-level <code>go</code> <code>tool</code> <code>vet</code> does not 387 and should be avoided except when working on <code>vet</code> itself. 388 (As of Go 1.9, <code>go</code> <code>vet</code> provides access to all the same flags as 389 <code>go</code> <code>tool</code> <code>vet</code>.) 390 </p> 391 392 <h3 id="diag">Diagnostics</h3> 393 394 <p> 395 This release includes a new <a href="/doc/diagnostics.html">overview of available Go program diagnostic tools</a>. 396 </p> 397 398 <h3 id="gofmt">Gofmt</h3> 399 400 <p> 401 Two minor details of the default formatting of Go source code have changed. 402 First, certain complex three-index slice expressions previously formatted like 403 <code>x[i+1</code> <code>:</code> <code>j:k]</code> and now 404 format with more consistent spacing: <code>x[i+1</code> <code>:</code> <code>j</code> <code>:</code> <code>k]</code>. 405 Second, single-method interface literals written on a single line, 406 which are sometimes used in type assertions, 407 are no longer split onto multiple lines. 408 </p> 409 410 <p> 411 Note that these kinds of minor updates to gofmt are expected from time to time. 412 In general, we recommend against building systems that check that source code 413 matches the output of a specific version of gofmt. 414 For example, a continuous integration test that fails if any code already checked into 415 a repository is not “properly formatted” is inherently fragile and not recommended. 416 </p> 417 418 <p> 419 If multiple programs must agree about which version of gofmt is used to format a source file, 420 we recommend that they do this by arranging to invoke the same gofmt binary. 421 For example, in the Go open source repository, our Git pre-commit hook is written in Go 422 and could import <code>go/format</code> directly but instead invokes the <code>gofmt</code> 423 binary found in the current path, so that the pre-commit hook need not be recompiled 424 each time <code>gofmt</code> changes. 425 </p> 426 427 <h3 id="compiler">Compiler Toolchain</h3> 428 429 <p> 430 The compiler includes many improvements to the performance of generated code, 431 spread fairly evenly across the supported architectures. 432 </p> 433 434 <p> 435 The DWARF debug information recorded in binaries has been improved in a few ways: 436 constant values are now recorded; 437 line number information is more accurate, making source-level stepping through a program work better; 438 and each package is now presented as its own DWARF compilation unit. 439 </p> 440 441 <p> 442 The various <a href="https://docs.google.com/document/d/1nr-TQHw_er6GOQRsF6T43GGhFDelrAP0NqSS_00RgZQ/edit">build modes</a> 443 has been ported to more systems. 444 Specifically, <code>c-shared</code> now works on <code>linux/ppc64le</code>, <code>windows/386</code>, and <code>windows/amd64</code>; 445 <code>pie</code> now works on <code>darwin/amd64</code> and also forces the use of external linking on all systems; 446 and <code>plugin</code> now works on <code>linux/ppc64le</code> and <code>darwin/amd64</code>. 447 </p> 448 449 <p> 450 The <code>linux/ppc64le</code> port now requires the use of external linking 451 with any programs that use cgo, even uses by the standard library. 452 </p> 453 454 <h3 id="asm">Assembler</h3> 455 456 <p> 457 For the ARM 32-bit port, the assembler now supports the instructions 458 <code><small>BFC</small></code>, 459 <code><small>BFI</small></code>, 460 <code><small>BFX</small></code>, 461 <code><small>BFXU</small></code>, 462 <code><small>FMULAD</small></code>, 463 <code><small>FMULAF</small></code>, 464 <code><small>FMULSD</small></code>, 465 <code><small>FMULSF</small></code>, 466 <code><small>FNMULAD</small></code>, 467 <code><small>FNMULAF</small></code>, 468 <code><small>FNMULSD</small></code>, 469 <code><small>FNMULSF</small></code>, 470 <code><small>MULAD</small></code>, 471 <code><small>MULAF</small></code>, 472 <code><small>MULSD</small></code>, 473 <code><small>MULSF</small></code>, 474 <code><small>NMULAD</small></code>, 475 <code><small>NMULAF</small></code>, 476 <code><small>NMULD</small></code>, 477 <code><small>NMULF</small></code>, 478 <code><small>NMULSD</small></code>, 479 <code><small>NMULSF</small></code>, 480 <code><small>XTAB</small></code>, 481 <code><small>XTABU</small></code>, 482 <code><small>XTAH</small></code>, 483 and 484 <code><small>XTAHU</small></code>. 485 </p> 486 487 <p> 488 For the ARM 64-bit port, the assembler now supports the 489 <code><small>VADD</small></code>, 490 <code><small>VADDP</small></code>, 491 <code><small>VADDV</small></code>, 492 <code><small>VAND</small></code>, 493 <code><small>VCMEQ</small></code>, 494 <code><small>VDUP</small></code>, 495 <code><small>VEOR</small></code>, 496 <code><small>VLD1</small></code>, 497 <code><small>VMOV</small></code>, 498 <code><small>VMOVI</small></code>, 499 <code><small>VMOVS</small></code>, 500 <code><small>VORR</small></code>, 501 <code><small>VREV32</small></code>, 502 and 503 <code><small>VST1</small></code> 504 instructions. 505 </p> 506 507 <p> 508 For the PowerPC 64-bit port, the assembler now supports the POWER9 instructions 509 <code><small>ADDEX</small></code>, 510 <code><small>CMPEQB</small></code>, 511 <code><small>COPY</small></code>, 512 <code><small>DARN</small></code>, 513 <code><small>LDMX</small></code>, 514 <code><small>MADDHD</small></code>, 515 <code><small>MADDHDU</small></code>, 516 <code><small>MADDLD</small></code>, 517 <code><small>MFVSRLD</small></code>, 518 <code><small>MTVSRDD</small></code>, 519 <code><small>MTVSRWS</small></code>, 520 <code><small>PASTECC</small></code>, 521 <code><small>VCMPNEZB</small></code>, 522 <code><small>VCMPNEZBCC</small></code>, 523 and 524 <code><small>VMSUMUDM</small></code>. 525 </p> 526 527 <p> 528 For the S390X port, the assembler now supports the 529 <code><small>TMHH</small></code>, 530 <code><small>TMHL</small></code>, 531 <code><small>TMLH</small></code>, 532 and 533 <code><small>TMLL</small></code> 534 instructions. 535 </p> 536 537 <p> 538 For the X86 64-bit port, the assembler now supports 359 new instructions, 539 including the full AVX, AVX2, BMI, BMI2, F16C, FMA3, SSE2, SSE3, SSSE3, SSE4.1, and SSE4.2 extension sets. 540 The assembler also no longer implements <code><small>MOVL</small></code> <code><small>$0,</small></code> <code><small>AX</small></code> 541 as an <code><small>XORL</small></code> instruction, 542 to avoid clearing the condition flags unexpectedly. 543 </p> 544 545 <h3 id="gccgo">Gccgo</h3> 546 547 <p> 548 TODO: Words about GCC 8 and Go 1.10. 549 </p> 550 551 <h2 id="runtime">Runtime</h2> 552 553 <p> 554 The behavior of nested calls to 555 <a href="/pkg/runtime/#LockOSThread"><code>LockOSThread</code></a> and 556 <a href="/pkg/runtime/#UnlockOSThread"><code>UnlockOSThread</code></a> 557 has changed. 558 These functions control whether a goroutine is locked to a specific operating system thread, 559 so that the goroutine only runs on that thread, and the thread only runs that goroutine. 560 Previously, calling <code>LockOSThread</code> more than once in a row 561 was equivalent to calling it once, and a single <code>UnlockOSThread</code> 562 always unlocked the thread. 563 Now, the calls nest: if <code>LockOSThread</code> is called multiple times, 564 <code>UnlockOSThread</code> must be called the same number of times 565 in order to unlock the thread. 566 Existing code that was careful not to nest these calls will remain correct. 567 Existing code that incorrectly assumed the calls nested will become correct. 568 Most uses of these functions in public Go source falls into the second category. 569 </p> 570 571 <p> 572 Because one common use of <code>LockOSThread</code> and <code>UnlockOSThread</code> 573 is to allow Go code to reliably modify thread-local state (for example, Linux or Plan 9 name spaces), 574 the runtime now treats locked threads as unsuitable for reuse or for creating new threads. 575 </p> 576 577 <p> 578 Stack traces no longer include implicit wrapper functions (previously marked <code><autogenerated></code>), 579 unless a fault or panic happens in the wrapper itself. 580 As a result, skip counts passed to functions like <a href="/pkg/runtime/#Caller"><code>Caller</code></a> 581 should now always match the structure of the code as written, rather than depending on 582 optimization decisions and implementation details. 583 </p> 584 585 <p> 586 The garbage collector has been modified to reduce its impact on allocation latency. 587 It now uses a smaller fraction of the overall CPU when running, but it may run more of the time. 588 The total CPU consumed by the garbage collector has not changed significantly. 589 </p> 590 591 <p> 592 The <a href="/pkg/runtime/#GOROOT"><code>GOROOT</code></a> function 593 now defaults (when the <code>$GOROOT</code> environment variable is not set) 594 to the <code>GOROOT</code> or <code>GOROOT_FINAL</code> in effect 595 at the time the calling program was compiled. 596 Previously it used the <code>GOROOT</code> or <code>GOROOT_FINAL</code> in effect 597 at the time the toolchain that compiled the calling program was compiled. 598 </p> 599 600 <p> 601 There is no longer a limit on the <a href="/pkg/runtime/#GOMAXPROCS"><code>GOMAXPROCS</code></a> setting. 602 (In Go 1.9 the limit was 1024.) 603 </p> 604 605 <h2 id="performance">Performance</h2> 606 607 <p> 608 As always, the changes are so general and varied that precise 609 statements about performance are difficult to make. Most programs 610 should run a bit faster, due to speedups in the garbage collector, 611 better generated code, and optimizations in the core library. 612 </p> 613 614 <h2 id="gc">Garbage Collector</h2> 615 616 <p> 617 Many applications should experience significantly lower allocation latency and overall performance overhead when the garbage collector is active. 618 </p> 619 620 <h2 id="library">Core library</h2> 621 622 <p> 623 All of the changes to the standard library are minor. 624 The changes in <a href="#bytes">bytes</a> 625 and <a href="#net/url">net/url</a> are the most likely to require updating of existing programs. 626 </p> 627 628 <h3 id="minor_library_changes">Minor changes to the library</h3> 629 630 <p> 631 As always, there are various minor changes and updates to the library, 632 made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a> 633 in mind. 634 </p> 635 636 <dl id="archive/tar"><dt><a href="/pkg/archive/tar/">archive/tar</a></dt> 637 <dd> 638 <p> 639 In general, the handling of special header formats is significantly improved and expanded. 640 </p> 641 <p> 642 <a href="/pkg/archive/tar/#FileInfoHeader"><code>FileInfoHeader</code></a> has always 643 recorded the Unix UID and GID numbers from its <a href="/pkg/os/#FileInfo"><code>os.FileInfo</code></a> argument 644 (specifically, from the system-dependent information returned by the <code>FileInfo</code>'s <code>Sys</code> method) 645 in the returned <a href="/pkg/archive/tar/#Header"><code>Header</code></a>. 646 Now it also records the user and group names corresponding to those IDs, 647 as well as the major and minor device numbers for device files. 648 </p> 649 <p> 650 The new <a href="/pkg/archive/tar/#Header"><code>Header.Format</code></a> field 651 of type <a href="/pkg/archive/tar/#Format"><code>Format</code></a> 652 controls which tar header format the <a href="/pkg/archive/tar/#Writer"><code>Writer</code></a> uses. 653 The default, as before, is to select the most widely-supported header type 654 that can encode the fields needed by the header (USTAR if possible, or else PAX if possible, or else GNU). 655 The <a href="/pkg/archive/tar/#Reader"><code>Reader</code></a> sets <code>Header.Format</code> for each header it reads. 656 </p> 657 <p> 658 <code>Reader</code> and the <code>Writer</code> now support arbitrary PAX records, 659 using the new <a href="/pkg/archive/tar/#Header"><code>Header.PAXRecords</code></a> field, 660 a generalization of the existing <code>Xattrs</code> field. 661 </p> 662 <p> 663 The <code>Reader</code> no longer insists that the file name or link name in GNU headers 664 be valid UTF-8. 665 </p> 666 <p> 667 When writing PAX- or GNU-format headers, the <code>Writer</code> now includes 668 the <code>Header.AccessTime</code> and <code>Header.ChangeTime</code> fields (if set). 669 When writing PAX-format headers, the times include sub-second precision. 670 </p> 671 </dl> 672 673 <dl id="archive/zip"><dt><a href="/pkg/archive/zip/">archive/zip</a></dt> 674 <dd> 675 <p> 676 Go 1.10 adds more complete support for times and character set encodings in ZIP archives. 677 </p> 678 <p> 679 The original ZIP format used the standard MS-DOS encoding of year, month, day, hour, minute, and second into fields in two 16-bit values. 680 That encoding cannot represent time zones or odd seconds, so multiple extensions have been 681 introduced to allow richer encodings. 682 In Go 1.10, the <a href="/pkg/archive/zip/#Reader"><code>Reader</code></a> and <a href="/pkg/archive/zip/#Writer"><code>Writer</code></a> 683 now support the widely-understood Info-Zip extension that encodes the time separately in the 32-bit Unix “seconds since epoch” form. 684 The <a href="/pkg/archive/zip/#FileHeader"><code>FileHeader</code></a>'s new <code>Modified</code> field of type <a href="/pkg/time/#Time"><code>time.Time</code></a> 685 obsoletes the <code>ModifiedTime</code> and <code>ModifiedDate</code> fields, which continue to hold the MS-DOS encoding. 686 The <code>Reader</code> and <code>Writer</code> now adopt the common 687 convention that a ZIP archive storing a time zone-independent Unix time 688 also stores the local time in the MS-DOS field, 689 so that the time zone offset can be inferred. 690 For compatibility, the <a href="/pkg/archive/zip/#FileHeader.ModTime"><code>ModTime</code></a> and 691 <a href="/pkg/archive/zip/#FileHeader.SetModTime"><code>SetModTime</code></a> methods 692 behave the same as in earlier releases; new code should use <code>Modified</code> directly. 693 </p> 694 <p> 695 The header for each file in a ZIP archive has a flag bit indicating whether 696 the name and comment fields are encoded as UTF-8, as opposed to a system-specific default encoding. 697 In Go 1.8 and earlier, the <code>Writer</code> never set the UTF-8 bit. 698 In Go 1.9, the <code>Writer</code> changed to set the UTF-8 bit almost always. 699 This broke the creation of ZIP archives containing Shift-JIS file names. 700 In Go 1.10, the <code>Writer</code> now sets the UTF-8 bit only when 701 both the name and the comment field are valid UTF-8 and at least one is non-ASCII. 702 Because non-ASCII encodings very rarely look like valid UTF-8, the new 703 heuristic should be correct nearly all the time. 704 Setting a <code>FileHeader</code>'s new <code>NonUTF8</code> field to true 705 disables the heuristic entirely for that file. 706 </p> 707 <p> 708 The <code>Writer</code> also now supports setting the end-of-central-directory record's comment field, 709 by calling the <code>Writer</code>'s new <a href="/pkg/archive/zip/#Writer.SetComment"><code>SetComment</code></a> method. 710 </p> 711 </dl> 712 713 <dl id="bufio"><dt><a href="/pkg/bufio/">bufio</a></dt> 714 <dd> 715 <p> 716 The new <a href="/pkg/bufio/#Reader.Size"><code>Reader.Size</code></a> 717 and <a href="/pkg/bufio/#Writer.Size"><code>Writer.Size</code></a> 718 methods report the <code>Reader</code> or <code>Writer</code>'s underlying buffer size. 719 </p> 720 </dl> 721 722 <dl id="bytes"><dt><a href="/pkg/bytes/">bytes</a></dt> 723 <dd> 724 <p> 725 The 726 <a href="/pkg/bytes/#Fields"><code>Fields</code></a>, 727 <a href="/pkg/bytes/#FieldsFunc"><code>FieldsFunc</code></a>, 728 <a href="/pkg/bytes/#Split"><code>Split</code></a>, 729 and 730 <a href="/pkg/bytes/#SplitAfter"><code>SplitAfter</code></a> 731 each already returned slices pointing into the same underlying array as its input. 732 Go 1.10 changes each of the returned subslices to have capacity equal to its length, 733 so that appending to a subslice will not overwrite adjacent data in the original input. 734 </p> 735 </dl> 736 737 <dl id="crypto/cipher"><dt><a href="/pkg/crypto/cipher/">crypto/cipher</a></dt> 738 <dd> 739 <p> 740 <a href="/pkg/crypto/cipher/#NewOFB"><code>NewOFB</code></a> now panics if given 741 an initialization vector of incorrect length, like the other constructors in the 742 package always have. 743 (Previously it returned a nil <code>Stream</code> implementation.) 744 </p> 745 </dl> 746 747 <dl id="crypto/tls"><dt><a href="/pkg/crypto/tls/">crypto/tls</a></dt> 748 <dd> 749 <p> 750 The TLS server now advertises support for SHA-512 signatures when using TLS 1.2. 751 The server already supported the signatures, but some clients would not select 752 them unless explicitly advertised. 753 </p> 754 </dl> 755 756 <dl id="crypto/x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt> 757 <dd> 758 <p> 759 Leaf certificate validation now enforces the name constraints for all 760 names contained in the certificate, not just the one name that a client has asked about. 761 Extended key usage restrictions are similarly now checked all at once. 762 As a result, after a certificate has been validated, now it can be trusted in its entirety. 763 It is no longer necessary to revalidate the certificate for each additional name 764 or key usage. 765 TODO: Link to docs that may not exist yet. 766 </p> 767 768 <p> 769 Parsed certificates also now report URI names and IP, email, and URI constraints, using the new 770 <a href="/pkg/crypto/x509/#Certificate"><code>Certificate</code></a> fields 771 <code>URIs</code>, <code>PermittedIPRanges</code>, <code>ExcludedIPRanges</code>, 772 <code>PermittedEmailAddresses</code>, <code>ExcludedEmailAddresses</code>, 773 <code>PermittedURIDomains</code>, and <code>ExcludedURIDomains</code>. 774 </p> 775 776 <p> 777 The new <a href="/pkg/crypto/x509/#MarshalPKCS1PublicKey"><code>MarshalPKCS1PublicKey</code></a> 778 and <a href="/pkg/crypto/x509/#ParsePKCS1PublicKey"><code>ParsePKCS1PublicKey</code></a> 779 functions convert an RSA public key to and from PKCS#1-encoded form. 780 </p> 781 782 <p> 783 The new <a href="/pkg/crypto/x509/#MarshalPKCS8PrivateKey"><code>MarshalPKCS8PrivateKey</code></a> 784 function converts a private key to PKCS#8-encoded form. 785 (<a href="/pkg/crypto/x509/#ParsePKCS8PrivateKey"><code>ParsePKCS8PrivateKey</code></a> 786 has existed since Go 1.) 787 </p> 788 </dl> 789 790 <dl id="crypto/x509/pkix"><dt><a href="/pkg/crypto/x509/pkix/">crypto/x509/pkix</a></dt> 791 <dd> 792 <p> 793 <a href="/pkg/crypto/x509/pkix/#Name"><code>Name</code></a> now implements a 794 <a href="/pkg/crypto/x509/pkix/#Name.String"><code>String</code></a> method that 795 formats the X.509 distinguished name in the standard RFC 2253 format. 796 </p> 797 </dl> 798 799 <dl id="database/sql/driver"><dt><a href="/pkg/database/sql/driver/">database/sql/driver</a></dt> 800 <dd> 801 <p> 802 Drivers that want to construct a <a href="/pkg/database/sql/#DB"><code>sql.DB</code></a> for 803 their clients can now implement the <a href="/pkg/database/sql/driver/#Connector"><code>Connector</code></a> interface 804 and call the new <a href="/pkg/database/sql/#OpenDB"><code>sql.OpenDB</code></a> function, 805 instead of needing to encode all configuration into a string 806 passed to <a href="/pkg/database/sql/#Open"><code>sql.Open</code></a>. 807 </p> 808 <p> 809 Drivers that want to parse the configuration string only once per <code>sql.DB</code> 810 instead of once per <a href="/pkg/database/sql/#Conn"><code>sql.Conn</code></a>, 811 or that want access to each <code>sql.Conn</code>'s underlying context, 812 can make their <a href="/pkg/database/sql/driver/#Driver"><code>Driver</code></a> 813 implementations also implement <a href="/pkg/database/sql/driver/#DriverContext"><code>DriverContext</code></a>'s 814 new <code>OpenConnector</code> method. 815 </p> 816 <p> 817 Drivers that implement <a href="/pkg/database/sql/driver/#ExecerContext"><code>ExecerContext</code></a> 818 no longer need to implement <a href="/pkg/database/sql/driver/#Execer"><code>Execer</code></a>; 819 similarly, drivers that implement <a href="/pkg/database/sql/driver/#QueryerContext"><code>QueryerContext</code></a> 820 no longer need to implement <a href="/pkg/database/sql/driver/#Queryer"><code>Queryer</code></a>. 821 Previously, even if the context-based interfaces were implemented they were ignored 822 unless the non-context-based interfaces were also implemented. 823 </p> 824 <p> 825 To allow drivers to better isolate different clients using a cached driver connection in succession, 826 if a <a href="/pkg/database/sql/driver/#Conn"><code>Conn</code></a> implements the new 827 <a href="/pkg/database/sql/driver/#SessionResetter"><code>SessionResetter</code></a> interface, 828 <code>database/sql</code> will now call <code>ResetSession</code> before 829 reusing the <code>Conn</code> for a new client. 830 </p> 831 </dl> 832 833 <dl id="debug/elf"><dt><a href="/pkg/debug/elf/">debug/elf</a></dt> 834 <dd> 835 <p> 836 This release adds 348 new relocation constants divided between the relocation types 837 <a href="/pkg/debug/elf/#R_386"><code>R_386</code></a>, 838 <a href="/pkg/debug/elf/#R_AARCH64"><code>R_AARCH64</code></a>, 839 <a href="/pkg/debug/elf/#R_ARM"><code>R_ARM</code></a>, 840 <a href="/pkg/debug/elf/#R_PPC64"><code>R_PPC64</code></a>, 841 and 842 <a href="/pkg/debug/elf/#R_X86_64"><code>R_X86_64</code></a>. 843 </p> 844 </dl> 845 846 <dl id="debug/macho"><dt><a href="/pkg/debug/macho/">debug/macho</a></dt> 847 <dd> 848 <p> 849 Go 1.10 adds support for reading relocations from Mach-O sections, 850 using the <a href="/pkg/debug/macho#Section"><code>Section</code></a> struct's new <code>Relocs</code> field 851 and the new <a href="/pkg/debug/macho/#Reloc"><code>Reloc</code></a>, 852 <a href="/pkg/debug/macho/#RelocTypeARM"><code>RelocTypeARM</code></a>, 853 <a href="/pkg/debug/macho/#RelocTypeARM64"><code>RelocTypeARM64</code></a>, 854 <a href="/pkg/debug/macho/#RelocTypeGeneric"><code>RelocTypeGeneric</code></a>, 855 and 856 <a href="/pkg/debug/macho/#RelocTypeX86_64"><code>RelocTypeX86_64</code></a> 857 types and associated constants. 858 </p> 859 <p> 860 Go 1.10 also adds support for the <code>LC_RPATH</code> load command, 861 represented by the types 862 <a href="/pkg/debug/macho/#RpathCmd"><code>RpathCmd</code></a> and 863 <a href="/pkg/debug/macho/#Rpath"><code>Rpath</code></a>, 864 and new <a href="/pkg/debug/macho/#pkg-constants">named constants</a> 865 for the various flag bits found in headers. 866 </p> 867 </dl> 868 869 <dl id="encoding/asn1"><dt><a href="/pkg/encoding/asn1/">encoding/asn1</a></dt> 870 <dd> 871 <p> 872 <a href="/pkg/encoding/asn1/#Marshal"><code>Marshal</code></a> now correctly encodes 873 strings containing asterisks as type UTF8String instead of PrintableString, 874 unless the string is in a struct field with a tag forcing the use of PrintableString. 875 <code>Marshal</code> also now respects struct tags containing <code>application</code> directives. 876 </p> 877 <p> 878 The new <a href="/pkg/encoding/asn1/#MarshalWithParams"><code>MarshalWithParams</code></a> 879 function marshals its argument as if the additional params were its associated 880 struct field tag. 881 </p> 882 <p> 883 <a href="/pkg/encoding/asn1/#Unmarshal"><code>Unmarshal</code></a> now respects 884 struct field tags using the <code>explicit</code> and <code>tag</code> 885 directives. 886 </p> 887 <p> 888 Both <code>Marshal</code> and <code>Unmarshal</code> now support a new struct field tag 889 <code>numeric</code>, indicating an ASN.1 NumericString. 890 </p> 891 </dl> 892 893 <dl id="encoding/csv"><dt><a href="/pkg/encoding/csv/">encoding/csv</a></dt> 894 <dd> 895 <p> 896 <a href="/pkg/encoding/csv/#Reader"><code>Reader</code></a> now disallows the use of 897 nonsensical <code>Comma</code> and <code>Comment</code> settings, 898 such as NUL, carriage return, newline, invalid runes, and the Unicode replacement character, 899 or setting <code>Comma</code> and <code>Comment</code> equal to each other. 900 </p> 901 <p> 902 In the case of a syntax error in a CSV record that spans multiple input lines, <code>Reader</code> 903 now reports the line on which the record started in the <a href="/pkg/encoding/csv/#ParseError"><code>ParseError</code></a>'s new <code>StartLine</code> field. 904 </p> 905 </dl> 906 907 <dl id="encoding/hex"><dt><a href="/pkg/encoding/hex/">encoding/hex</a></dt> 908 <dd> 909 <p> 910 The new functions 911 <a href="/pkg/encoding/hex/#NewEncoder"><code>NewEncoder</code></a> 912 and 913 <a href="/pkg/encoding/hex/#NewDecoder"><code>NewDecoder</code></a> 914 provide streaming conversions to and from hexadecimal, 915 analogous to equivalent functions already in 916 <a href="/pkg/encoding/base32/">encoding/base32</a> 917 and 918 <a href="/pkg/encoding/base64/">encoding/base64</a>. 919 </p> 920 921 <p> 922 When the functions 923 <a href="/pkg/encoding/hex/#Decode"><code>Decode</code></a> 924 and 925 <a href="/pkg/encoding/hex/#DecodeString"><code>DecodeString</code></a> 926 encounter malformed input, 927 they now return the number of bytes already converted 928 along with the error. 929 Previously they always returned a count of 0 with any error. 930 </p> 931 </dl> 932 933 <dl id="encoding/json"><dt><a href="/pkg/encoding/json/">encoding/json</a></dt> 934 <dd> 935 <p> 936 The <a href="/pkg/encoding/json/#Decoder"><code>Decoder</code></a> 937 adds a new method 938 <a href="/pkg/encoding/json/#Decoder.DisallowUnknownFields"><code>DisallowUnknownFields</code></a> 939 that causes it to report inputs with unknown JSON fields as a decoding error. 940 (The default behavior has always been to discard unknown fields.) 941 </p> 942 943 <p> 944 As a result of <a href="#reflect">fixing a reflect bug</a>, 945 <a href="/pkg/encoding/json/#Unmarshal"><code>Unmarshal</code></a> 946 can no longer decode into fields inside 947 embedded pointers to unexported struct types, 948 because it cannot initialize the unexported embedded pointer 949 to point at fresh storage. 950 <code>Unmarshal</code> now returns an error in this case. 951 </p> 952 </dl> 953 954 <dl id="encoding/pem"><dt><a href="/pkg/encoding/pem/">encoding/pem</a></dt> 955 <dd> 956 <p> 957 <a href="/pkg/encoding/pem/#Encode"><code>Encode</code></a> 958 and 959 <a href="/pkg/encoding/pem/#EncodeToMemory"><code>EncodeToMemory</code></a> 960 no longer generate partial output when presented with a 961 block that is impossible to encode as PEM data. 962 </p> 963 </dl> 964 965 <dl id="encoding/xml"><dt><a href="/pkg/encoding/xml/">encoding/xml</a></dt> 966 <dd> 967 <p> 968 The new function 969 <a href="/pkg/encoding/xml/#NewTokenDecoder"><code>NewTokenDecoder</code></a> 970 is like 971 <a href="/pkg/encoding/xml/#NewDecoder"><code>NewDecoder</code></a> 972 but creates a decoder reading from a <a href="/pkg/encoding/xml/#TokenReader"><code>TokenReader</code></a> 973 instead of an XML-formatted byte stream. 974 This is meant to enable the construction of XML stream transformers in client libraries. 975 </p> 976 </dl> 977 978 <dl id="flag"><dt><a href="/pkg/flag/">flag</a></dt> 979 <dd> 980 <p> 981 The default 982 <a href="/pkg/flag/#Usage"><code>Usage</code></a> function now prints 983 its first line of output to 984 <code>CommandLine.Output()</code> 985 instead of assuming <code>os.Stderr</code>, 986 so that the usage message is properly redirected for 987 clients using <code>CommandLine.SetOutput</code>. 988 </p> 989 <p> 990 <a href="/pkg/flag/#PrintDefaults"><code>PrintDefaults</code></a> now 991 adds appropriate indentation after newlines in flag usage strings, 992 so that multi-line usage strings display nicely. 993 </p> 994 <p> 995 <a href="/pkg/flag/#FlagSet"><code>FlagSet</code></a> adds new methods 996 <a href="/pkg/flag/#FlagSet.ErrorHandling"><code>ErrorHandling</code></a>, 997 <a href="/pkg/flag/#FlagSet.Name"><code>Name</code></a>, 998 and 999 <a href="/pkg/flag/#FlagSet.Output"><code>Output</code></a>, 1000 to retrieve the settings passed to 1001 <a href="/pkg/flag/#NewFlagSet"><code>NewFlagSet</code></a> 1002 and 1003 <a href="/pkg/flag/#FlagSet.SetOutput"><code>FlagSet.SetOutput</code></a>. 1004 </p> 1005 </dl> 1006 1007 <dl id="go/doc"><dt><a href="/pkg/go/doc/">go/doc</a></dt> 1008 <dd> 1009 <p> 1010 To support the <a href="#doc">doc change</a> described above, 1011 functions returning slices of <code>T</code>, <code>*T</code>, <code>**T</code>, and so on 1012 are now reported in <code>T</code>'s <a href="/pkg/go/doc/#Type"><code>Type</code></a>'s <code>Funcs</code> list, 1013 instead of in the <a href="/pkg/go/doc/#Package"><code>Package</code></a>'s <code>Funcs</code> list. 1014 </p> 1015 </dl> 1016 1017 <dl id="go/importer"><dt><a href="/pkg/go/importer/">go/importer</a></dt> 1018 <dd> 1019 <p> 1020 The <a href="/pkg/go/importer/#For"><code>For</code></a> function now accepts a non-nil lookup argument. 1021 </p> 1022 </dl> 1023 1024 <dl id="go/printer"><dt><a href="/pkg/go/printer/">go/printer</a></dt> 1025 <dd> 1026 <p> 1027 The changes to the default formatting of Go source code 1028 discussed in the <a href="#gofmt">gofmt section</a> above 1029 are implemented in the <a href="/pkg/go/printer/">go/printer</a> package 1030 and also affect the output of the higher-level <a href="/pkg/go/format/">go/format</a> package. 1031 </p> 1032 </dl> 1033 1034 <dl id="hash"><dt><a href="/pkg/hash/">hash</a></dt> 1035 <dd> 1036 <p> 1037 Implementations of the <a href="/pkg/hash/#Hash"><code>Hash</code></a> interface are now 1038 encouraged to implement <a href="/pkg/encoding/#BinaryMarshaler"><code>encoding.BinaryMarshaler</code></a> 1039 and <a href="/pkg/encoding/#BinaryUnmarshaler"><code>encoding.BinaryUnmarshaler</code></a> 1040 to allow saving and recreating their internal state, 1041 and all implementations in the standard library 1042 (<a href="/pkg/hash/crc32/">hash/crc32</a>, <a href="/pkg/crypto/sha256/">crypto/sha256</a>, and so on) 1043 now implement those interfaces. 1044 </p> 1045 </dl> 1046 1047 <dl id="html/template"><dt><a href="/pkg/html/template/">html/template</a></dt> 1048 <dd> 1049 <p> 1050 The new actions <code>{{"{{break}}"}}</code> and <code>{{"{{continue}}"}}</code> 1051 break out of the innermost <code>{{"{{range"}}</code> ...<code>}}</code> loop, 1052 like the corresponding Go statements. 1053 </p> 1054 <p> 1055 The new <a href="/pkg/html/template#Srcset"><code>Srcset</code></a> content 1056 type allows for proper handling of values within the 1057 <a href="https://w3c.github.io/html/semantics-embedded-content.html#element-attrdef-img-srcset"><code>srcset</code></a> 1058 attribute of <code>img</code> tags. 1059 </p> 1060 </dl> 1061 1062 <dl id="math/big"><dt><a href="/pkg/math/big/">math/big</a></dt> 1063 <dd> 1064 <p> 1065 <a href="/pkg/math/big/#Int"><code>Int</code></a> now supports conversions to and from bases 2 through 62 1066 in its <a href="/pkg/math/big/#Int.SetString"><code>SetString</code></a> and <a href="/pkg/math/big/#Text"><code>Text</code></a> methods. 1067 (Previously it only allowed bases 2 through 36.) 1068 The value of the constant <code>MaxBase</code> has been updated. 1069 </p> 1070 <p> 1071 <a href="/pkg/math/big/#Int"><code>Int</code></a> adds a new 1072 <a href="/pkg/math/big/#CmpAbs"><code>CmpAbs</code></a> method 1073 that is like <a href="/pkg/math/big/#Cmp"><code>Cmp</code></a> but 1074 compares only the absolute values (not the signs) of its arguments. 1075 </p> 1076 <p> 1077 <a href="/pkg/math/big/#Float"><code>Float</code></a> adds a new 1078 <a href="/pkg/math/big/#Float.Sqrt"><code>Sqrt</code></a> method to 1079 compute square roots. 1080 </p> 1081 </dl> 1082 1083 <dl id="math/cmplx"><dt><a href="/pkg/math/cmplx/">math/cmplx</a></dt> 1084 <dd> 1085 <p> 1086 Branch cuts and other boundary cases in 1087 <a href="/pkg/math/cmplx/#Asin"><code>Asin</code></a>, 1088 <a href="/pkg/math/cmplx/#Asinh"><code>Asinh</code></a>, 1089 <a href="/pkg/math/cmplx/#Atan"><code>Atan</code></a>, 1090 and 1091 <a href="/pkg/math/cmplx/#Sqrt"><code>Sqrt</code></a> 1092 have been corrected to match the definitions used in the C99 standard. 1093 </p> 1094 </dl> 1095 1096 <dl id="math/rand"><dt><a href="/pkg/math/rand/">math/rand</a></dt> 1097 <dd> 1098 <p> 1099 The new <a href="/pkg/math/rand/#Shuffle"><code>Shuffle</code></a> function and corresponding 1100 <a href="/pkg/math/rand/#Rand.Shuffle"><code>Rand.Shuffle</code></a> method 1101 shuffle an input sequence. 1102 </p> 1103 </dl> 1104 1105 <dl id="math"><dt><a href="/pkg/math/">math</a></dt> 1106 <dd> 1107 <p> 1108 The new functions 1109 <a href="/pkg/math/#Round"><code>Round</code></a> 1110 and 1111 <a href="/pkg/math/#RoundToEven"><code>RoundToEven</code></a> 1112 round their arguments to the nearest floating-point integer; 1113 <code>Round</code> rounds a half-integer to its larger integer neighbor (away from zero) 1114 while <code>RoundToEven</code> rounds a half-integer to its even integer neighbor. 1115 </p> 1116 1117 <p> 1118 The new functions 1119 <a href="/pkg/math/#Erfinv"><code>Erfinv</code></a> 1120 and 1121 <a href="/pkg/math/#Erfcinv"><code>Erfcinv</code></a> 1122 compute the inverse error function and the 1123 inverse complementary error function. 1124 </p> 1125 </dl> 1126 1127 <dl id="mime/multipart"><dt><a href="/pkg/mime/multipart/">mime/multipart</a></dt> 1128 <dd> 1129 <p> 1130 <a href="/pkg/mime/multipart/#Reader"><code>Reader</code></a> 1131 now accepts parts with empty filename attributes. 1132 </p> 1133 </dl> 1134 1135 <dl id="mime"><dt><a href="/pkg/mime/">mime</a></dt> 1136 <dd> 1137 <p> 1138 <a href="/pkg/mime/#ParseMediaType"><code>ParseMediaType</code></a> now discards 1139 invalid attribute values; previously it returned those values as empty strings. 1140 </p> 1141 </dl> 1142 1143 <dl id="net"><dt><a href="/pkg/net/">net</a></dt> 1144 <dd> 1145 <p> 1146 The <a href="/pkg/net/#Conn"><code>Conn</code></a> and 1147 <a href="/pkg/net/#Conn"><code>Listener</code></a> implementations 1148 in this package now guarantee that when <code>Close</code> returns, 1149 the underlying file descriptor has been closed. 1150 (In earlier releases, if the <code>Close</code> stopped pending I/O 1151 in other goroutines, the closing of the file descriptor could happen in one of those 1152 goroutines shortly after <code>Close</code> returned.) 1153 </p> 1154 1155 <p> 1156 <a href="/pkg/net/#TCPListener"><code>TCPListener</code></a> and 1157 <a href="/pkg/net/#UnixListener"><code>UnixListener</code></a> 1158 now implement 1159 <a href="/pkg/syscall/#Conn"><code>syscall.Conn</code></a>, 1160 to allow setting options on the underlying file descriptor 1161 using <a href="/pkg/syscall/#RawConn"><code>syscall.RawConn.Control</code></a>. 1162 </p> 1163 1164 <p> 1165 The <code>Conn</code> implementations returned by <a href="/pkg/net/#Pipe"><code>Pipe</code></a> 1166 now support setting read and write deadlines. 1167 </p> 1168 1169 <p> 1170 The <a href="/pkg/net/#IPConn.ReadMsgIP"><code>IPConn.ReadMsgIP</code></a>, 1171 <a href="/pkg/net/#IPConn.WriteMsgIP"><code>IPConn.WriteMsgIP</code></a>, 1172 <a href="/pkg/net/#UDPConn.ReadMsgUDP"><code>UDPConn.ReadMsgUDP</code></a>, 1173 and 1174 <a href="/pkg/net/#UDPConn.WriteMsgUDP"><code>UDPConn.WriteMsgUDP</code></a>, 1175 methods are now implemented on Windows. 1176 </p> 1177 </dl> 1178 1179 <dl id="net/http"><dt><a href="/pkg/net/http/">net/http</a></dt> 1180 <dd> 1181 <p> 1182 On the client side, an HTTP proxy (most commonly configured by 1183 <a href="/pkg/net/http/#ProxyFromEnvironment"><code>ProxyFromEnvironment</code></a>) 1184 can now be specified as an <code>https://</code> URL, 1185 meaning that the client connects to the proxy over HTTPS before issuing a standard, proxied HTTP request. 1186 (Previously, HTTP proxy URLs were required to begin with <code>http://</code> or <code>socks5://</code>.) 1187 </p> 1188 <p> 1189 On the server side, <a href="/pkg/net/http/#FileServer"><code>FileServer</code></a> and its single-file equivalent <a href="/pkg/net/http/#ServeFile"><code>ServeFile</code></a> 1190 now apply <code>If-Range</code> checks to <code>HEAD</code> requests. 1191 <code>FileServer</code> also now reports directory read failures to the <a href="/pkg/net/http/#Server"><code>Server</code></a>'s <code>ErrorLog</code>. 1192 The content-serving handlers also now omit the <code>Content-Type</code> header when serving zero-length content. 1193 </p> 1194 <p> 1195 <a href="/pkg/net/http/#ResponseWriter"><code>ResponseWriter</code></a>'s <code>WriteHeader</code> method now panics 1196 if passed an invalid (non-3-digit) status code. 1197 </p> 1198 <p> 1199 <a href="/pkg/net/http/#Redirect"><code>Redirect</code></a> now sets the <code>Content-Type</code> header before writing its HTTP response. 1200 </p> 1201 </dl> 1202 1203 <dl id="net/mail"><dt><a href="/pkg/net/mail/">net/mail</a></dt> 1204 <dd> 1205 <p> 1206 <a href="/pkg/net/mail/#ParseAddress"><code>ParseAddress</code></a> and 1207 <a href="/pkg/net/mail/#ParseAddressList"><code>ParseAddressList</code></a> 1208 now support a variety of obsolete address formats. 1209 </p> 1210 </dl> 1211 1212 <dl id="net/smtp"><dt><a href="/pkg/net/smtp/">net/smtp</a></dt> 1213 <dd> 1214 <p> 1215 The <a href="/pkg/net/smtp/#Client"><code>Client</code></a> adds a new 1216 <a href="/pkg/net/smtp/#Client.Noop"><code>Noop</code></a> method, 1217 to test whether the server is still responding. 1218 It also now defends against possible SMTP injection in the inputs 1219 to the <a href="/pkg/net/smtp/#Client.Hello"><code>Hello</code></a> 1220 and <a href="/pkg/net/smtp/#Client.Verify"><code>Verify</code></a> methods. 1221 </p> 1222 </dl> 1223 1224 <dl id="net/textproto"><dt><a href="/pkg/net/textproto/">net/textproto</a></dt> 1225 <dd> 1226 <p> 1227 <a href="/pkg/net/textproto/#ReadMIMEHeader"><code>ReadMIMEHeader</code></a> 1228 now rejects any header that begins with a continuation (indented) header line. 1229 Previously a header with an indented first line was treated as if the first line 1230 were not indented. 1231 </p> 1232 </dl> 1233 1234 <dl id="net/url"><dt><a href="/pkg/net/url/">net/url</a></dt> 1235 <dd> 1236 <p> 1237 <a href="/pkg/net/url/#ResolveReference"><code>ResolveReference</code></a> 1238 now preserves multiple leading slashes in the target URL. 1239 Previously it rewrote multiple leading slashes to a single slash, 1240 which resulted in the <a href="/pkg/net/http/#Client"><code>http.Client</code></a> 1241 following certain redirects incorrectly. 1242 </p> 1243 <p> 1244 For example, this code's output has changed: 1245 </p> 1246 <pre> 1247 base, _ := url.Parse("http://host//path//to/page1") 1248 target, _ := url.Parse("page2") 1249 fmt.Println(base.ResolveReference(target)) 1250 </pre> 1251 <p> 1252 Note the doubled slashes around <code>path</code>. 1253 In Go 1.9 and earlier, the resolved URL was <code>http://host/path//to/page2</code>: 1254 the doubled slash before <code>path</code> was incorrectly rewritten 1255 to a single slash, while the doubled slash after <code>path</code> was 1256 correctly preserved. 1257 Go 1.10 preserves both doubled slashes, resolving to <code>http://host//path//to/page2</code> 1258 as required by <a href="https://tools.ietf.org/html/rfc3986#section-5.2">RFC 3986</a>. 1259 </p> 1260 1261 <p>This change may break existing buggy programs that unintentionally 1262 construct a base URL with a leading doubled slash in the path and inadvertently 1263 depend on <code>ResolveReference</code> to correct that mistake. 1264 For example, this can happen if code adds a host prefix 1265 like <code>http://host/</code> to a path like <code>/my/api</code>, 1266 resulting in a URL with a doubled slash: <code>http://host//my/api</code>. 1267 </p> 1268 1269 <p> 1270 <a href="/pkg/net/url/#UserInfo"><code>UserInfo</code></a>'s methods 1271 now treat a nil receiver as equivalent to a pointer to a zero <code>UserInfo</code>. 1272 Previously, they panicked. 1273 </p> 1274 </dl> 1275 1276 <dl id="os"><dt><a href="/pkg/os/">os</a></dt> 1277 <dd> 1278 <p> 1279 <a href="/pkg/os/#File"><code>File</code></a> adds new methods 1280 <a href="/pkg/os/#File.SetDeadline"><code>SetDeadline</code></a>, 1281 <a href="/pkg/os/#File.SetReadDeadline"><code>SetReadDeadline</code></a>, 1282 and 1283 <a href="/pkg/os/#File.SetWriteDeadline"><code>SetWriteDeadline</code></a> 1284 that allow setting I/O deadlines when the 1285 underlying file descriptor supports non-blocking I/O operations. 1286 The definition of these methods matches those in <a href="/pkg/net/#Conn"><code>net.Conn</code></a>. 1287 If an I/O method fails due to missing a deadline, it will return a 1288 timeout error; the 1289 new <a href="/pkg/os/#IsTimeout"><code>IsTimeout</code></a> function 1290 reports whether an error represents a timeout. 1291 </p> 1292 1293 <p> 1294 Also matching <code>net.Conn</code>, 1295 <code>File</code>'s 1296 <a href="/pkg/os/#File.Close"><code>Close</code></a> method 1297 now guarantee that when <code>Close</code> returns, 1298 the underlying file descriptor has been closed. 1299 (In earlier releases, like for <code>net.Conn</code>'s, 1300 if the <code>Close</code> stopped pending I/O 1301 in other goroutines, the closing of the file descriptor could happen in one of those 1302 goroutines shortly after <code>Close</code> returned.) 1303 </p> 1304 1305 <p> 1306 On BSD, macOS, and Solaris systems, 1307 <a href="/pkg/os/#Chtimes"><code>Chtimes</code></a> 1308 now supports setting file times with nanosecond precision 1309 (assuming the underlying file system can represent them). 1310 </p> 1311 </dl> 1312 1313 <dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt> 1314 <dd> 1315 <p> 1316 The <a href="/pkg/reflect/#Copy"><code>Copy</code></a> function now allows copying 1317 from a string into a byte array or byte slice, to match the 1318 <a href="/pkg/builtin/#copy">built-in copy function</a>. 1319 </p> 1320 1321 <p> 1322 In structs, embedded pointers to unexported struct types were 1323 previously incorrectly reported with an empty <code>PkgPath</code> 1324 in the corresponding <a href="/pkg/reflect/#StructField">StructField</a>, 1325 with the result that for those fields, 1326 and <a href="/pkg/reflect/#Value.CanSet"><code>Value.CanSet</code></a> 1327 incorrectly returned true and 1328 and <a href="/pkg/reflect/#Value.Set"><code>Value.Set</code></a> 1329 incorrectly succeeded. 1330 The underlying metadata has been corrected; 1331 for those fields, 1332 <code>CanSet</code> now correctly returns false 1333 and <code>Set</code> now correctly panics. 1334 This may affect reflection-based unmarshalers 1335 that could previously unmarshal into such fields 1336 but no longer can. 1337 For example, see the <a href="#encoding/json"><code>encoding/json</code> notes</a>. 1338 </p> 1339 </dl> 1340 1341 <dl id="runtime/pprof"><dt><a href="/pkg/runtime/pprof/">runtime/pprof</a></dt> 1342 <dd> 1343 <p> 1344 As <a href="#pprof">noted above</a>, the blocking and mutex profiles 1345 now include symbol information so that they can be viewed without needing 1346 the binary that generated them. 1347 </p> 1348 </dl> 1349 1350 <dl id="strconv"><dt><a href="/pkg/strconv/">strconv</a></dt> 1351 <dd> 1352 <p> 1353 <a href="/pkg/strconv/#ParseUint"><code>ParseUint</code></a> now returns 1354 the maximum magnitude integer of the appropriate size 1355 with any <code>ErrRange</code> error, as it was already documented to do. 1356 Previously it returned 0 with <code>ErrRange</code> errors. 1357 </p> 1358 </dl> 1359 1360 <dl id="strings"><dt><a href="/pkg/strings/">strings</a></dt> 1361 <dd> 1362 <p> 1363 A new type 1364 <a href="/pkg/strings/#Builder"><code>Builder</code></a> is a replacement for 1365 <a href="/pkg/bytes/#Buffer"><code>bytes.Buffer</code></a> for the use case of 1366 accumulating text into a <code>string</code> result. 1367 The <code>Builder</code>'s API is a restricted subset of <code>bytes.Buffer</code>'s 1368 that allows it to safely avoid making a duplicate copy of the data 1369 during the <a href="/pkg/strings/#Builder.String"><code>String</code></a> method. 1370 </p> 1371 </dl> 1372 1373 <dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt> 1374 <dd> 1375 <p> 1376 On Windows, 1377 the new <a href="/pkg/syscall/#SysProcAttr"><code>SysProcAttr</code></a> field <code>Token</code>, 1378 of type <a href="/pkg/syscall/#Token"><code>Token</code></a> allows the creation of a process that 1379 runs as another user during <a href="/pkg/syscall/#StartProcess"><code>StartProcess</code></a> 1380 (and therefore also during <a href="/pkg/os/#StartProcess"><code>os.StartProcess</code></a> and 1381 <a href="/pkg/os/exec/#Cmd.Start"><code>exec.Cmd.Start</code></a>). 1382 The new function <a href="/pkg/syscall/#CreateProcessAsUser"><code>CreateProcessAsUser</code></a> 1383 gives access to the underlying system call. 1384 </p> 1385 1386 <p> 1387 On BSD, macOS, and Solaris systems, <a href="/pkg/syscall/#UtimesNano"><code>UtimesNano</code></a> 1388 is now implemented. 1389 </p> 1390 </dl> 1391 1392 <dl id="text/template"><dt><a href="/pkg/text/template/">text/template</a></dt> 1393 <dd> 1394 <p> 1395 The new actions <code>{{"{{break}}"}}</code> and <code>{{"{{continue}}"}}</code> 1396 break out of the innermost <code>{{"{{range"}}</code> ...<code>}}</code> loop, 1397 like the corresponding Go statements. 1398 </p> 1399 </dl> 1400 1401 <dl id="time"><dt><a href="/pkg/time/">time</a></dt> 1402 <dd> 1403 <p> 1404 <a href="/pkg/time/#LoadLocation"><code>LoadLocation</code></a> now uses the directory 1405 or uncompressed zip file named by the <code>$ZONEINFO</code> 1406 environment variable before looking in the default system-specific list of 1407 known installation locations or in <code>$GOROOT/lib/time/zoneinfo.zip</code>. 1408 </p> 1409 <p> 1410 The new function <a href="/pkg/time/#LoadLocationFromTZData"><code>LoadLocationFromTZData</code></a> 1411 allows conversion of IANA time zone file data to a <a href="/pkg/time/#Location"><code>Location</code></a>. 1412 </p> 1413 </dl> 1414 1415 <dl id="unicode"><dt><a href="/pkg/unicode/">unicode</a></dt> 1416 <dd> 1417 <p> 1418 The <a href="/pkg/unicode/"><code>unicode</code></a> package and associated 1419 support throughout the system has been upgraded from version 9.0 to 1420 <a href="http://www.unicode.org/versions/Unicode10.0.0/">Unicode 10.0</a>, 1421 which adds 8,518 new characters, including four new scripts, one new property, 1422 a Bitcoin currency symbol, and 56 new emoji. 1423 </p> 1424 </dl>