go1.13.html 45 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<!--{
        "Title": "Go 1.13 Release Notes",
        "Path":  "/doc/go1.13",
        "Template": true
}-->

<!--
NOTE: In this document and others in this directory, the convention is to
set fixed-width phrases with non-fixed-width spaces, as in
<code>hello</code> <code>world</code>.
Do not send CLs removing the interior tags from such phrases.
-->

<style>
obei's avatar
obei committed
15
  main ul li { margin: 0.5em 0; }
16 17
</style>

18
<h2 id="introduction">Introduction to Go 1.13</h2>
19 20

<p>
21 22 23 24
  The latest Go release, version 1.13, arrives six months after <a href="go1.12">Go 1.12</a>.
  Most of its changes are in the implementation of the toolchain, runtime, and libraries.
  As always, the release maintains the Go 1 <a href="/doc/go1compat.html">promise of compatibility</a>.
  We expect almost all Go programs to continue to compile and run as before.
25 26
</p>

27
<p>
28 29
  As of Go 1.13, the go command by default downloads and authenticates
  modules using the Go module mirror and Go checksum database run by Google. See
30 31 32
  <a href="https://proxy.golang.org/privacy">https://proxy.golang.org/privacy</a>
  for privacy information about these services and the
  <a href="/cmd/go/#hdr-Module_downloading_and_verification">go command documentation</a>
33
  for configuration details including how to disable the use of these servers or use
34 35
  different ones. If you depend on non-public modules, see the
  <a href="/cmd/go/#hdr-Module_configuration_for_non_public_modules">documentation for configuring your environment</a>.
36 37
</p>

38 39 40
<h2 id="language">Changes to the language</h2>

<p>
41 42 43 44
  Per the <a href="https://github.com/golang/proposal/blob/master/design/19308-number-literals.md">number literal proposal</a>,
  Go 1.13 supports a more uniform and modernized set of number literal prefixes.
  <ul>
    <li>
45
      <a href="/ref/spec#Integer_literals">Binary integer literals</a>:
46 47 48 49 50
      The prefix <code>0b</code> or <code>0B</code> indicates a binary integer literal
      such as <code>0b1011</code>.
    </li>

    <li>
51
      <a href="/ref/spec#Integer_literals">Octal integer literals</a>:
52 53 54 55 56 57 58
      The prefix <code>0o</code> or <code>0O</code> indicates an octal integer literal
      such as <code>0o660</code>.
      The existing octal notation indicated by a leading <code>0</code> followed by
      octal digits remains valid.
    </li>

    <li>
59
      <a href="/ref/spec#Floating-point_literals">Hexadecimal floating point literals</a>:
60 61 62 63 64 65 66 67
      The prefix <code>0x</code> or <code>0X</code> may now be used to express the mantissa of a
      floating-point number in hexadecimal format such as <code>0x1.0p-1021</code>.
      A hexadecimal floating-point number must always have an exponent, written as the letter
      <code>p</code> or <code>P</code> followed by an exponent in decimal. The exponent scales
      the mantissa by 2 to the power of the exponent.
    </li>

    <li>
68
      <a href="/ref/spec#Imaginary_literals">Imaginary literals</a>:
69 70 71 72 73 74 75 76 77 78 79
      The imaginary suffix <code>i</code> may now be used with any (binary, decimal, hexadecimal)
      integer or floating-point literal.
    </li>

    <li>
      Digit separators:
      The digits of any number literal may now be separated (grouped) using underscores, such as
      in <code>1_000_000</code>, <code>0b_1010_0110</code>, or <code>3.1415_9265</code>.
      An underscore may appear between any two digits or the literal prefix and the first digit.
    </li>
  </ul>
80 81
</p>

82 83
<p>
  Per the <a href="https://github.com/golang/proposal/blob/master/design/19113-signed-shift-counts.md">signed shift counts proposal</a>
84
  Go 1.13 removes the restriction that a <a href="/ref/spec#Operators">shift count</a>
85 86 87 88 89 90
  must be unsigned. This change eliminates the need for many artificial <code>uint</code> conversions,
  solely introduced to satisfy this (now removed) restriction of the <code>&lt;&lt;</code> and <code>&gt;&gt;</code> operators.
</p>

<p>
  These language changes were implemented by changes to the compiler, and corresponding internal changes to the library
91 92 93
  packages <code><a href="#go/scanner">go/scanner</a></code> and
  <code><a href="#text/scanner">text/scanner</a></code> (number literals),
  and <code><a href="#go/types">go/types</a></code> (signed shift counts).
94 95
</p>

96 97 98 99 100 101 102
<p>
  If your code uses modules and your <code>go.mod</code> files specifies a language version, be sure
  it is set to at least <code>1.13</code> to get access to these language changes.
  You can do this by editing the <code>go.mod</code> file directly, or you can run
  <code>go mod edit -go=1.13</code>.
</p>

103 104
<h2 id="ports">Ports</h2>

105 106 107 108
<p>
  Go 1.13 is the last release that will run on Native Client (NaCl).
</p>

109 110 111 112 113
<p><!-- CL 170119, CL 168882 -->
  For <code>GOARCH=wasm</code>, the new environment variable <code>GOWASM</code> takes a comma-separated list of experimental features that the binary gets compiled with.
  The valid values are documented <a href="/cmd/go/#hdr-Environment_variables">here</a>.
</p>

114 115 116 117 118 119 120 121
<h3 id="aix">AIX</h3>

<p><!-- CL 164003, CL 169120 -->
  AIX on PPC64 (<code>aix/ppc64</code>) now supports cgo, external
  linking, and the <code>c-archive</code> and <code>pie</code> build
  modes.
</p>

122 123 124
<h3 id="android">Android</h3>

<p><!-- CL 170127 -->
125
  Go programs are now compatible with Android 10.
126 127
</p>

128 129 130 131 132 133 134 135 136 137 138 139 140 141
<h3 id="darwin">Darwin</h3>

<p>
  As <a href="go1.12#darwin">announced</a> in the Go 1.12 release notes,
  Go 1.13 now requires macOS 10.11 El Capitan or later;
  support for previous versions has been discontinued.
</p>

<h3 id="freebsd">FreeBSD</h3>

<p>
  As <a href="go1.12#freebsd">announced</a> in the Go 1.12 release notes,
  Go 1.13 now requires FreeBSD 11.2 or later;
  support for previous versions has been discontinued.
142 143
  FreeBSD 12.0 or later requires a kernel with the <code>COMPAT_FREEBSD11</code>
  option set (this is the default).
144 145
</p>

146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
<h3 id="illumos">Illumos</h3>

