github.com/hikaru7719/go@v0.0.0-20181025140707-c8b2ac68906a/doc/go1.11.html (about) 1 <!--{ 2 "Title": "Go 1.11 Release Notes", 3 "Path": "/doc/go1.11", 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">Introduction to Go 1.11</h2> 19 20 <p> 21 The latest Go release, version 1.11, arrives six months after <a href="go1.10">Go 1.10</a>. 22 Most of its changes are in the implementation of the toolchain, runtime, and libraries. 23 As always, the release maintains the Go 1 <a href="/doc/go1compat.html">promise of compatibility</a>. 24 We expect almost all Go programs to continue to compile and run as before. 25 </p> 26 27 <h2 id="language">Changes to the language</h2> 28 29 <p> 30 There are no changes to the language specification. 31 </p> 32 33 <h2 id="ports">Ports</h2> 34 35 <p> <!-- CL 94255, CL 115038, etc --> 36 As <a href="go1.10#ports">announced in the Go 1.10 release notes</a>, Go 1.11 now requires 37 OpenBSD 6.2 or later, macOS 10.10 Yosemite or later, or Windows 7 or later; 38 support for previous versions of these operating systems has been removed. 39 </p> 40 41 <p> <!-- CL 121657 --> 42 Go 1.11 supports the upcoming OpenBSD 6.4 release. Due to changes in 43 the OpenBSD kernel, older versions of Go will not work on OpenBSD 6.4. 44 </p> 45 46 <p> 47 There are <a href="https://golang.org/issue/25206">known issues</a> with NetBSD on i386 hardware. 48 </p> 49 50 <p><!-- CL 107935 --> 51 The race detector is now supported on <code>linux/ppc64le</code> 52 and, to a lesser extent, on <code>netbsd/amd64</code>. The NetBSD race detector support 53 has <a href="https://golang.org/issue/26403">known issues</a>. 54 </p> 55 56 <p><!-- CL 109255 --> 57 The memory sanitizer (<code>-msan</code>) is now supported on <code>linux/arm64</code>. 58 </p> 59 60 <p><!-- CL 93875 --> 61 The build modes <code>c-shared</code> and <code>c-archive</code> are now supported on 62 <code>freebsd/amd64</code>. 63 </p> 64 65 <p id="mips"><!-- CL 108475 --> 66 On 64-bit MIPS systems, the new environment variable settings 67 <code>GOMIPS64=hardfloat</code> (the default) and 68 <code>GOMIPS64=softfloat</code> select whether to use 69 hardware instructions or software emulation for floating-point computations. 70 For 32-bit systems, the environment variable is still <code>GOMIPS</code>, 71 as <a href="go1.10#mips">added in Go 1.10</a>. 72 </p> 73 74 <p><!-- CL 107475 --> 75 On soft-float ARM systems (<code>GOARM=5</code>), Go now uses a more 76 efficient software floating point interface. This is transparent to 77 Go code, but ARM assembly that uses floating-point instructions not 78 guarded on GOARM will break and must be ported to 79 the <a href="https://golang.org/cl/107475">new interface</a>. 80 </p> 81 82 <p><!-- CL 94076 --> 83 Go 1.11 on ARMv7 no longer requires a Linux kernel configured 84 with <code>KUSER_HELPERS</code>. This setting is enabled in default 85 kernel configurations, but is sometimes disabled in stripped-down 86 configurations. 87 </p> 88 89 <h3 id="wasm">WebAssembly</h3> 90 <p> 91 Go 1.11 adds an experimental port to <a href="https://webassembly.org">WebAssembly</a> 92 (<code>js/wasm</code>). 93 </p> 94 <p> 95 Go programs currently compile to one WebAssembly module that 96 includes the Go runtime for goroutine scheduling, garbage 97 collection, maps, etc. 98 As a result, the resulting size is at minimum around 99 2 MB, or 500 KB compressed. Go programs can call into JavaScript 100 using the new experimental 101 <a href="/pkg/syscall/js/"><code>syscall/js</code></a> package. 102 Binary size and interop with other languages has not yet been a 103 priority but may be addressed in future releases. 104 </p> 105 <p> 106 As a result of the addition of the new <code>GOOS</code> value 107 "<code>js</code>" and <code>GOARCH</code> value "<code>wasm</code>", 108 Go files named <code>*_js.go</code> or <code>*_wasm.go</code> will 109 now be <a href="/pkg/go/build/#hdr-Build_Constraints">ignored by Go 110 tools</a> except when those GOOS/GOARCH values are being used. 111 If you have existing filenames matching those patterns, you will need to rename them. 112 </p> 113 <p> 114 More information can be found on the 115 <a href="https://golang.org/wiki/WebAssembly">WebAssembly wiki page</a>. 116 </p> 117 118 <h3 id="riscv">RISC-V GOARCH values reserved</h3> 119 <p><!-- CL 106256 --> 120 The main Go compiler does not yet support the RISC-V architecture <!-- is gonna change everything --> 121 but we've reserved the <code>GOARCH</code> values 122 "<code>riscv</code>" and "<code>riscv64</code>", as used by Gccgo, 123 which does support RISC-V. This means that Go files 124 named <code>*_riscv.go</code> will now also 125 be <a href="/pkg/go/build/#hdr-Build_Constraints">ignored by Go 126 tools</a> except when those GOOS/GOARCH values are being used. 127 </p> 128 129 <h2 id="tools">Tools</h2> 130 131 <h3 id="modules">Modules, package versioning, and dependency management</h3> 132 <p> 133 Go 1.11 adds preliminary support for a <a href="/cmd/go/#hdr-Modules__module_versions__and_more">new concept called “modules,”</a> 134 an alternative to GOPATH with integrated support for versioning and 135 package distribution. 136 Using modules, developers are no longer confined to working inside GOPATH, 137 version dependency information is explicit yet lightweight, 138 and builds are more reliable and reproducible. 139 </p> 140 141 <p> 142 Module support is considered experimental. 143 Details are likely to change in response to feedback from Go 1.11 users, 144 and we have more tools planned. 145 Although the details of module support may change, projects that convert 146 to modules using Go 1.11 will continue to work with Go 1.12 and later. 147 If you encounter bugs using modules, 148 please <a href="https://golang.org/issue/new">file issues</a> 149 so we can fix them. For more information, see the 150 <a href="/cmd/go#hdr-Modules__module_versions__and_more"><code>go</code> command documentation</a>. 151 </p> 152 153 <h3 id="importpath">Import path restriction</h3> 154 155 <p> 156 Because Go module support assigns special meaning to the 157 <code>@</code> symbol in command line operations, 158 the <code>go</code> command now disallows the use of 159 import paths containing <code>@</code> symbols. 160 Such import paths were never allowed by <code>go</code> <code>get</code>, 161 so this restriction can only affect users building 162 custom GOPATH trees by other means. 163 </p> 164 165 <h3 id="gopackages">Package loading</h3> 166 167 <p> 168 The new package 169 <a href="https://godoc.org/golang.org/x/tools/go/packages"><code>golang.org/x/tools/go/packages</code></a> 170 provides a simple API for locating and loading packages of Go source code. 171 Although not yet part of the standard library, for many tasks it 172 effectively replaces the <a href="/pkg/go/build"><code>go/build</code></a> 173 package, whose API is unable to fully support modules. 174 Because it runs an external query command such as 175 <a href="/cmd/go/#hdr-List_packages"><code>go list</code></a> 176 to obtain information about Go packages, it enables the construction of 177 analysis tools that work equally well with alternative build systems 178 such as <a href="https://bazel.build">Bazel</a> 179 and <a href="https://buckbuild.com">Buck</a>. 180 </p> 181 182 <h3 id="gocache">Build cache requirement</h3> 183 184 <p> 185 Go 1.11 will be the last release to support setting the environment 186 variable <code>GOCACHE=off</code> to disable the 187 <a href="/cmd/go/#hdr-Build_and_test_caching">build cache</a>, 188 introduced in Go 1.10. 189 Starting in Go 1.12, the build cache will be required, 190 as a step toward eliminating <code>$GOPATH/pkg</code>. 191 The module and package loading support described above 192 already require that the build cache be enabled. 193 If you have disabled the build cache to avoid problems you encountered, 194 please <a href="https://golang.org/issue/new">file an issue</a> to let us know about them. 195 </p> 196 197 <h3 id="compiler">Compiler toolchain</h3> 198 199 <p><!-- CL 109918 --> 200 More functions are now eligible for inlining by default, including 201 functions that call <code>panic</code>. 202 </p> 203 204 <p><!-- CL 97375 --> 205 The compiler toolchain now supports column information 206 in <a href="/cmd/compile/#hdr-Compiler_Directives">line 207 directives</a>. 208 </p> 209 210 <p><!-- CL 106797 --> 211 A new package export data format has been introduced. 212 This should be transparent to end users, except for speeding up 213 build times for large Go projects. 214 If it does cause problems, it can be turned off again by 215 passing <code>-gcflags=all=-iexport=false</code> to 216 the <code>go</code> tool when building a binary. 217 </p> 218 219 <p><!-- CL 100459 --> 220 The compiler now rejects unused variables declared in a type switch 221 guard, such as <code>x</code> in the following example: 222 </p> 223 <pre> 224 func f(v interface{}) { 225 switch x := v.(type) { 226 } 227 } 228 </pre> 229 <p> 230 This was already rejected by both <code>gccgo</code> 231 and <a href="/pkg/go/types/">go/types</a>. 232 </p> 233 234 <h3 id="assembler">Assembler</h3> 235 236 <p><!-- CL 113315 --> 237 The assembler for <code>amd64</code> now accepts AVX512 instructions. 238 </p> 239 240 <h3 id="debugging">Debugging</h3> 241 242 <p><!-- CL 100738, CL 93664 --> 243 The compiler now produces significantly more accurate debug 244 information for optimized binaries, including variable location 245 information, line numbers, and breakpoint locations. 246 247 This should make it possible to debug binaries 248 compiled <em>without</em> <code>-N</code> <code>-l</code>. 249 250 There are still limitations to the quality of the debug information, 251 some of which are fundamental, and some of which will continue to 252 improve with future releases. 253 </p> 254 255 <p><!-- CL 118276 --> 256 DWARF sections are now compressed by default because of the expanded 257 and more accurate debug information produced by the compiler. 258 259 This is transparent to most ELF tools (such as debuggers on Linux 260 and *BSD) and is supported by the Delve debugger on all platforms, 261 but has limited support in the native tools on macOS and Windows. 262 263 To disable DWARF compression, 264 pass <code>-ldflags=-compressdwarf=false</code> to 265 the <code>go</code> tool when building a binary. 266 </p> 267 268 <p><!-- CL 109699 --> 269 Go 1.11 adds experimental support for calling Go functions from 270 within a debugger. 271 272 This is useful, for example, to call <code>String</code> methods 273 when paused at a breakpoint. 274 275 This is currently only supported by Delve (version 1.1.0 and up). 276 </p> 277 278 <h3 id="test">Test</h3> 279 280 <p> 281 Since Go 1.10, the <code>go</code> <code>test</code> command runs 282 <code>go</code> <code>vet</code> on the package being tested, 283 to identify problems before running the test. Since <code>vet</code> 284 typechecks the code with <a href="/pkg/go/types/">go/types</a> 285 before running, tests that do not typecheck will now fail. 286 287 In particular, tests that contain an unused variable inside a 288 closure compiled with Go 1.10, because the Go compiler incorrectly 289 accepted them (<a href="https://golang.org/issues/3059">Issue #3059</a>), 290 but will now fail, since <code>go/types</code> correctly reports an 291 "unused variable" error in this case. 292 </p> 293 294 <p><!-- CL 102696 --> 295 The <code>-memprofile</code> flag 296 to <code>go</code> <code>test</code> now defaults to the 297 "allocs" profile, which records the total bytes allocated since the 298 test began (including garbage-collected bytes). 299 </p> 300 301 <h3 id="vet">Vet</h3> 302 303 <p><!-- CL 108555 --> 304 The <a href="/cmd/vet/"><code>go</code> <code>vet</code></a> 305 command now reports a fatal error when the package under analysis 306 does not typecheck. Previously, a type checking error simply caused 307 a warning to be printed, and <code>vet</code> to exit with status 1. 308 </p> 309 310 <p><!-- CL 108559 --> 311 Additionally, <a href="/cmd/vet"><code>go</code> <code>vet</code></a> 312 has become more robust when format-checking <code>printf</code> wrappers. 313 Vet now detects the mistake in this example: 314 </p> 315 316 <pre> 317 func wrapper(s string, args ...interface{}) { 318 fmt.Printf(s, args...) 319 } 320 321 func main() { 322 wrapper("%s", 42) 323 } 324 </pre> 325 326 <h3 id="trace">Trace</h3> 327 328 <p><!-- CL 63274 --> 329 With the new <code>runtime/trace</code> 330 package's <a href="/pkg/runtime/trace/#hdr-User_annotation">user 331 annotation API</a>, users can record application-level information 332 in execution traces and create groups of related goroutines. 333 The <code>go</code> <code>tool</code> <code>trace</code> 334 command visualizes this information in the trace view and the new 335 user task/region analysis page. 336 </p> 337 338 <h3 id="cgo">Cgo</h3> 339 340 <p> 341 Since Go 1.10, cgo has translated some C pointer types to the Go 342 type <code>uintptr</code>. These types include 343 the <code>CFTypeRef</code> hierarchy in Darwin's CoreFoundation 344 framework and the <code>jobject</code> hierarchy in Java's JNI 345 interface. In Go 1.11, several improvements have been made to the code 346 that detects these types. Code that uses these types may need some 347 updating. See the <a href="go1.10.html#cgo">Go 1.10 release notes</a> for 348 details. <!-- CL 126275, CL 127156, CL 122217, CL 122575, CL 123177 --> 349 </p> 350 351 <h3 id="go_command">Go command</h3> 352 353 <p><!-- CL 126656 --> 354 The environment variable <code>GOFLAGS</code> may now be used 355 to set default flags for the <code>go</code> command. 356 This is useful in certain situations. 357 Linking can be noticeably slower on underpowered systems due to DWARF, 358 and users may want to set <code>-ldflags=-w</code> by default. 359 For modules, some users and CI systems will want vendoring always, 360 so they should set <code>-mod=vendor</code> by default. 361 For more information, see the <a href="/cmd/go/#hdr-Environment_variables"><code>go</code> 362 command documentation</a>. 363 </p> 364 365 <h3 id="godoc">Godoc</h3> 366 367 <p> 368 Go 1.11 will be the last release to support <code>godoc</code>'s command-line interface. 369 In future releases, <code>godoc</code> will only be a web server. Users should use 370 <code>go</code> <code>doc</code> for command-line help output instead. 371 </p> 372 373 <p><!-- CL 85396, CL 124495 --> 374 The <code>godoc</code> web server now shows which version of Go introduced 375 new API features. The initial Go version of types, funcs, and methods are shown 376 right-aligned. For example, see <a href="/pkg/os/#UserCacheDir"><code>UserCacheDir</code></a>, with "1.11" 377 on the right side. For struct fields, inline comments are added when the struct field was 378 added in a Go version other than when the type itself was introduced. 379 For a struct field example, see 380 <a href="/pkg/net/http/httptrace/#ClientTrace.Got1xxResponse"><code>ClientTrace.Got1xxResponse</code></a>. 381 </p> 382 383 <h3 id="gofmt">Gofmt</h3> 384 385 <p> 386 One minor detail of the default formatting of Go source code has changed. 387 When formatting expression lists with inline comments, the comments were 388 aligned according to a heuristic. 389 However, in some cases the alignment would be split up too easily, or 390 introduce too much whitespace. 391 The heuristic has been changed to behave better for human-written code. 392 </p> 393 394 <p> 395 Note that these kinds of minor updates to gofmt are expected from time to 396 time. 397 In general, systems that need consistent formatting of Go source code should 398 use a specific version of the <code>gofmt</code> binary. 399 See the <a href="/pkg/go/format/">go/format</a> package documentation for more 400 information. 401 </p> 402 403 <h2 id="runtime">Runtime</h2> 404 405 <p><!-- CL 85887 --> 406 The runtime now uses a sparse heap layout so there is no longer a 407 limit to the size of the Go heap (previously, the limit was 512GiB). 408 This also fixes rare "address space conflict" failures in mixed Go/C 409 binaries or binaries compiled with <code>-race</code>. 410 </p> 411 412 <p><!-- CL 108679, CL 106156 --> 413 On macOS and iOS, the runtime now uses <code>libSystem.dylib</code> instead of 414 calling the kernel directly. This should make Go binaries more 415 compatible with future versions of macOS and iOS. 416 The <a href="/pkg/syscall">syscall</a> package still makes direct 417 system calls; fixing this is planned for a future release. 418 </p> 419 420 <h2 id="performance">Performance</h2> 421 422 <p> 423 As always, the changes are so general and varied that precise 424 statements about performance are difficult to make. Most programs 425 should run a bit faster, due to better generated code and 426 optimizations in the core library. 427 </p> 428 429 <p><!-- CL 74851 --> 430 There were multiple performance changes to the <code>math/big</code> 431 package as well as many changes across the tree specific to <code>GOARCH=arm64</code>. 432 </p> 433 434 <h3 id="performance-compiler">Compiler toolchain</h3> 435 436 <p><!-- CL 110055 --> 437 The compiler now optimizes map clearing operations of the form: 438 </p> 439 <pre> 440 for k := range m { 441 delete(m, k) 442 } 443 </pre> 444 445 <p><!-- CL 109517 --> 446 The compiler now optimizes slice extension of the form 447 <code>append(s,</code> <code>make([]T,</code> <code>n)...)</code>. 448 </p> 449 450 <p><!-- CL 100277, CL 105635, CL 109776 --> 451 The compiler now performs significantly more aggressive bounds-check 452 and branch elimination. Notably, it now recognizes transitive 453 relations, so if <code>i<j</code> and <code>j<len(s)</code>, 454 it can use these facts to eliminate the bounds check 455 for <code>s[i]</code>. It also understands simple arithmetic such 456 as <code>s[i-10]</code> and can recognize more inductive cases in 457 loops. Furthermore, the compiler now uses bounds information to more 458 aggressively optimize shift operations. 459 </p> 460 461 <h2 id="library">Core library</h2> 462 463 <p> 464 All of the changes to the standard library are minor. 465 </p> 466 467 <h3 id="minor_library_changes">Minor changes to the library</h3> 468 469 <p> 470 As always, there are various minor changes and updates to the library, 471 made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a> 472 in mind. 473 </p> 474 475 <!-- CL 115095: https://golang.org/cl/115095: yes (`go test pkg` now always builds pkg even if there are no test files): cmd/go: output coverage report even if there are no test files --> 476 <!-- CL 110395: https://golang.org/cl/110395: cmd/go, cmd/compile: use Windows response files to avoid arg length limits --> 477 <!-- CL 112436: https://golang.org/cl/112436: cmd/pprof: add readline support similar to upstream --> 478 479 480 <dl id="crypto"><dt><a href="/pkg/crypto/">crypto</a></dt> 481 <dd> 482 <p><!-- CL 64451 --> 483 Certain crypto operations, including 484 <a href="/pkg/crypto/ecdsa/#Sign"><code>ecdsa.Sign</code></a>, 485 <a href="/pkg/crypto/rsa/#EncryptPKCS1v15"><code>rsa.EncryptPKCS1v15</code></a> and 486 <a href="/pkg/crypto/rsa/#GenerateKey"><code>rsa.GenerateKey</code></a>, 487 now randomly read an extra byte of randomness to ensure tests don't rely on internal behavior. 488 </p> 489 490 </dl><!-- crypto --> 491 492 <dl id="crypto/cipher"><dt><a href="/pkg/crypto/cipher/">crypto/cipher</a></dt> 493 <dd> 494 <p><!-- CL 48510, CL 116435 --> 495 The new function <a href="/pkg/crypto/cipher/#NewGCMWithTagSize"><code>NewGCMWithTagSize</code></a> 496 implements Galois Counter Mode with non-standard tag lengths for compatibility with existing cryptosystems. 497 </p> 498 499 </dl><!-- crypto/cipher --> 500 501 <dl id="crypto/rsa"><dt><a href="/pkg/crypto/rsa/">crypto/rsa</a></dt> 502 <dd> 503 <p><!-- CL 103876 --> 504 <a href="/pkg/crypto/rsa/#PublicKey"><code>PublicKey</code></a> now implements a 505 <a href="/pkg/crypto/rsa/#PublicKey.Size"><code>Size</code></a> method that 506 returns the modulus size in bytes. 507 </p> 508 509 </dl><!-- crypto/rsa --> 510 511 <dl id="crypto/tls"><dt><a href="/pkg/crypto/tls/">crypto/tls</a></dt> 512 <dd> 513 <p><!-- CL 85115 --> 514 <a href="/pkg/crypto/tls/#ConnectionState"><code>ConnectionState</code></a>'s new 515 <a href="/pkg/crypto/tls/#ConnectionState.ExportKeyingMaterial"><code>ExportKeyingMaterial</code></a> 516 method allows exporting keying material bound to the 517 connection according to RFC 5705. 518 </p> 519 520 </dl><!-- crypto/tls --> 521 522 <dl id="crypto/x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt> 523 <dd> 524 <p><!-- CL 123355, CL 123695 --> 525 The deprecated, legacy behavior of treating the <code>CommonName</code> field as 526 a hostname when no Subject Alternative Names are present is now disabled when the CN is not a 527 valid hostname. 528 The <code>CommonName</code> can be completely ignored by adding the experimental value 529 <code>x509ignoreCN=1</code> to the <code>GODEBUG</code> environment variable. 530 When the CN is ignored, certificates without SANs validate under chains with name constraints 531 instead of returning <code>NameConstraintsWithoutSANs</code>. 532 </p> 533 534 <p><!-- CL 113475 --> 535 Extended key usage restrictions are again checked only if they appear in the <code>KeyUsages</code> 536 field of <a href="/pkg/crypto/x509/#VerifyOptions"><code>VerifyOptions</code></a>, instead of always being checked. 537 This matches the behavior of Go 1.9 and earlier. 538 </p> 539 540 <p><!-- CL 102699 --> 541 The value returned by <a href="/pkg/crypto/x509/#SystemCertPool"><code>SystemCertPool</code></a> 542 is now cached and might not reflect system changes between invocations. 543 </p> 544 545 </dl><!-- crypto/x509 --> 546 547 <dl id="debug/elf"><dt><a href="/pkg/debug/elf/">debug/elf</a></dt> 548 <dd> 549 <p><!-- CL 112115 --> 550 More <a href="/pkg/debug/elf/#ELFOSABI_NONE"><code>ELFOSABI</code></a> 551 and <a href="/pkg/debug/elf/#EM_NONE"><code>EM</code></a> 552 constants have been added. 553 </p> 554 555 </dl><!-- debug/elf --> 556 557 <dl id="encoding/asn1"><dt><a href="/pkg/encoding/asn1/">encoding/asn1</a></dt> 558 <dd> 559 <p><!-- CL 110561 --> 560 <code>Marshal</code> and <code><a href="/pkg/encoding/asn1/#Unmarshal">Unmarshal</a></code> 561 now support "private" class annotations for fields. 562 </p> 563 564 </dl><!-- encoding/asn1 --> 565 566 <dl id="encoding/base32"><dt><a href="/pkg/encoding/base32/">encoding/base32</a></dt> 567 <dd> 568 <p><!-- CL 112516 --> 569 The decoder now consistently 570 returns <code>io.ErrUnexpectedEOF</code> for an incomplete 571 chunk. Previously it would return <code>io.EOF</code> in some 572 cases. 573 </p> 574 575 </dl><!-- encoding/base32 --> 576 577 <dl id="encoding/csv"><dt><a href="/pkg/encoding/csv/">encoding/csv</a></dt> 578 <dd> 579 <p><!-- CL 99696 --> 580 The <code>Reader</code> now rejects attempts to set 581 the <a href="/pkg/encoding/csv/#Reader.Comma"><code>Comma</code></a> 582 field to a double-quote character, as double-quote characters 583 already have a special meaning in CSV. 584 </p> 585 586 </dl><!-- encoding/csv --> 587 588 <!-- CL 100235 was reverted --> 589 590 <dl id="html/template"><dt><a href="/pkg/html/template/">html/template</a></dt> 591 <dd> 592 <p><!-- CL 121815 --> 593 The package has changed its behavior when a typed interface 594 value is passed to an implicit escaper function. Previously such 595 a value was written out as (an escaped form) 596 of <code><nil></code>. Now such values are ignored, just 597 as an untyped <code>nil</code> value is (and always has been) 598 ignored. 599 </p> 600 601 </dl><!-- html/template --> 602 603 <dl id="image/gif"><dt><a href="/pkg/image/gif/">image/gif</a></dt> 604 <dd> 605 <p><!-- CL 93076 --> 606 Non-looping animated GIFs are now supported. They are denoted by having a 607 <code><a href="/pkg/image/gif/#GIF.LoopCount">LoopCount</a></code> of -1. 608 </p> 609 610 </dl><!-- image/gif --> 611 612 <dl id="io/ioutil"><dt><a href="/pkg/io/ioutil/">io/ioutil</a></dt> 613 <dd> 614 <p><!-- CL 105675 --> 615 The <code><a href="/pkg/io/ioutil/#TempFile">TempFile</a></code> 616 function now supports specifying where the random characters in 617 the filename are placed. If the <code>prefix</code> argument 618 includes a "<code>*</code>", the random string replaces the 619 "<code>*</code>". For example, a <code>prefix</code> argument of "<code>myname.*.bat</code>" will 620 result in a random filename such as 621 "<code>myname.123456.bat</code>". If no "<code>*</code>" is 622 included the old behavior is retained, and the random digits are 623 appended to the end. 624 </p> 625 626 </dl><!-- io/ioutil --> 627 628 <dl id="math/big"><dt><a href="/pkg/math/big/">math/big</a></dt> 629 <dd> 630 631 <p><!-- CL 108996 --> 632 <a href="/pkg/math/big/#Int.ModInverse"><code>ModInverse</code></a> now returns nil when g and n are not relatively prime. The result was previously undefined. 633 </p> 634 635 </dl><!-- math/big --> 636 637 <dl id="mime/multipart"><dt><a href="/pkg/mime/multipart/">mime/multipart</a></dt> 638 <dd> 639 <p><!-- CL 121055 --> 640 The handling of form-data with missing/empty file names has been 641 restored to the behavior in Go 1.9: in the 642 <a href="/pkg/mime/multipart/#Form"><code>Form</code></a> for 643 the form-data part the value is available in 644 the <code>Value</code> field rather than the <code>File</code> 645 field. In Go releases 1.10 through 1.10.3 a form-data part with 646 a missing/empty file name and a non-empty "Content-Type" field 647 was stored in the <code>File</code> field. This change was a 648 mistake in 1.10 and has been reverted to the 1.9 behavior. 649 </p> 650 651 </dl><!-- mime/multipart --> 652 653 <dl id="mime/quotedprintable"><dt><a href="/pkg/mime/quotedprintable/">mime/quotedprintable</a></dt> 654 <dd> 655 <p><!-- CL 121095 --> 656 To support invalid input found in the wild, the package now 657 permits non-ASCII bytes but does not validate their encoding. 658 </p> 659 660 </dl><!-- mime/quotedprintable --> 661 662 <dl id="net"><dt><a href="/pkg/net/">net</a></dt> 663 <dd> 664 <p><!-- CL 72810 --> 665 The new <a href="/pkg/net/#ListenConfig"><code>ListenConfig</code></a> type and the new 666 <a href="/pkg/net/#Dialer.Control"><code>Dialer.Control</code></a> field permit 667 setting socket options before accepting and creating connections, respectively. 668 </p> 669 670 <p><!-- CL 76391 --> 671 The <a href="/pkg/syscall/#RawConn"><code>syscall.RawConn</code></a> <code>Read</code> 672 and <code>Write</code> methods now work correctly on Windows. 673 </p> 674 675 <p><!-- CL 107715 --> 676 The <code>net</code> package now automatically uses the 677 <a href="http://man7.org/linux/man-pages/man2/splice.2.html"><code>splice</code> system call</a> 678 on Linux when copying data between TCP connections in 679 <a href="/pkg/net/#TCPConn.ReadFrom"><code>TCPConn.ReadFrom</code></a>, as called by 680 <a href="/pkg/io/#Copy"><code>io.Copy</code></a>. The result is faster, more efficient TCP proxying. 681 </p> 682 683 <p><!-- CL 108297 --> 684 The <a href="/pkg/net/#TCPConn.File"><code>TCPConn.File</code></a>, 685 <a href="/pkg/net/#UDPConn.File"><code>UDPConn.File</code></a>, 686 <a href="/pkg/net/#UnixCOnn.File"><code>UnixConn.File</code></a>, 687 and <a href="/pkg/net/#IPConn.File"><code>IPConn.File</code></a> 688 methods no longer put the returned <code>*os.File</code> into 689 blocking mode. 690 </p> 691 692 </dl><!-- net --> 693 694 <dl id="net/http"><dt><a href="/pkg/net/http/">net/http</a></dt> 695 <dd> 696 <p><!-- CL 71272 --> 697 The <a href="/pkg/net/http/#Transport"><code>Transport</code></a> type has a 698 new <a href="/pkg/net/http/#Transport.MaxConnsPerHost"><code>MaxConnsPerHost</code></a> 699 option that permits limiting the maximum number of connections 700 per host. 701 </p> 702 703 <p><!-- CL 79919 --> 704 The <a href="/pkg/net/http/#Cookie"><code>Cookie</code></a> type has a new 705 <a href="/pkg/net/http/#Cookie.SameSite"><code>SameSite</code></a> field 706 (of new type also named 707 <a href="/pkg/net/http/#SameSite"><code>SameSite</code></a>) to represent the new cookie attribute recently supported by most browsers. 708 The <code>net/http</code>'s <code>Transport</code> does not use the <code>SameSite</code> 709 attribute itself, but the package supports parsing and serializing the 710 attribute for browsers to use. 711 </p> 712 713 <p><!-- CL 81778 --> 714 It is no longer allowed to reuse a <a href="/pkg/net/http/#Server"><code>Server</code></a> 715 after a call to 716 <a href="/pkg/net/http/#Server.Shutdown"><code>Shutdown</code></a> or 717 <a href="/pkg/net/http/#Server.Close"><code>Close</code></a>. It was never officially supported 718 in the past and had often surprising behavior. Now, all future calls to the server's <code>Serve</code> 719 methods will return errors after a shutdown or close. 720 </p> 721 722 <!-- CL 89275 was reverted before Go 1.11 --> 723 724 <p><!-- CL 93296 --> 725 The constant <code>StatusMisdirectedRequest</code> is now defined for HTTP status code 421. 726 </p> 727 728 <p><!-- CL 123875 --> 729 The HTTP server will no longer cancel contexts or send on 730 <a href="/pkg/net/http/#CloseNotifier"><code>CloseNotifier</code></a> 731 channels upon receiving pipelined HTTP/1.1 requests. Browsers do 732 not use HTTP pipelining, but some clients (such as 733 Debian's <code>apt</code>) may be configured to do so. 734 </p> 735 736 <p><!-- CL 115255 --> 737 <a href="/pkg/net/http/#ProxyFromEnvironment"><code>ProxyFromEnvironment</code></a>, which is used by the 738 <a href="/pkg/net/http/#DefaultTransport"><code>DefaultTransport</code></a>, now 739 supports CIDR notation and ports in the <code>NO_PROXY</code> environment variable. 740 </p> 741 742 </dl><!-- net/http --> 743 744 <dl id="net/http/httputil"><dt><a href="/pkg/net/http/httputil/">net/http/httputil</a></dt> 745 <dd> 746 <p><!-- CL 77410 --> 747 The 748 <a href="/pkg/net/http/httputil/#ReverseProxy"><code>ReverseProxy</code></a> 749 has a new 750 <a href="/pkg/net/http/httputil/#ReverseProxy.ErrorHandler"><code>ErrorHandler</code></a> 751 option to permit changing how errors are handled. 752 </p> 753 754 <p><!-- CL 115135 --> 755 The <code>ReverseProxy</code> now also passes 756 "<code>TE:</code> <code>trailers</code>" request headers 757 through to the backend, as required by the gRPC protocol. 758 </p> 759 760 </dl><!-- net/http/httputil --> 761 762 <dl id="os"><dt><a href="/pkg/os/">os</a></dt> 763 <dd> 764 <p><!-- CL 78835 --> 765 The new <a href="/pkg/os/#UserCacheDir"><code>UserCacheDir</code></a> function 766 returns the default root directory to use for user-specific cached data. 767 </p> 768 769 <p><!-- CL 94856 --> 770 The new <a href="/pkg/os/#ModeIrregular"><code>ModeIrregular</code></a> 771 is a <a href="/pkg/os/#FileMode"><code>FileMode</code></a> bit to represent 772 that a file is not a regular file, but nothing else is known about it, or that 773 it's not a socket, device, named pipe, symlink, or other file type for which 774 Go has a defined mode bit. 775 </p> 776 777 <p><!-- CL 99337 --> 778 <a href="/pkg/os/#Symlink"><code>Symlink</code></a> now works 779 for unprivileged users on Windows 10 on machines with Developer 780 Mode enabled. 781 </p> 782 783 <p><!-- CL 100077 --> 784 When a non-blocking descriptor is passed 785 to <a href="/pkg/os#NewFile"><code>NewFile</code></a>, the 786 resulting <code>*File</code> will be kept in non-blocking 787 mode. This means that I/O for that <code>*File</code> will use 788 the runtime poller rather than a separate thread, and that 789 the <a href="/pkg/os/#File.SetDeadline"><code>SetDeadline</code></a> 790 methods will work. 791 </p> 792 793 </dl><!-- os --> 794 795 <dl id="os/signal"><dt><a href="/pkg/os/signal/">os/signal</a></dt> 796 <dd> 797 <p><!-- CL 108376 --> 798 The new <a href="/pkg/os/signal/#Ignored"><code>Ignored</code></a> function reports 799 whether a signal is currently ignored. 800 </p> 801 802 </dl><!-- os/signal --> 803 804 <dl id="os/user"><dt><a href="/pkg/os/user/">os/user</a></dt> 805 <dd> 806 <p><!-- CL 92456 --> 807 The <code>os/user</code> package can now be built in pure Go 808 mode using the build tag "<code>osusergo</code>", 809 independent of the use of the environment 810 variable <code>CGO_ENABLED=0</code>. Previously the only way to use 811 the package's pure Go implementation was to disable <code>cgo</code> 812 support across the entire program. 813 </p> 814 815 </dl><!-- os/user --> 816 817 <!-- CL 101715 was reverted --> 818 819 <dl id="runtime-again"><dt><a href="/pkg/runtime/">runtime</a></dt> 820 <dd> 821 822 <p><!-- CL 70993 --> 823 Setting the <code>GODEBUG=tracebackancestors=<em>N</em></code> 824 environment variable now extends tracebacks with the stacks at 825 which goroutines were created, where <em>N</em> limits the 826 number of ancestor goroutines to report. 827 </p> 828 829 </dl><!-- runtime --> 830 831 <dl id="runtime/pprof"><dt><a href="/pkg/runtime/pprof/">runtime/pprof</a></dt> 832 <dd> 833 <p><!-- CL 102696 --> 834 This release adds a new "allocs" profile type that profiles 835 total number of bytes allocated since the program began 836 (including garbage-collected bytes). This is identical to the 837 existing "heap" profile viewed in <code>-alloc_space</code> mode. 838 Now <code>go test -memprofile=...</code> reports an "allocs" profile 839 instead of "heap" profile. 840 </p> 841 842 </dl><!-- runtime/pprof --> 843 844 <dl id="sync"><dt><a href="/pkg/sync/">sync</a></dt> 845 <dd> 846 <p><!-- CL 87095 --> 847 The mutex profile now includes reader/writer contention 848 for <a href="/pkg/sync/#RWMutex"><code>RWMutex</code></a>. 849 Writer/writer contention was already included in the mutex 850 profile. 851 </p> 852 853 </dl><!-- sync --> 854 855 <dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt> 856 <dd> 857 <p><!-- CL 106275 --> 858 On Windows, several fields were changed from <code>uintptr</code> to a new 859 <a href="/pkg/syscall/?GOOS=windows&GOARCH=amd64#Pointer"><code>Pointer</code></a> 860 type to avoid problems with Go's garbage collector. The same change was made 861 to the <a href="https://godoc.org/golang.org/x/sys/windows"><code>golang.org/x/sys/windows</code></a> 862 package. For any code affected, users should first migrate away from the <code>syscall</code> 863 package to the <code>golang.org/x/sys/windows</code> package, and then change 864 to using the <code>Pointer</code>, while obeying the 865 <a href="/pkg/unsafe/#Pointer"><code>unsafe.Pointer</code> conversion rules</a>. 866 </p> 867 868 <p><!-- CL 118658 --> 869 On Linux, the <code>flags</code> parameter to 870 <a href="/pkg/syscall/?GOOS=linux&GOARCH=amd64#Faccessat"><code>Faccessat</code></a> 871 is now implemented just as in glibc. In earlier Go releases the 872 flags parameter was ignored. 873 </p> 874 875 <p><!-- CL 118658 --> 876 On Linux, the <code>flags</code> parameter to 877 <a href="/pkg/syscall/?GOOS=linux&GOARCH=amd64#Fchmodat"><code>Fchmodat</code></a> 878 is now validated. Linux's <code>fchmodat</code> doesn't support the <code>flags</code> parameter 879 so we now mimic glibc's behavior and return an error if it's non-zero. 880 </p> 881 882 </dl><!-- syscall --> 883 884 <dl id="text/scanner"><dt><a href="/pkg/text/scanner/">text/scanner</a></dt> 885 <dd> 886 <p><!-- CL 112037 --> 887 The <a href="/pkg/text/scanner/#Scanner.Scan"><code>Scanner.Scan</code></a> method now returns 888 the <a href="/pkg/text/scanner/#RawString"><code>RawString</code></a> token 889 instead of <a href="/pkg/text/scanner/#String"><code>String</code></a> 890 for raw string literals. 891 </p> 892 893 </dl><!-- text/scanner --> 894 895 <dl id="text/template"><dt><a href="/pkg/text/template/">text/template</a></dt> 896 <dd> 897 <p><!-- CL 84480 --> 898 Modifying template variables via assignments is now permitted via the <code>=</code> token: 899 </p> 900 <pre> 901 {{"{{"}} $v := "init" {{"}}"}} 902 {{"{{"}} if true {{"}}"}} 903 {{"{{"}} $v = "changed" {{"}}"}} 904 {{"{{"}} end {{"}}"}} 905 v: {{"{{"}} $v {{"}}"}} {{"{{"}}/* "changed" */{{"}}"}}</pre> 906 907 <p><!-- CL 95215 --> 908 In previous versions untyped <code>nil</code> values passed to 909 template functions were ignored. They are now passed as normal 910 arguments. 911 </p> 912 913 </dl><!-- text/template --> 914 915 <dl id="time"><dt><a href="/pkg/time/">time</a></dt> 916 <dd> 917 <p><!-- CL 98157 --> 918 Parsing of timezones denoted by sign and offset is now 919 supported. In previous versions, numeric timezone names 920 (such as <code>+03</code>) were not considered valid, and only 921 three-letter abbreviations (such as <code>MST</code>) were accepted 922 when expecting a timezone name. 923 </p> 924 </dl><!-- time -->