<p><!-- CL 174457 -->
  Go now supports Illumos with <code>GOOS=illumos</code>.
  The <code>illumos</code> build tag implies the <code>solaris</code>
  build tag.
</p>

<h3 id="windows">Windows</h3>

<p><!-- CL 178977 -->
  The Windows version specified by internally-linked Windows binaries
  is now Windows 7 rather than NT 4.0. This was already the minimum
  required version for Go, but can affect the behavior of system calls
  that have a backwards-compatibility mode. These will now behave as
  documented. Externally-linked binaries (any program using cgo) have
  always specified a more recent Windows version.
163 164
</p>

165 166
<h2 id="tools">Tools</h2>

167 168
<h3 id="modules">Modules</h3>

169 170
<h4 id="proxy-vars">Environment variables</h4>

171 172 173 174 175 176 177 178 179 180 181
<p><!-- CL 176580 -->
  The <a href="/cmd/go/#hdr-Module_support"><code>GO111MODULE</code></a>
  environment variable continues to default to <code>auto</code>, but
  the <code>auto</code> setting now activates the module-aware mode of
  the <code>go</code> command whenever the current working directory contains,
  or is below a directory containing, a <code>go.mod</code> file — even if the
  current directory is within <code>GOPATH/src</code>. This change simplifies
  the migration of existing code within <code>GOPATH/src</code> and the ongoing
  maintenance of module-aware packages alongside non-module-aware importers.
</p>

182 183 184 185
<p><!-- CL 181719 -->
  The new
  <a href="/cmd/go/#hdr-Module_configuration_for_non_public_modules"><code>GOPRIVATE</code></a>
  environment variable indicates module paths that are not publicly available.
186 187 188
  It serves as the default value for the lower-level <code>GONOPROXY</code>
  and <code>GONOSUMDB</code> variables, which provide finer-grained control over
  which modules are fetched via proxy and verified using the checksum database.
189 190 191 192 193 194 195 196
</p>

<p><!-- CL 173441, CL 177958 -->
  The <a href="/cmd/go/#hdr-Module_downloading_and_verification"><code>GOPROXY</code>
  environment variable</a> may now be set to a comma-separated list of proxy
  URLs or the special token <code>direct</code>, and
  its <a href="#introduction">default value</a> is
  now <code>https://proxy.golang.org,direct</code>. When resolving a package
197 198 199 200
  path to its containing module, the <code>go</code> command will try all
  candidate module paths on each proxy in the list in succession. An unreachable
  proxy or HTTP status code other than 404 or 410 terminates the search without
  consulting the remaining proxies.
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
</p>

<p>
  The new
  <a href="/cmd/go/#hdr-Module_authentication_failures"><code>GOSUMDB</code></a>
  environment variable identifies the name, and optionally the public key and
  server URL, of the database to consult for checksums of modules that are not
  yet listed in the main module's <code>go.sum</code> file.
  If <code>GOSUMDB</code> does not include an explicit URL, the URL is chosen by
  probing the <code>GOPROXY</code> URLs for an endpoint indicating support for
  the checksum database, falling back to a direct connection to the named
  database if it is not supported by any proxy. If <code>GOSUMDB</code> is set
  to <code>off</code>, the checksum database is not consulted and only the
  existing checksums in the <code>go.sum</code> file are verified.
</p>

<p>
  Users who cannot reach the default proxy and checksum database (for example,
  due to a firewalled or sandboxed configuration) may disable their use by
  setting <code>GOPROXY</code> to <code>direct</code>, and/or
  <code>GOSUMDB</code> to <code>off</code>.
  <a href="#go-env-w"><code>go</code> <code>env</code> <code>-w</code></a>
  can be used to set the default values for these variables independent of
  platform:
</p>
<pre>
go env -w GOPROXY=direct
go env -w GOSUMDB=off
</pre>

231
<h4 id="go-get"><code>go</code> <code>get</code></h4>
232 233

<p><!-- CL 174099 -->
234 235 236 237
  In module-aware mode,
  <a href="/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them"><code>go</code> <code>get</code></a>
  with the <code>-u</code> flag now updates a smaller set of modules that is
  more consistent with the set of packages updated by
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
  <code>go</code> <code>get</code> <code>-u</code> in GOPATH mode.
  <code>go</code> <code>get</code> <code>-u</code> continues to update the
  modules and packages named on the command line, but additionally updates only
  the modules containing the packages <em>imported by</em> the named packages,
  rather than the transitive module requirements of the modules containing the
  named packages.
</p>

<p>
  Note in particular that <code>go</code> <code>get</code> <code>-u</code>
  (without additional arguments) now updates only the transitive imports of the
  package in the current directory. To instead update all of the packages
  transitively imported by the main module (including test dependencies), use
  <code>go</code> <code>get</code> <code>-u</code> <code>all</code>.
</p>

<p><!-- CL 177879 -->
  As a result of the above changes to
  <code>go</code> <code>get</code> <code>-u</code>, the
  <code>go</code> <code>get</code> subcommand no longer supports
  the <code>-m</code> flag, which caused <code>go</code> <code>get</code> to
  stop before loading packages. The <code>-d</code> flag remains supported, and
  continues to cause <code>go</code> <code>get</code> to stop after downloading
  the source code needed to build dependencies of the named packages.
</p>

264 265 266 267 268
<p><!-- CL 177677 -->
  By default, <code>go</code> <code>get</code> <code>-u</code> in module mode
  upgrades only non-test dependencies, as in GOPATH mode. It now also accepts
  the <code>-t</code> flag, which (as in GOPATH mode)
  causes <code>go</code> <code>get</code> to include the packages imported
269
  by <em>tests of</em> the packages named on the command line.
270 271
</p>

272 273 274 275 276 277 278 279
<p><!-- CL 167747 -->
  In module-aware mode, the <code>go</code> <code>get</code> subcommand now
  supports the version suffix <code>@patch</code>. The <code>@patch</code>
  suffix indicates that the named module, or module containing the named
  package, should be updated to the highest patch release with the same
  major and minor versions as the version found in the build list.
</p>

280 281 282 283 284 285 286 287 288 289 290
<p><!-- CL 184440 -->
  If a module passed as an argument to <code>go</code> <code>get</code>
  without a version suffix is already required at a newer version than the
  latest released version, it will remain at the newer version. This is
  consistent with the behavior of the <code>-u</code> flag for module
  dependencies. This prevents unexpected downgrades from pre-release versions.
  The new version suffix <code>@upgrade</code> explicitly requests this
  behavior. <code>@latest</code> explicitly requests the latest version
  regardless of the current version.
</p>

291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
<h4 id="version-validation">Version validation</h4><!-- CL 181881 -->

<p>
  When extracting a module from a version control system, the <code>go</code>
  command now performs additional validation on the requested version string.
</p>

<p>
  The <code>+incompatible</code> version annotation bypasses the requirement
  of <a href="/cmd/go/#hdr-Module_compatibility_and_semantic_versioning">semantic
  import versioning</a> for repositories that predate the introduction of
  modules. The <code>go</code> command now verifies that such a version does not
  include an explicit <code>go.mod</code> file.
</p>

<p>
  The <code>go</code> command now verifies the mapping
308
  between <a href="/cmd/go/#hdr-Pseudo_versions">pseudo-versions</a> and
309 310
  version-control metadata. Specifically:
  <ul>
311 312 313 314
    <li>The version prefix must be of the form <code>vX.0.0</code>, or derived
    from a tag on an ancestor of the named revision, or derived from a tag that
    includes <a href="https://semver.org/#spec-item-10">build metadata</a> on
    the named revision itself.</li>
315 316 317 318 319 320 321 322 323 324

    <li>The date string must match the UTC timestamp of the revision.</li>

    <li>The short name of the revision must use the same number of characters as
    what the <code>go</code> command would generate. (For SHA-1 hashes as used
    by <code>git</code>, a 12-digit prefix.)</li>
  </ul>
</p>

<p>
325 326 327 328
  If a <code>require</code> directive in the
  <a href="/cmd/go/#hdr-The_main_module_and_the_build_list">main module</a> uses
  an invalid pseudo-version, it can usually be corrected by redacting the
  version to just the commit hash and re-running a <code>go</code> command, such
329
  as <code>go</code> <code>list</code> <code>-m</code> <code>all</code>
330
  or <code>go</code> <code>mod</code> <code>tidy</code>. For example,
331
</p>
332 333 334 335 336
<pre>require github.com/docker/docker v1.14.0-0.20190319215453-e7b5f7dbe98c</pre>
<p>can be redacted to</p>
<pre>require github.com/docker/docker e7b5f7dbe98c</pre>
<p>which currently resolves to</p>
<pre>require github.com/docker/docker v0.7.3-0.20190319215453-e7b5f7dbe98c</pre>
337 338

<p>
339 340 341 342 343 344 345
  If one of the transitive dependencies of the main module requires an invalid
  version or pseudo-version, the invalid version can be replaced with a valid
  one using a
  <a href="/cmd/go/#hdr-The_go_mod_file"><code>replace</code> directive</a> in
  the <code>go.mod</code> file of the main module. If the replacement is a
  commit hash, it will be resolved to the appropriate pseudo-version as above.
  For example,
346
</p>
347 348 349
<pre>replace github.com/docker/docker v1.14.0-0.20190319215453-e7b5f7dbe98c => github.com/docker/docker e7b5f7dbe98c</pre>
<p>currently resolves to</p>
<pre>replace github.com/docker/docker v1.14.0-0.20190319215453-e7b5f7dbe98c => github.com/docker/docker v0.7.3-0.20190319215453-e7b5f7dbe98c</pre>
350

351 352
<h3 id="go-command">Go command</h3>

353 354 355
<p id="go-env-w"><!-- CL 171137 -->
  The <a href="/cmd/go/#hdr-Environment_variables"><code>go</code> <code>env</code></a>
  command now accepts a <code>-w</code> flag to set the per-user default value
Tobias Klauser's avatar
Tobias Klauser committed
356
  of an environment variable recognized by the
357 358 359 360 361 362 363
  <code>go</code> command, and a corresponding <code>-u</code> flag to unset a
  previously-set default. Defaults set via
  <code>go</code> <code>env</code> <code>-w</code> are stored in the
  <code>go/env</code> file within
  <a href="/pkg/os/#UserConfigDir"><code>os.UserConfigDir()</code></a>.
</p>

364 365 366 367 368 369 370 371 372 373 374 375
<p id="go-version-exe"><!-- CL 173343 -->
  The <a href="/cmd/go/#hdr-Print_Go_version">
  <code>go</code> <code>version</code></a> command now accepts arguments naming
  executables and directories. When invoked on an executable,
  <code>go</code> <code>version</code> prints the version of Go used to build
  the executable. If the <code>-m</code> flag is used,
  <code>go</code> <code>version</code> prints the executable's embedded module
  version information, if available. When invoked on a directory,
  <code>go</code> <code>version</code> prints information about executables
  contained in the directory and its subdirectories.
</p>

376 377 378 379 380 381
<p id="trimpath"><!-- CL 173345 -->
  The new <a href="/cmd/go/#hdr-Compile_packages_and_dependencies"><code>go</code>
  <code>build</code> flag</a> <code>-trimpath</code> removes all file system paths
  from the compiled executable, to improve build reproducibility.
</p>

382 383 384 385 386 387 388
<p id="o-dir"><!-- CL 167679 -->
  If the <code>-o</code> flag passed to <code>go</code> <code>build</code>
  refers to an existing directory, <code>go</code> <code>build</code> will now
  write executable files within that directory for <code>main</code> packages
  matching its package arguments.
</p>

389 390 391 392 393 394 395 396 397 398 399 400 401
<p id="comma-separated-tags"><!-- CL 173438 -->
  The <code>go</code> <code>build</code> flag <code>-tags</code> now takes a
  comma-separated list of build tags, to allow for multiple tags in
  <a href="/cmd/go/#hdr-Environment_variables"><code>GOFLAGS</code></a>. The
  space-separated form is deprecated but still recognized and will be maintained.
</p>

<p id="go-generate-tag"><!-- CL 175983 -->
  <a href="/cmd/go/#hdr-Generate_Go_files_by_processing_source"><code>go</code>
  <code>generate</code></a> now sets the <code>generate</code> build tag so that
  files may be searched for directives but ignored during build.
</p>

402 403 404 405 406 407 408
<p id="binary-only"><!-- CL 165746 -->
  As <a href="/doc/go1.12#binary-only">announced</a> in the Go 1.12 release
  notes, binary-only packages are no longer supported. Building a binary-only
  package (marked with a <code>//go:binary-only-package</code> comment) now
  results in an error.
</p>

409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
<h3 id="compiler">Compiler toolchain</h3>

<p><!-- CL 170448 -->
  The compiler has a new implementation of escape analysis that is
  more precise. For most Go code should be an improvement (in other
  words, more Go variables and expressions allocated on the stack
  instead of heap). However, this increased precision may also break
  invalid code that happened to work before (for example, code that
  violates
  the <a href="/pkg/unsafe/#Pointer"><code>unsafe.Pointer</code>
  safety rules</a>). If you notice any regressions that appear
  related, the old escape analysis pass can be re-enabled
  with <code>go</code> <code>build</code> <code>-gcflags=all=-newescape=false</code>.
  The option to use the old escape analysis will be removed in a
  future release.
</p>

<p><!-- CL 161904 -->
  The compiler no longer emits floating point or complex constants
  to <code>go_asm.h</code> files. These have always been emitted in a
  form that could not be used as numeric constant in assembly code.
</p>

432 433 434 435 436 437 438
<h3 id="assembler">Assembler</h3>

<p><!-- CL 157001 -->
  The assembler now supports many of the atomic instructions
  introduced in ARM v8.1.
</p>

439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
<h3 id="gofmt">gofmt</h3>

<p>
  <code>gofmt</code> (and with that <code>go fmt</code>) now canonicalizes
  number literal prefixes and exponents to use lower-case letters, but
  leaves hexadecimal digits alone. This improves readability when using the new octal prefix
  (<code>0O</code> becomes <code>0o</code>), and the rewrite is applied consistently.
  <code>gofmt</code> now also removes unnecessary leading zeroes from a decimal integer
  imaginary literal. (For backwards-compatibility, an integer imaginary literal
  starting with <code>0</code> is considered a decimal, not an octal number.
  Removing superfluous leading zeroes avoids potential confusion.)
  For instance, <code>0B1010</code>, <code>0XabcDEF</code>, <code>0O660</code>,
  <code>1.2E3</code>, and <code>01i</code> become <code>0b1010</code>, <code>0xabcDEF</code>,
  <code>0o660</code>, <code>1.2e3</code>, and <code>1i</code> after applying <code>gofmt</code>.
</p>

455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
<h3 id="godoc"><code>godoc</code> and <code>go</code> <code>doc</code></h3>

<p><!-- CL 174322 -->
  The <code>godoc</code> webserver is no longer included in the main binary distribution.
  To run the <code>godoc</code> webserver locally, manually install it first:
<pre>
go get golang.org/x/tools/cmd/godoc
godoc
</pre>
</p>

<p><!-- CL 177797 -->
  The
  <a href="/cmd/go/#hdr-Show_documentation_for_package_or_symbol"><code>go</code> <code>doc</code></a>
  command now always includes the package clause in its output, except for
  commands. This replaces the previous behavior where a heuristic was used,
  causing the package clause to be omitted under certain conditions.
</p>

474 475
<h2 id="runtime">Runtime</h2>

476 477 478 479 480
<p><!-- CL 161477 -->
  Out of range panic messages now include the index that was out of
  bounds and the length (or capacity) of the slice. For
  example, <code>s[3]</code> on a slice of length 1 will panic with
  "runtime error: index out of range [3] with length 1".
481 482
</p>

483 484 485 486 487 488 489 490 491 492 493 494 495 496
<p><!-- CL 171758 -->
  This release improves performance of most uses of <code>defer</code>
  by 30%.
</p>

<p><!-- CL 142960 -->
  The runtime is now more aggressive at returning memory to the
  operating system to make it available to co-tenant applications.
  Previously, the runtime could retain memory for five or more minutes
  following a spike in the heap size. It will now begin returning it
  promptly after the heap shrinks. However, on many OSes, including
  Linux, the OS itself reclaims memory lazily, so process RSS will not
  decrease until the system is under memory pressure.
</p>
497 498 499 500 501 502

<h2 id="library">Core library</h2>

<h3 id="tls_1_3">TLS 1.3</h3>

<p>
503 504 505 506
  As announced in Go 1.12, Go 1.13 enables support for TLS 1.3 in the
  <code>crypto/tls</code> package by default. It can be disabled by adding the
  value <code>tls13=0</code> to the <code>GODEBUG</code>
  environment variable. The opt-out will be removed in Go 1.14.
507 508
</p>

509 510 511 512 513 514 515 516 517 518 519 520 521 522 523
<p>
  See <a href="/doc/go1.12#tls_1_3">the Go 1.12 release notes</a> for important
  compatibility information.
</p>

<h3 id="crypto/ed25519"><a href="/pkg/crypto/ed25519/">crypto/ed25519</a></h3>

<p><!-- CL 174945, 182698 -->
  The new <a href="/pkg/crypto/ed25519/"><code>crypto/ed25519</code></a>
  package implements the Ed25519 signature
  scheme. This functionality was previously provided by the
  <a href="https://godoc.org/golang.org/x/crypto/ed25519"><code>golang.org/x/crypto/ed25519</code></a>
  package, which becomes a wrapper for
  <code>crypto/ed25519</code> when used with Go 1.13+.
</p>
524

525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543
<h3 id="error_wrapping">Error wrapping</h3>

<p><!-- CL 163558, 176998 -->
  Go 1.13 contains support for error wrapping, as first proposed in
  the <a href="https://go.googlesource.com/proposal/+/master/design/29934-error-values.md">
  Error Values proposal</a> and discussed on <a href="https://golang.org/issue/29934">the
  associated issue</a>.
</p>
<p>
  An error <code>e</code> can <em>wrap</em> another error <code>w</code> by providing
  an <code>Unwrap</code> method that returns <code>w</code>. Both <code>e</code>
  and <code>w</code> are available to programs, allowing <code>e</code> to provide
  additional context to <code>w</code> or to reinterpret it while still allowing
  programs to make decisions based on <code>w</code>.
</p>
<p>
  To support wrapping, <a href="#fmt"><code>fmt.Errorf</code></a> now has a <code>%w</code>
  verb for creating wrapped errors, and three new functions in
  the <a href="#errors"><code>errors</code></a> package (
544 545 546
  <a href="/pkg/errors/#Unwrap"><code>errors.Unwrap</code></a>,
  <a href="/pkg/errors/#Is"><code>errors.Is</code></a> and
  <a href="/pkg/errors/#As"><code>errors.As</code></a>) simplify unwrapping
547 548 549 550 551 552 553 554 555
  and inspecting wrapped errors.
</p>
<p>
  For more information, read the <a href="/pkg/errors/"><code>errors</code> package
  documentation</a>, or see
  the <a href="https://golang.org/wiki/ErrorValueFAQ">Error Value FAQ</a>.
  There will soon be a blog post as well.
</p>

556 557 558 559 560 561 562 563
<h3 id="minor_library_changes">Minor changes to the library</h3>

<p>
  As always, there are various minor changes and updates to the library,
  made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a>
  in mind.
</p>

564 565
<dl id="bytes"><dt><a href="/pkg/bytes/">bytes</a></dt>
  <dd>
566 567 568 569 570
    <p>
      The new <a href="/pkg/bytes/#ToValidUTF8"><code>ToValidUTF8</code></a> function returns a
      copy of a given byte slice with each run of invalid UTF-8 byte sequences replaced by a given slice.
    </p>

571 572 573 574 575
</dl><!-- bytes -->

<dl id="context"><dt><a href="/pkg/context/">context</a></dt>
  <dd>
    <p><!-- CL 169080 -->
Julie's avatar
Julie committed
576
    The formatting of contexts returned by <a href="/pkg/context/#WithValue"><code>WithValue</code></a> no longer depends on <code>fmt</code> and will not stringify in the same way. Code that depends on the exact previous stringification might be affected.
577 578 579 580
    </p>

</dl><!-- context -->

581
<dl id="crypto/tls"><dt><a href="/pkg/crypto/tls/">crypto/tls</a></dt>
582
  <dd>
583 584
    <p>
      Support for SSL version 3.0 (SSLv3) <a href="https://golang.org/issue/32716">
585 586 587 588 589 590 591 592 593
      is now deprecated and will be removed in Go 1.14</a>. Note that SSLv3 is the
      <a href="https://tools.ietf.org/html/rfc7568">cryptographically broken</a>
      protocol predating TLS.
    </p>

    <p>
      SSLv3 was always disabled by default, other than in Go 1.12, when it was
      mistakenly enabled by default server-side. It is now again disabled by
      default. (SSLv3 was never supported client-side.)
594 595
    </p>

596 597
    <p><!-- CL 177698 -->
      Ed25519 certificates are now supported in TLS versions 1.2 and 1.3.
598 599
    </p>

600
</dl><!-- crypto/tls -->
601

602
<dl id="crypto/x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt>
603
  <dd>
604 605 606 607 608 609
    <p><!-- CL 175478 -->
      Ed25519 keys are now supported in certificates and certificate requests
      according to <a href="https://www.rfc-editor.org/info/rfc8410">RFC 8410</a>, as well as by the
      <a href="/pkg/crypto/x509/#ParsePKCS8PrivateKey"><code>ParsePKCS8PrivateKey</code></a>,
      <a href="/pkg/crypto/x509/#MarshalPKCS8PrivateKey"><code>MarshalPKCS8PrivateKey</code></a>,
      and <a href="/pkg/crypto/x509/#ParsePKIXPublicKey"><code>ParsePKIXPublicKey</code></a> functions.
610 611
    </p>

612 613 614 615 616
    <p><!-- CL 169238 -->
      The paths searched for system roots now include <code>/etc/ssl/cert.pem</code>
      to support the default location in Alpine Linux 3.7+.
    </p>

617
</dl><!-- crypto/x509 -->
618 619 620 621

<dl id="database/sql"><dt><a href="/pkg/database/sql/">database/sql</a></dt>
  <dd>
    <p><!-- CL 170699 -->
622
      The new <a href="/pkg/database/sql/#NullTime"><code>NullTime</code></a> type represents a <code>time.Time</code> that may be null.
623 624 625
    </p>

    <p><!-- CL 174178 -->
626
      The new  <a href="/pkg/database/sql/#NullInt32"><code>NullInt32</code></a> type represents an <code>int32</code> that may be null.
627 628 629 630 631 632 633
    </p>

</dl><!-- database/sql -->

<dl id="debug/dwarf"><dt><a href="/pkg/debug/dwarf/">debug/dwarf</a></dt>
  <dd>
    <p><!-- CL 158797 -->
634 635 636 637 638 639
      The <a href="/pkg/debug/dwarf/#Data.Type"><code>Data.Type</code></a>
      method no longer panics if it encounters an unknown DWARF tag in
      the type graph. Instead, it represents that component of the
      type with
      an <a href="/pkg/debug/dwarf/#UnsupportedType"><code>UnsupportedType</code></a>
      object.
640 641 642 643
    </p>

</dl><!-- debug/dwarf -->

644 645 646 647
<dl id="errors"><dt><a href="/pkg/errors/">errors</a></dt>
  <dd>
    <!-- CL 163558 -->
    <p>
648 649
      The new function <a href="/pkg/errors/#As"><code>As</code></a> finds the first
      error in a given error’s chain (sequence of wrapped errors)
650 651 652 653 654 655 656 657 658 659 660 661 662
      that matches a given target’s type, and if so, sets the target to that error value.
    </p>
    <p>
      The new function <a href="/pkg/errors/#Is"><code>Is</code></a> reports whether a given error value matches an
      error in another’s chain.
    </p>
    <p>
      The new function <a href="/pkg/errors/#Unwrap"><code>Unwrap</code></a> returns the result of calling
      <code>Unwrap</code> on a given error, if one exists.
    </p>

</dl><!-- errors -->

663
<dl id="fmt"><dt><a href="/pkg/fmt/">fmt</a></dt>
664
  <dd>
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682
    <!-- CL 160245 -->
    <p>
      The printing verbs <code>%x</code> and <code>%X</code> now format floating-point and
      complex numbers in hexadecimal notation, in lower-case and upper-case respectively.
    </p>

    <!-- CL 160246 -->
    <p>
      The new printing verb <code>%O</code> formats integers in base 8, emitting the <code>0o</code> prefix.
    </p>

    <!-- CL 160247 -->
    <p>
      The scanner now accepts hexadecimal floating-point values, digit-separating underscores
      and leading <code>0b</code> and <code>0o</code> prefixes.
      See the <a href="#language">Changes to the language</a> for details.
    </p>

683 684 685 686 687
    <!-- CL 176998 -->
    <p>The <a href="/pkg/fmt/#Errorf"><code>Errorf</code></a> function
      has a new verb, <code>%w</code>, whose operand must be an error.
      The error returned from <code>Errorf</code> will have an
      <code>Unwrap</code> method which returns the operand of <code>%w</code>.
688 689
    </p>

690 691
</dl><!-- fmt -->

692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712

<dl id="go/scanner"><dt><a href="/pkg/go/scanner/">go/scanner</a></dt>
  <dd>
    <p><!-- CL 175218 -->
      The scanner has been updated to recognize the new Go number literals, specifically
      binary literals with <code>0b</code>/<code>0B</code> prefix, octal literals with <code>0o</code>/<code>0O</code> prefix,
      and floating-point numbers with hexadecimal mantissa. The imaginary suffix <code>i</code> may now be used with any number
      literal, and underscores may used as digit separators for grouping.
      See the <a href="#language">Changes to the language</a> for details.
  </p>

  </dl><!-- go/scanner -->

<dl id="go/types"><dt><a href="/pkg/go/types/">go/types</a></dt>
  <dd>
    <p>
      The type-checker has been updated to follow the new rules for integer shifts.
      See the <a href="#language">Changes to the language</a> for details.
    </p>

</dl><!-- go/types -->
713

714 715 716 717 718 719 720 721 722 723 724


<dl id="html/template"><dt><a href="/pkg/html/template/">html/template</a></dt>
  <dd>
    <p><!-- CL 175218 -->
      When using a <code>&lt;script&gt;</code> tag with "module" set as the
      type attribute, code will now be interpreted as <a href="https://html.spec.whatwg.org/multipage/scripting.html#the-script-element:module-script-2">JavaScript module script</a>.
    </p>

</dl><!-- html/template -->

725 726 727
<dl id="log"><dt><a href="/pkg/log/">log</a></dt>
  <dd>
    <p><!-- CL 168920 -->
Julie's avatar
Julie committed
728
      The new <a href="/pkg/log/#Writer"><code>Writer</code></a> function returns the output destination for the standard logger.
729 730 731 732 733 734 735
    </p>

</dl><!-- log -->

<dl id="math/big"><dt><a href="/pkg/math/big/">math/big</a></dt>
  <dd>
    <p><!-- CL 160682 -->
736
      The new <a href="/pkg/math/big/#Rat.SetUint64"><code>Rat.SetUint64</code></a> method sets the <code>Rat</code> to a <code>uint64</code> value.
737 738
    </p>

739 740 741 742 743 744 745 746 747 748 749 750
    <p><!-- CL 166157 -->
      For <a href="/pkg/math/big/#Float.Parse"><code>Float.Parse</code></a>, if base is 0, underscores
      may be used between digits for readability.
      See the <a href="#language">Changes to the language</a> for details.
    </p>

    <p><!-- CL 166157 -->
      For <a href="/pkg/math/big/#Int.SetString"><code>Int.SetString</code></a>, if base is 0, underscores
      may be used between digits for readability.
      See the <a href="#language">Changes to the language</a> for details.
    </p>

751
    <p><!-- CL 168237 -->
752
      <a href="/pkg/math/big/#Rat.SetString"><code>Rat.SetString</code></a> now accepts non-decimal floating point representations.
753 754 755 756 757 758 759
    </p>

</dl><!-- math/big -->

<dl id="math/bits"><dt><a href="/pkg/math/bits/">math/bits</a></dt>
  <dd>
    <p><!-- CL 178177 -->
760 761 762 763 764 765
      The execution time of <a href="/pkg/math/bits/#Add"><code>Add</code></a>,
      <a href="/pkg/math/bits/#Sub"><code>Sub</code></a>,
      <a href="/pkg/math/bits/#Mul"><code>Mul</code></a>,
      <a href="/pkg/math/bits/#RotateLeft"><code>RotateLeft</code></a>, and
      <a href="/pkg/math/bits/#ReverseBytes"><code>ReverseBytes</code></a> is now
      guaranteed to be independent of the inputs.
766 767 768 769 770 771 772
    </p>

</dl><!-- math/bits -->

<dl id="net"><dt><a href="/pkg/net/">net</a></dt>
  <dd>
    <p><!-- CL 156366 -->
773
      On Unix systems where <code>use-vc</code> is set in <code>resolv.conf</code>, TCP is used for DNS resolution.
774 775 776
    </p>

    <p><!-- CL 170678 -->
777 778
      The new field <a href="/pkg/net/#ListenConfig.KeepAlive"><code>ListenConfig.KeepAlive</code></a>
      specifies the keep-alive period for network connections accepted by the listener.
779 780 781 782 783 784 785 786 787
      If this field is 0 (the default) TCP keep-alives will be enabled.
      To disable them, set it to a negative value.
    </p>
    <p>
      Note that the error returned from I/O on a connection that was
      closed by a keep-alive timeout will have a
      <code>Timeout</code> method that returns <code>true</code> if called.
      This can make a keep-alive error difficult to distinguish from
      an error returned due to a missed deadline as set by the
788
      <a href="/pkg/net/#Conn"><code>SetDeadline</code></a>
789 790 791 792 793 794 795 796
      method and similar methods.
      Code that uses deadlines and checks for them with
      the <code>Timeout</code> method or
      with <a href="/pkg/os/#IsTimeout"><code>os.IsTimeout</code></a>
      may want to disable keep-alives, or
      use <code>errors.Is(syscall.ETIMEDOUT)</code> (on Unix systems)
      which will return true for a keep-alive timeout and false for a
      deadline timeout.
797 798 799 800 801 802
    </p>

</dl><!-- net -->

<dl id="net/http"><dt><a href="/pkg/net/http/">net/http</a></dt>
  <dd>
803 804 805 806 807 808 809
    <p><!-- CL 76410 -->
      The new fields <a href="/pkg/net/http/#Transport.WriteBufferSize"><code>Transport.WriteBufferSize</code></a>
      and <a href="/pkg/net/http/#Transport.ReadBufferSize"><code>Transport.ReadBufferSize</code></a>
      allow one to specify the sizes of the write and read buffers for a <a href="/pkg/net/http/#Transport"><code>Transport</code></a>.
      If either field is zero, a default size of 4KB is used.
    </p>

810
    <p><!-- CL 130256 -->
811 812 813
      The new field <a href="/pkg/net/http/#Transport.ForceAttemptHTTP2"><code>Transport.ForceAttemptHTTP2</code></a>
      controls whether HTTP/2 is enabled when a non-zero <code>Dial</code>, <code>DialTLS</code>, or <code>DialContext</code>
      func or <code>TLSClientConfig</code> is provided.
814 815 816
    </p>

    <p><!-- CL 140357 -->
817 818
      <a href="/pkg/net/http/#Transport.MaxConnsPerHost"><code>Transport.MaxConnsPerHost</code></a> now works
      properly with HTTP/2.
819 820 821
    </p>

    <p><!-- CL 154383 -->
822 823 824
      <a href="/pkg/net/http/#TimeoutHandler"><code>TimeoutHandler</code></a>'s
      <a href="/pkg/net/http/#ResponseWriter"><code>ResponseWriter</code></a> now implements the
      <a href="/pkg/net/http/#Pusher"><code>Pusher</code></a> and <a href="/pkg/net/http/#Flusher"><code>Flusher</code></a> interfaces.
825 826
    </p>

827 828 829 830
    <p><!-- CL 157339 -->
      The <code>StatusCode</code> <code>103</code> <code>"Early Hints"</code> has been added.
    </p>

831 832 833 834 835
    <p><!-- CL 163599 -->
    <a href="/pkg/net/http/#Transport"><code>Transport</code></a> now uses the <a href="/pkg/net/http/#Request.Body"><code>Request.Body</code></a>'s
    <a href="/pkg/io/#ReaderFrom"><code>io.ReaderFrom</code></a> implementation if available, to optimize writing the body.
    </p>

836 837 838 839 840
    <p><!-- CL 167017 -->
      On encountering unsupported transfer-encodings, <a href="/pkg/net/http/#Server"><code>http.Server</code></a> now
      returns a "501 Unimplemented" status as mandated by the HTTP specification <a href="https://tools.ietf.org/html/rfc7230#section-3.3.1">RFC 7230 Section 3.3.1</a>.
    </p>

841
    <p><!-- CL 167681 -->
842
      The new <a href="/pkg/net/http/#Server"><code>Server</code></a> fields
843 844
      <a href="/pkg/net/http/#Server.BaseContext"><code>BaseContext</code></a> and
      <a href="/pkg/net/http/#Server.ConnContext"><code>ConnContext</code></a>
845
      allow finer control over the <a href="/pkg/context/#Context"><code>Context</code></a> values provided to requests and connections.
846 847
    </p>

848
    <p><!-- CL 167781 -->
849
      <a href="/pkg/net/http/#DetectContentType"><code>http.DetectContentType</code></a> now correctly detects RAR signatures, and can now also detect RAR v5 signatures.
850 851
    </p>

852
    <p><!-- CL 173658 -->
853 854
      The new <a href="/pkg/net/http/#Header"><code>Header</code></a> method
      <a href="/pkg/net/http/#Header.Clone"><code>Clone</code></a> returns a copy of the receiver.
855 856
    </p>

857 858 859 860
    <p><!-- CL 174324 -->
      A new function <a href="/pkg/net/http/#NewRequestWithContext"><code>NewRequestWithContext</code></a> has been added and it
      accepts a <a href="/pkg/context/#Context"><code>Context</code></a> that controls the entire lifetime of
      the created outgoing <a href="/pkg/net/http/#Request"><code>Request</code></a>, suitable for use with
861
      <a href="/pkg/net/http/#Client.Do"><code>Client.Do</code></a> and <a href="/pkg/net/http/#Transport.RoundTrip"><code>Transport.RoundTrip</code></a>.
862 863 864
    </p>

    <p><!-- CL 179457 -->
865 866
      The <a href="/pkg/net/http/#Transport"><code>Transport</code></a> no longer logs errors when servers
      gracefully shut down idle connections using a <code>"408 Request Timeout"</code> response.
867 868
    </p>

869 870 871 872
</dl><!-- net/http -->

<dl id="os"><dt><a href="/pkg/os/">os</a></dt>
  <dd>
873 874 875 876 877
    <p><!-- CL 160877 -->
      The new <a href="/pkg/os/#UserConfigDir"><code>UserConfigDir</code></a> function
      returns the default directory to use for user-specific configuration data.
    </p>

878
    <p><!-- CL 166578 -->
879 880
      If a <a href="/pkg/os/#File"><code>File</code></a> is opened using the O_APPEND flag, its
      <a href="/pkg/os/#File.WriteAt"><code>WriteAt</code></a> method will always return an error.
881 882 883 884 885 886 887
    </p>

</dl><!-- os -->

<dl id="os/exec"><dt><a href="/pkg/os/exec/">os/exec</a></dt>
  <dd>
    <p><!-- CL 174318 -->
888
      On Windows, the environment for a <a href="/pkg/os/exec/#Cmd"><code>Cmd</code></a> always inherits the
889
      <code>%SYSTEMROOT%</code> value of the parent process unless the
890
      <a href="/pkg/os/exec/#Cmd.Env"><code>Cmd.Env</code></a> field includes an explicit value for it.
891 892 893 894 895 896 897
    </p>

</dl><!-- os/exec -->

<dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt>
  <dd>
    <p><!-- CL 171337 -->
898
      The new <a href="/pkg/reflect/#Value.IsZero"><code>Value.IsZero</code></a> method reports whether a <code>Value</code> is the zero value for its type.
899 900 901
    </p>

    <p><!-- CL 174531 -->
902
      The <a href="/pkg/reflect/#MakeFunc"><code>MakeFunc</code></a> function now allows assignment conversions on returned values, instead of requiring exact type match. This is particularly useful when the type being returned is an interface type, but the value actually returned is a concrete value implementing that type.
903 904 905 906 907 908
    </p>

</dl><!-- reflect -->

<dl id="runtime"><dt><a href="/pkg/runtime/">runtime</a></dt>
  <dd>
909
    <p> <!-- CL 167780 -->
910 911
      Tracebacks, <a href="/pkg/runtime/#Caller"><code>runtime.Caller</code></a>,
      and <a href="/pkg/runtime/#Callers"><code>runtime.Callers</code></a> now refer to the function that
912
      initializes the global variables of <code>PKG</code>
913
      as <code>PKG.init</code> instead of <code>PKG.init.ializers</code>.
914 915 916 917
    </p>

</dl><!-- runtime -->

918
<dl id="strconv"><dt><a href="/pkg/strconv/">strconv</a></dt>
919 920
  <dd>
    <p><!-- CL 160243 -->
921 922 923
       For <a href="/pkg/strconv/#ParseFloat"><code>strconv.ParseFloat</code></a>,
       <a href="/pkg/strconv/#ParseInt"><code>strconv.ParseInt</code></a>
       and <a href="/pkg/strconv/#ParseUint"><code>strconv.ParseUint</code></a>,
924 925 926 927 928 929
       if base is 0, underscores may be used between digits for readability.
       See the <a href="#language">Changes to the language</a> for details.
    </p>

</dl><!-- strconv -->

930
<dl id="strings"><dt><a href="/pkg/strings/">strings</a></dt>
931 932
  <dd>
    <p><!-- CL 142003 -->
933 934
      The new <a href="/pkg/strings/#ToValidUTF8"><code>ToValidUTF8</code></a> function returns a
      copy of a given string with each run of invalid UTF-8 byte sequences replaced by a given string.
935 936
    </p>

937
</dl><!-- strings -->
938 939 940

<dl id="sync"><dt><a href="/pkg/sync/">sync</a></dt>
  <dd>
941 942 943 944 945 946 947 948
    <p><!-- CL 148958, CL 148959, CL 152697, CL 152698 -->
      The fast paths of <a href="/pkg/sync/#Mutex.Lock"><code>Mutex.Lock</code></a>, <a href="/pkg/sync/#Mutex.Unlock"><code>Mutex.Unlock</code></a>,
      <a href="/pkg/sync/#RWMutex.Lock"><code>RWMutex.Lock</code></a>, <a href="/pkg/sync/#Mutex.RUnlock"><code>RWMutex.RUnlock</code></a>, and
      <a href="/pkg/sync/#Once.Do"><code>Once.Do</code></a> are now inlined in their callers.
      For the uncontended cases on amd64, these changes make <a href="/pkg/sync/#Once.Do"><code>Once.Do</code></a> twice as fast, and the
      <a href="/pkg/sync/#Mutex"><code>Mutex</code></a>/<a href="/pkg/sync/#RWMutex"><code>RWMutex</code></a> methods up to 10% faster.
    </p>

949
    <p><!-- CL 166960 -->
950
      Large <a href="/pkg/sync/#Pool"><code>Pool</code></a> no longer increase stop-the-world pause times.
951 952 953
    </p>

    <p><!-- CL 166961 -->
954 955
      <code>Pool</code> no longer needs to be completely repopulated after every GC. It now retains some objects across GCs,
      as opposed to releasing all objects, reducing load spikes for heavy users of <code>Pool</code>.
956 957 958 959 960 961 962
    </p>

</dl><!-- sync -->

<dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt>
  <dd>
    <p><!-- CL 168479 -->
963 964 965
      Uses of <code>_getdirentries64</code> have been removed from
      Darwin builds, to allow Go binaries to be uploaded to the macOS
      App Store.
966 967 968
    </p>

    <p><!-- CL 174197 -->
969 970 971
      The new <code>ProcessAttributes</code> and <code>ThreadAttributes</code> fields in
      <a href="/pkg/syscall/?GOOS=windows#SysProcAttr"><code>SysProcAttr</code></a> have been introduced for Windows,
      exposing security settings when creating new processes.
972 973 974
    </p>

    <p><!-- CL 174320 -->
975 976
      <code>EINVAL</code> is no longer returned in zero
      <a href="/pkg/syscall/?GOOS=windows#Chmod"><code>Chmod</code></a> mode on Windows.
977 978
    </p>

979 980 981 982 983 984 985
    <p><!-- CL 191337 -->
      Values of type <code>Errno</code> can be tested against error values in
      the <code>os</code> package,
      like <a href="/pkg/os/#ErrExist"><code>ErrExist</code></a>, using
      <a href="/pkg/errors/#Is"><code>errors.Is</code></a>.
    </p>

986 987 988 989 990
</dl><!-- syscall -->

<dl id="syscall/js"><dt><a href="/pkg/syscall/js/">syscall/js</a></dt>
  <dd>
    <p><!-- CL 177537 -->
991
      <code>TypedArrayOf</code> has been replaced by
992
      <a href="/pkg/syscall/js/#CopyBytesToGo"><code>CopyBytesToGo</code></a> and
993 994
      <a href="/pkg/syscall/js/#CopyBytesToJS"><code>CopyBytesToJS</code></a> for copying bytes
      between a byte slice and a <code>Uint8Array</code>.
995 996 997 998 999 1000 1001
    </p>

</dl><!-- syscall/js -->

<dl id="testing"><dt><a href="/pkg/testing/">testing</a></dt>
  <dd>
    <p><!-- CL 112155 -->
1002
      When running benchmarks, <a href="/pkg/testing/#B.N"><code>B.N</code></a> is no longer rounded.
1003 1004 1005
    </p>

    <p><!-- CL 166717 -->
1006 1007
      The new method <a href="/pkg/testing/#B.ReportMetric"><code>B.ReportMetric</code></a> lets users report
      custom benchmark metrics and override built-in metrics.
1008 1009 1010
    </p>

    <p><!-- CL 173722 -->
1011 1012 1013 1014
      Testing flags are now registered in the new <a href="/pkg/testing/#Init"><code>Init</code></a> function,
      which is invoked by the generated <code>main</code> function for the test.
      As a result, testing flags are now only registered when running a test binary,
      and packages that call <code>flag.Parse</code> during package initialization may cause tests to fail.
1015 1016 1017 1018 1019 1020
    </p>

</dl><!-- testing -->

<dl id="text/scanner"><dt><a href="/pkg/text/scanner/">text/scanner</a></dt>
  <dd>
1021 1022 1023 1024 1025 1026 1027
    <p><!-- CL 183077 -->
      The scanner has been updated to recognize the new Go number literals, specifically
      binary literals with <code>0b</code>/<code>0B</code> prefix, octal literals with <code>0o</code>/<code>0O</code> prefix,
      and floating-point numbers with hexadecimal mantissa.
      Also, the new <a href="/pkg/text/scanner/#AllowDigitSeparators"><code>AllowDigitSeparators</code></a>
      mode allows number literals to contain underscores as digit separators (off by default for backwards-compatibility).
      See the <a href="#language">Changes to the language</a> for details.
1028 1029 1030 1031 1032 1033 1034
    </p>

</dl><!-- text/scanner -->

<dl id="text/template"><dt><a href="/pkg/text/template/">text/template</a></dt>
  <dd>
    <p><!-- CL 161762 -->
1035 1036
      The new <a href="/pkg/text/template/#hdr-Functions">slice function</a>
      returns the result of slicing its first argument by the following arguments.
1037 1038 1039 1040 1041 1042 1043
    </p>

</dl><!-- text/template -->

<dl id="time"><dt><a href="/pkg/time/">time</a></dt>
  <dd>
    <p><!-- CL 122876 -->
1044
      Day-of-year is now supported by <a href="/pkg/time/#Time.Format"><code>Format</code></a>
1045
      and <a href="/pkg/time/#Parse"><code>Parse</code></a>.
1046 1047 1048
    </p>

    <p><!-- CL 167387 -->
1049 1050 1051 1052
      The new <a href="/pkg/time/#Duration"><code>Duration</code></a> methods
      <a href="/pkg/time/#Duration.Microseconds"><code>Microseconds</code></a> and
      <a href="/pkg/time/#Duration.Milliseconds"><code>Milliseconds</code></a> return
      the duration as an integer count of their respectively named units.
1053 1054 1055 1056
    </p>

</dl><!-- time -->

1057 1058 1059 1060 1061 1062 1063 1064 1065 1066
<dl id="unicode"><dt><a href="/pkg/unicode/">unicode</a></dt>
  <dd>
    <p>
      The <a href="/pkg/unicode/"><code>unicode</code></a> package and associated
      support throughout the system has been upgraded from Unicode 10.0 to
      <a href="http://www.unicode.org/versions/Unicode11.0.0/">Unicode 11.0</a>,
      which adds 684 new characters, including seven new scripts, and 66 new emoji.
    </p>

</dl><!-- unicode -->