blob: 8f4035d87f8460c62f91bd347c4d544fbaf42f3b [file] [log] [blame]
Russ Cox23167842019-04-30 13:46:02 -04001<!--{
2 "Title": "Go 1.13 Release Notes",
3 "Path": "/doc/go1.13",
4 "Template": true
5}-->
6
7<!--
8NOTE: In this document and others in this directory, the convention is to
9set fixed-width phrases with non-fixed-width spaces, as in
10<code>hello</code> <code>world</code>.
11Do not send CLs removing the interior tags from such phrases.
12-->
13
14<style>
obeicded9f42019-08-21 23:25:20 +053015 main ul li { margin: 0.5em 0; }
Russ Cox23167842019-04-30 13:46:02 -040016</style>
17
Andrew Bonventredec16792019-08-28 16:07:39 -040018<h2 id="introduction">Introduction to Go 1.13</h2>
Russ Cox23167842019-04-30 13:46:02 -040019
20<p>
Andrew Bonventredec16792019-08-28 16:07:39 -040021 The latest Go release, version 1.13, arrives six months after <a href="go1.12">Go 1.12</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.
Russ Cox23167842019-04-30 13:46:02 -040025</p>
26
27<p>
Katie Hockmanf83c44e2019-06-12 17:50:55 -040028 As of Go 1.13, the go command by default downloads and authenticates
29 modules using the Go module mirror and Go checksum database run by Google. See
Katie Hockmand36452e2019-06-11 15:12:54 -040030 <a href="https://proxy.golang.org/privacy">https://proxy.golang.org/privacy</a>
31 for privacy information about these services and the
32 <a href="/cmd/go/#hdr-Module_downloading_and_verification">go command documentation</a>
Katie Hockmanf83c44e2019-06-12 17:50:55 -040033 for configuration details including how to disable the use of these servers or use
Katie Hockman989409f2019-08-26 12:57:09 -040034 different ones. If you depend on non-public modules, see the
35 <a href="/cmd/go/#hdr-Module_configuration_for_non_public_modules">documentation for configuring your environment</a>.
Katie Hockmand36452e2019-06-11 15:12:54 -040036</p>
37
Russ Cox23167842019-04-30 13:46:02 -040038<h2 id="language">Changes to the language</h2>
39
40<p>
Robert Griesemer7119f4b2019-06-18 17:40:09 -070041 Per the <a href="https://github.com/golang/proposal/blob/master/design/19308-number-literals.md">number literal proposal</a>,
42 Go 1.13 supports a more uniform and modernized set of number literal prefixes.
43 <ul>
44 <li>
Diogo Pinela67f181b2019-06-27 22:19:15 +010045 <a href="/ref/spec#Integer_literals">Binary integer literals</a>:
Robert Griesemer7119f4b2019-06-18 17:40:09 -070046 The prefix <code>0b</code> or <code>0B</code> indicates a binary integer literal
47 such as <code>0b1011</code>.
48 </li>
49
50 <li>
Diogo Pinela67f181b2019-06-27 22:19:15 +010051 <a href="/ref/spec#Integer_literals">Octal integer literals</a>:
Robert Griesemer7119f4b2019-06-18 17:40:09 -070052 The prefix <code>0o</code> or <code>0O</code> indicates an octal integer literal
53 such as <code>0o660</code>.
54 The existing octal notation indicated by a leading <code>0</code> followed by
55 octal digits remains valid.
56 </li>
57
58 <li>
Diogo Pinela67f181b2019-06-27 22:19:15 +010059 <a href="/ref/spec#Floating-point_literals">Hexadecimal floating point literals</a>:
Robert Griesemer7119f4b2019-06-18 17:40:09 -070060 The prefix <code>0x</code> or <code>0X</code> may now be used to express the mantissa of a
61 floating-point number in hexadecimal format such as <code>0x1.0p-1021</code>.
62 A hexadecimal floating-point number must always have an exponent, written as the letter
63 <code>p</code> or <code>P</code> followed by an exponent in decimal. The exponent scales
64 the mantissa by 2 to the power of the exponent.
65 </li>
66
67 <li>
Diogo Pinela67f181b2019-06-27 22:19:15 +010068 <a href="/ref/spec#Imaginary_literals">Imaginary literals</a>:
Robert Griesemer7119f4b2019-06-18 17:40:09 -070069 The imaginary suffix <code>i</code> may now be used with any (binary, decimal, hexadecimal)
70 integer or floating-point literal.
71 </li>
72
73 <li>
74 Digit separators:
75 The digits of any number literal may now be separated (grouped) using underscores, such as
76 in <code>1_000_000</code>, <code>0b_1010_0110</code>, or <code>3.1415_9265</code>.
77 An underscore may appear between any two digits or the literal prefix and the first digit.
78 </li>
79 </ul>
Russ Cox23167842019-04-30 13:46:02 -040080</p>
81
Robert Griesemer7119f4b2019-06-18 17:40:09 -070082<p>
83 Per the <a href="https://github.com/golang/proposal/blob/master/design/19113-signed-shift-counts.md">signed shift counts proposal</a>
Diogo Pinela67f181b2019-06-27 22:19:15 +010084 Go 1.13 removes the restriction that a <a href="/ref/spec#Operators">shift count</a>
Robert Griesemer7119f4b2019-06-18 17:40:09 -070085 must be unsigned. This change eliminates the need for many artificial <code>uint</code> conversions,
86 solely introduced to satisfy this (now removed) restriction of the <code>&lt;&lt;</code> and <code>&gt;&gt;</code> operators.
Austin Clementsbd7d1bb2019-06-14 15:02:35 -040087</p>
88
Robert Griesemer7119f4b2019-06-18 17:40:09 -070089<p>
90 These language changes were implemented by changes to the compiler, and corresponding internal changes to the library
Robert Griesemerb5a8dcb2019-06-20 16:50:48 -070091 packages <code><a href="#go/scanner">go/scanner</a></code> and
92 <code><a href="#text/scanner">text/scanner</a></code> (number literals),
93 and <code><a href="#go/types">go/types</a></code> (signed shift counts).
Robert Griesemer7119f4b2019-06-18 17:40:09 -070094</p>
95
96<p>
97 If your code uses modules and your <code>go.mod</code> files specifies a language version, be sure
98 it is set to at least <code>1.13</code> to get access to these language changes.
99 You can do this by editing the <code>go.mod</code> file directly, or you can run
100 <code>go mod edit -go=1.13</code>.
101</p>
102
Russ Cox23167842019-04-30 13:46:02 -0400103<h2 id="ports">Ports</h2>
104
Andrewb7e9c7a2019-09-18 21:34:24 -0400105<p id="nacl">
Norman B. Lancaster79426712019-07-10 10:33:12 -0500106 Go 1.13 is the last release that will run on Native Client (NaCl).
107</p>
108
Agniva De Sarkera2f5d642019-08-02 21:58:29 +0530109<p><!-- CL 170119, CL 168882 -->
110 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.
111 The valid values are documented <a href="/cmd/go/#hdr-Environment_variables">here</a>.
112</p>
113
Ian Lance Taylor122a4fb2019-06-24 10:02:41 -0700114<h3 id="aix">AIX</h3>
115
116<p><!-- CL 164003, CL 169120 -->
117 AIX on PPC64 (<code>aix/ppc64</code>) now supports cgo, external
118 linking, and the <code>c-archive</code> and <code>pie</code> build
119 modes.
120</p>
121
Austin Clementsbd7d1bb2019-06-14 15:02:35 -0400122<h3 id="android">Android</h3>
123
124<p><!-- CL 170127 -->
Andrew Bonventredec16792019-08-28 16:07:39 -0400125 Go programs are now compatible with Android 10.
Austin Clementsbd7d1bb2019-06-14 15:02:35 -0400126</p>
127
Russ Cox23167842019-04-30 13:46:02 -0400128<h3 id="darwin">Darwin</h3>
129
130<p>
131 As <a href="go1.12#darwin">announced</a> in the Go 1.12 release notes,
132 Go 1.13 now requires macOS 10.11 El Capitan or later;
133 support for previous versions has been discontinued.
134</p>
135
136<h3 id="freebsd">FreeBSD</h3>
137
138<p>
139 As <a href="go1.12#freebsd">announced</a> in the Go 1.12 release notes,
140 Go 1.13 now requires FreeBSD 11.2 or later;
141 support for previous versions has been discontinued.
Andrew Bonventredec16792019-08-28 16:07:39 -0400142 FreeBSD 12.0 or later requires a kernel with the <code>COMPAT_FREEBSD11</code>
143 option set (this is the default).
Russ Cox23167842019-04-30 13:46:02 -0400144</p>
145
Austin Clements0ab1cc32019-06-18 17:42:44 -0400146<h3 id="illumos">Illumos</h3>
Austin Clementsbd7d1bb2019-06-14 15:02:35 -0400147
Austin Clements0ab1cc32019-06-18 17:42:44 -0400148<p><!-- CL 174457 -->
149 Go now supports Illumos with <code>GOOS=illumos</code>.
150 The <code>illumos</code> build tag implies the <code>solaris</code>
151 build tag.
152</p>
153
Austin Clements0ab1cc32019-06-18 17:42:44 -0400154<h3 id="windows">Windows</h3>
155
156<p><!-- CL 178977 -->
157 The Windows version specified by internally-linked Windows binaries
158 is now Windows 7 rather than NT 4.0. This was already the minimum
159 required version for Go, but can affect the behavior of system calls
160 that have a backwards-compatibility mode. These will now behave as
161 documented. Externally-linked binaries (any program using cgo) have
162 always specified a more recent Windows version.
Austin Clementsbd7d1bb2019-06-14 15:02:35 -0400163</p>
164
Russ Cox23167842019-04-30 13:46:02 -0400165<h2 id="tools">Tools</h2>
166
Bryan C. Mills1803ab12019-06-11 15:49:44 -0400167<h3 id="modules">Modules</h3>
168
Bryan C. Mills53a42d32019-06-24 17:49:36 -0400169<h4 id="proxy-vars">Environment variables</h4>
170
Bryan C. Millsb21c8372019-06-26 13:16:50 -0400171<p><!-- CL 176580 -->
172 The <a href="/cmd/go/#hdr-Module_support"><code>GO111MODULE</code></a>
173 environment variable continues to default to <code>auto</code>, but
174 the <code>auto</code> setting now activates the module-aware mode of
175 the <code>go</code> command whenever the current working directory contains,
176 or is below a directory containing, a <code>go.mod</code> file — even if the
177 current directory is within <code>GOPATH/src</code>. This change simplifies
178 the migration of existing code within <code>GOPATH/src</code> and the ongoing
179 maintenance of module-aware packages alongside non-module-aware importers.
180</p>
181
Bryan C. Mills53a42d32019-06-24 17:49:36 -0400182<p><!-- CL 181719 -->
183 The new
184 <a href="/cmd/go/#hdr-Module_configuration_for_non_public_modules"><code>GOPRIVATE</code></a>
185 environment variable indicates module paths that are not publicly available.
Bryan C. Millsab94ebb2019-06-26 15:57:25 -0400186 It serves as the default value for the lower-level <code>GONOPROXY</code>
187 and <code>GONOSUMDB</code> variables, which provide finer-grained control over
188 which modules are fetched via proxy and verified using the checksum database.
Bryan C. Mills53a42d32019-06-24 17:49:36 -0400189</p>
190
191<p><!-- CL 173441, CL 177958 -->
192 The <a href="/cmd/go/#hdr-Module_downloading_and_verification"><code>GOPROXY</code>
193 environment variable</a> may now be set to a comma-separated list of proxy
194 URLs or the special token <code>direct</code>, and
195 its <a href="#introduction">default value</a> is
196 now <code>https://proxy.golang.org,direct</code>. When resolving a package
Bryan C. Millsab94ebb2019-06-26 15:57:25 -0400197 path to its containing module, the <code>go</code> command will try all
198 candidate module paths on each proxy in the list in succession. An unreachable
199 proxy or HTTP status code other than 404 or 410 terminates the search without
200 consulting the remaining proxies.
Bryan C. Mills53a42d32019-06-24 17:49:36 -0400201</p>
202
203<p>
204 The new
205 <a href="/cmd/go/#hdr-Module_authentication_failures"><code>GOSUMDB</code></a>
206 environment variable identifies the name, and optionally the public key and
207 server URL, of the database to consult for checksums of modules that are not
208 yet listed in the main module's <code>go.sum</code> file.
209 If <code>GOSUMDB</code> does not include an explicit URL, the URL is chosen by
210 probing the <code>GOPROXY</code> URLs for an endpoint indicating support for
211 the checksum database, falling back to a direct connection to the named
212 database if it is not supported by any proxy. If <code>GOSUMDB</code> is set
213 to <code>off</code>, the checksum database is not consulted and only the
214 existing checksums in the <code>go.sum</code> file are verified.
215</p>
216
217<p>
218 Users who cannot reach the default proxy and checksum database (for example,
219 due to a firewalled or sandboxed configuration) may disable their use by
220 setting <code>GOPROXY</code> to <code>direct</code>, and/or
221 <code>GOSUMDB</code> to <code>off</code>.
222 <a href="#go-env-w"><code>go</code> <code>env</code> <code>-w</code></a>
223 can be used to set the default values for these variables independent of
224 platform:
225</p>
226<pre>
227go env -w GOPROXY=direct
228go env -w GOSUMDB=off
229</pre>
230
Mohit Agarwale94472a2019-07-04 21:21:02 +0530231<h4 id="go-get"><code>go</code> <code>get</code></h4>
Bryan C. Millsa6ad6262019-06-24 17:47:52 -0400232
233<p><!-- CL 174099 -->
Bryan C. Millsab94ebb2019-06-26 15:57:25 -0400234 In module-aware mode,
235 <a href="/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them"><code>go</code> <code>get</code></a>
236 with the <code>-u</code> flag now updates a smaller set of modules that is
237 more consistent with the set of packages updated by
Bryan C. Millsa6ad6262019-06-24 17:47:52 -0400238 <code>go</code> <code>get</code> <code>-u</code> in GOPATH mode.
239 <code>go</code> <code>get</code> <code>-u</code> continues to update the
240 modules and packages named on the command line, but additionally updates only
241 the modules containing the packages <em>imported by</em> the named packages,
242 rather than the transitive module requirements of the modules containing the
243 named packages.
244</p>
245
246<p>
247 Note in particular that <code>go</code> <code>get</code> <code>-u</code>
248 (without additional arguments) now updates only the transitive imports of the
249 package in the current directory. To instead update all of the packages
250 transitively imported by the main module (including test dependencies), use
251 <code>go</code> <code>get</code> <code>-u</code> <code>all</code>.
252</p>
253
254<p><!-- CL 177879 -->
255 As a result of the above changes to
256 <code>go</code> <code>get</code> <code>-u</code>, the
257 <code>go</code> <code>get</code> subcommand no longer supports
258 the <code>-m</code> flag, which caused <code>go</code> <code>get</code> to
259 stop before loading packages. The <code>-d</code> flag remains supported, and
260 continues to cause <code>go</code> <code>get</code> to stop after downloading
261 the source code needed to build dependencies of the named packages.
262</p>
263
Bryan C. Mills06f709a2019-06-26 10:07:13 -0400264<p><!-- CL 177677 -->
265 By default, <code>go</code> <code>get</code> <code>-u</code> in module mode
266 upgrades only non-test dependencies, as in GOPATH mode. It now also accepts
267 the <code>-t</code> flag, which (as in GOPATH mode)
268 causes <code>go</code> <code>get</code> to include the packages imported
Bryan C. Millsab94ebb2019-06-26 15:57:25 -0400269 by <em>tests of</em> the packages named on the command line.
Bryan C. Mills06f709a2019-06-26 10:07:13 -0400270</p>
271
Bryan C. Millsa6ad6262019-06-24 17:47:52 -0400272<p><!-- CL 167747 -->
273 In module-aware mode, the <code>go</code> <code>get</code> subcommand now
274 supports the version suffix <code>@patch</code>. The <code>@patch</code>
275 suffix indicates that the named module, or module containing the named
276 package, should be updated to the highest patch release with the same
277 major and minor versions as the version found in the build list.
Bryan C. Millsa6ad6262019-06-24 17:47:52 -0400278</p>
279
Jay Conrodf518a962019-07-17 18:55:18 -0400280<p><!-- CL 184440 -->
281 If a module passed as an argument to <code>go</code> <code>get</code>
282 without a version suffix is already required at a newer version than the
283 latest released version, it will remain at the newer version. This is
284 consistent with the behavior of the <code>-u</code> flag for module
285 dependencies. This prevents unexpected downgrades from pre-release versions.
286 The new version suffix <code>@upgrade</code> explicitly requests this
287 behavior. <code>@latest</code> explicitly requests the latest version
288 regardless of the current version.
289</p>
290
Bryan C. Mills1803ab12019-06-11 15:49:44 -0400291<h4 id="version-validation">Version validation</h4><!-- CL 181881 -->
292
293<p>
294 When extracting a module from a version control system, the <code>go</code>
295 command now performs additional validation on the requested version string.
296</p>
297
298<p>
299 The <code>+incompatible</code> version annotation bypasses the requirement
300 of <a href="/cmd/go/#hdr-Module_compatibility_and_semantic_versioning">semantic
301 import versioning</a> for repositories that predate the introduction of
302 modules. The <code>go</code> command now verifies that such a version does not
303 include an explicit <code>go.mod</code> file.
304</p>
305
306<p>
307 The <code>go</code> command now verifies the mapping
Toshihiro Shiino89fb80f2019-08-23 11:56:32 +0000308 between <a href="/cmd/go/#hdr-Pseudo_versions">pseudo-versions</a> and
Bryan C. Mills1803ab12019-06-11 15:49:44 -0400309 version-control metadata. Specifically:
310 <ul>
Bryan C. Mills6bf27672019-07-02 17:03:27 -0400311 <li>The version prefix must be of the form <code>vX.0.0</code>, or derived
312 from a tag on an ancestor of the named revision, or derived from a tag that
313 includes <a href="https://semver.org/#spec-item-10">build metadata</a> on
314 the named revision itself.</li>
Bryan C. Mills1803ab12019-06-11 15:49:44 -0400315
316 <li>The date string must match the UTC timestamp of the revision.</li>
317
318 <li>The short name of the revision must use the same number of characters as
319 what the <code>go</code> command would generate. (For SHA-1 hashes as used
320 by <code>git</code>, a 12-digit prefix.)</li>
321 </ul>
322</p>
323
324<p>
Bryan C. Millsa6ad6262019-06-24 17:47:52 -0400325 If a <code>require</code> directive in the
326 <a href="/cmd/go/#hdr-The_main_module_and_the_build_list">main module</a> uses
327 an invalid pseudo-version, it can usually be corrected by redacting the
328 version to just the commit hash and re-running a <code>go</code> command, such
Dmitri Shuralyovfa0537b2019-06-25 14:57:50 -0400329 as <code>go</code> <code>list</code> <code>-m</code> <code>all</code>
Bryan C. Millsa6ad6262019-06-24 17:47:52 -0400330 or <code>go</code> <code>mod</code> <code>tidy</code>. For example,
Bryan C. Mills1803ab12019-06-11 15:49:44 -0400331</p>
Bryan C. Millsa6ad6262019-06-24 17:47:52 -0400332<pre>require github.com/docker/docker v1.14.0-0.20190319215453-e7b5f7dbe98c</pre>
333<p>can be redacted to</p>
334<pre>require github.com/docker/docker e7b5f7dbe98c</pre>
335<p>which currently resolves to</p>
336<pre>require github.com/docker/docker v0.7.3-0.20190319215453-e7b5f7dbe98c</pre>
Bryan C. Mills1803ab12019-06-11 15:49:44 -0400337
338<p>
Bryan C. Millsa6ad6262019-06-24 17:47:52 -0400339 If one of the transitive dependencies of the main module requires an invalid
340 version or pseudo-version, the invalid version can be replaced with a valid
341 one using a
342 <a href="/cmd/go/#hdr-The_go_mod_file"><code>replace</code> directive</a> in
343 the <code>go.mod</code> file of the main module. If the replacement is a
344 commit hash, it will be resolved to the appropriate pseudo-version as above.
345 For example,
Bryan C. Mills1803ab12019-06-11 15:49:44 -0400346</p>
Bryan C. Millsa6ad6262019-06-24 17:47:52 -0400347<pre>replace github.com/docker/docker v1.14.0-0.20190319215453-e7b5f7dbe98c => github.com/docker/docker e7b5f7dbe98c</pre>
348<p>currently resolves to</p>
349<pre>replace github.com/docker/docker v1.14.0-0.20190319215453-e7b5f7dbe98c => github.com/docker/docker v0.7.3-0.20190319215453-e7b5f7dbe98c</pre>
Bryan C. Mills1803ab12019-06-11 15:49:44 -0400350
Filippo Valsorda5f7e9ce2019-06-24 13:49:06 -0400351<h3 id="go-command">Go command</h3>
352
Bryan C. Mills816ce1a2019-06-24 18:03:57 -0400353<p id="go-env-w"><!-- CL 171137 -->
354 The <a href="/cmd/go/#hdr-Environment_variables"><code>go</code> <code>env</code></a>
355 command now accepts a <code>-w</code> flag to set the per-user default value
Tobias Klausere2fdce92019-07-02 17:07:54 +0200356 of an environment variable recognized by the
Bryan C. Mills816ce1a2019-06-24 18:03:57 -0400357 <code>go</code> command, and a corresponding <code>-u</code> flag to unset a
358 previously-set default. Defaults set via
359 <code>go</code> <code>env</code> <code>-w</code> are stored in the
360 <code>go/env</code> file within
361 <a href="/pkg/os/#UserConfigDir"><code>os.UserConfigDir()</code></a>.
362</p>
363
Jay Conrodfc26cba2019-06-26 15:21:38 -0400364<p id="go-version-exe"><!-- CL 173343 -->
365 The <a href="/cmd/go/#hdr-Print_Go_version">
366 <code>go</code> <code>version</code></a> command now accepts arguments naming
367 executables and directories. When invoked on an executable,
368 <code>go</code> <code>version</code> prints the version of Go used to build
369 the executable. If the <code>-m</code> flag is used,
370 <code>go</code> <code>version</code> prints the executable's embedded module
371 version information, if available. When invoked on a directory,
372 <code>go</code> <code>version</code> prints information about executables
373 contained in the directory and its subdirectories.
374</p>
375
Filippo Valsorda5f7e9ce2019-06-24 13:49:06 -0400376<p id="trimpath"><!-- CL 173345 -->
377 The new <a href="/cmd/go/#hdr-Compile_packages_and_dependencies"><code>go</code>
378 <code>build</code> flag</a> <code>-trimpath</code> removes all file system paths
379 from the compiled executable, to improve build reproducibility.
380</p>
381
Bryan C. Mills72385232019-08-20 16:02:24 -0400382<p id="o-dir"><!-- CL 167679 -->
383 If the <code>-o</code> flag passed to <code>go</code> <code>build</code>
384 refers to an existing directory, <code>go</code> <code>build</code> will now
385 write executable files within that directory for <code>main</code> packages
386 matching its package arguments.
387</p>
388
Filippo Valsorda5f7e9ce2019-06-24 13:49:06 -0400389<p id="comma-separated-tags"><!-- CL 173438 -->
390 The <code>go</code> <code>build</code> flag <code>-tags</code> now takes a
391 comma-separated list of build tags, to allow for multiple tags in
392 <a href="/cmd/go/#hdr-Environment_variables"><code>GOFLAGS</code></a>. The
393 space-separated form is deprecated but still recognized and will be maintained.
394</p>
395
396<p id="go-generate-tag"><!-- CL 175983 -->
397 <a href="/cmd/go/#hdr-Generate_Go_files_by_processing_source"><code>go</code>
398 <code>generate</code></a> now sets the <code>generate</code> build tag so that
399 files may be searched for directives but ignored during build.
400</p>
401
Jay Conrod8382ccb2019-06-24 19:04:15 -0400402<p id="binary-only"><!-- CL 165746 -->
403 As <a href="/doc/go1.12#binary-only">announced</a> in the Go 1.12 release
404 notes, binary-only packages are no longer supported. Building a binary-only
405 package (marked with a <code>//go:binary-only-package</code> comment) now
406 results in an error.
407</p>
408
Austin Clementsbd7d1bb2019-06-14 15:02:35 -0400409<h3 id="compiler">Compiler toolchain</h3>
Russ Cox23167842019-04-30 13:46:02 -0400410
Austin Clementsbd7d1bb2019-06-14 15:02:35 -0400411<p><!-- CL 170448 -->
412 The compiler has a new implementation of escape analysis that is
413 more precise. For most Go code should be an improvement (in other
414 words, more Go variables and expressions allocated on the stack
415 instead of heap). However, this increased precision may also break
416 invalid code that happened to work before (for example, code that
417 violates
418 the <a href="/pkg/unsafe/#Pointer"><code>unsafe.Pointer</code>
419 safety rules</a>). If you notice any regressions that appear
420 related, the old escape analysis pass can be re-enabled
421 with <code>go</code> <code>build</code> <code>-gcflags=all=-newescape=false</code>.
422 The option to use the old escape analysis will be removed in a
423 future release.
Russ Cox23167842019-04-30 13:46:02 -0400424</p>
425
Austin Clementsbd7d1bb2019-06-14 15:02:35 -0400426<p><!-- CL 161904 -->
427 The compiler no longer emits floating point or complex constants
428 to <code>go_asm.h</code> files. These have always been emitted in a
429 form that could not be used as numeric constant in assembly code.
430</p>
431
Austin Clements0ab1cc32019-06-18 17:42:44 -0400432<h3 id="assembler">Assembler</h3>
433
434<p><!-- CL 157001 -->
435 The assembler now supports many of the atomic instructions
436 introduced in ARM v8.1.
437</p>
438
Robert Griesemerb5a8dcb2019-06-20 16:50:48 -0700439<h3 id="gofmt">gofmt</h3>
440
441<p>
442 <code>gofmt</code> (and with that <code>go fmt</code>) now canonicalizes
443 number literal prefixes and exponents to use lower-case letters, but
444 leaves hexadecimal digits alone. This improves readability when using the new octal prefix
445 (<code>0O</code> becomes <code>0o</code>), and the rewrite is applied consistently.
446 <code>gofmt</code> now also removes unnecessary leading zeroes from a decimal integer
447 imaginary literal. (For backwards-compatibility, an integer imaginary literal
448 starting with <code>0</code> is considered a decimal, not an octal number.
449 Removing superfluous leading zeroes avoids potential confusion.)
450 For instance, <code>0B1010</code>, <code>0XabcDEF</code>, <code>0O660</code>,
451 <code>1.2E3</code>, and <code>01i</code> become <code>0b1010</code>, <code>0xabcDEF</code>,
452 <code>0o660</code>, <code>1.2e3</code>, and <code>1i</code> after applying <code>gofmt</code>.
453</p>
454
Dmitri Shuralyovc11f6c42019-06-17 16:28:18 -0400455<h3 id="godoc"><code>godoc</code> and <code>go</code> <code>doc</code></h3>
456
457<p><!-- CL 174322 -->
458 The <code>godoc</code> webserver is no longer included in the main binary distribution.
459 To run the <code>godoc</code> webserver locally, manually install it first:
460<pre>
461go get golang.org/x/tools/cmd/godoc
462godoc
463</pre>
464</p>
465
466<p><!-- CL 177797 -->
467 The
468 <a href="/cmd/go/#hdr-Show_documentation_for_package_or_symbol"><code>go</code> <code>doc</code></a>
469 command now always includes the package clause in its output, except for
470 commands. This replaces the previous behavior where a heuristic was used,
471 causing the package clause to be omitted under certain conditions.
472</p>
473
Austin Clementsbd7d1bb2019-06-14 15:02:35 -0400474<h2 id="runtime">Runtime</h2>
475
476<p><!-- CL 161477 -->
477 Out of range panic messages now include the index that was out of
478 bounds and the length (or capacity) of the slice. For
479 example, <code>s[3]</code> on a slice of length 1 will panic with
480 "runtime error: index out of range [3] with length 1".
481</p>
482
483<p><!-- CL 171758 -->
484 This release improves performance of most uses of <code>defer</code>
485 by 30%.
486</p>
487
488<p><!-- CL 142960 -->
489 The runtime is now more aggressive at returning memory to the
490 operating system to make it available to co-tenant applications.
491 Previously, the runtime could retain memory for five or more minutes
492 following a spike in the heap size. It will now begin returning it
493 promptly after the heap shrinks. However, on many OSes, including
494 Linux, the OS itself reclaims memory lazily, so process RSS will not
495 decrease until the system is under memory pressure.
496</p>
Russ Cox23167842019-04-30 13:46:02 -0400497
498<h2 id="library">Core library</h2>
499
Russ Cox23167842019-04-30 13:46:02 -0400500<h3 id="tls_1_3">TLS 1.3</h3>
501
502<p>
Filippo Valsordac82e7e72019-06-17 18:28:27 -0400503 As announced in Go 1.12, Go 1.13 enables support for TLS 1.3 in the
504 <code>crypto/tls</code> package by default. It can be disabled by adding the
505 value <code>tls13=0</code> to the <code>GODEBUG</code>
506 environment variable. The opt-out will be removed in Go 1.14.
Russ Cox23167842019-04-30 13:46:02 -0400507</p>
508
Filippo Valsordac82e7e72019-06-17 18:28:27 -0400509<p>
510 See <a href="/doc/go1.12#tls_1_3">the Go 1.12 release notes</a> for important
511 compatibility information.
512</p>
513
514<h3 id="crypto/ed25519"><a href="/pkg/crypto/ed25519/">crypto/ed25519</a></h3>
515
516<p><!-- CL 174945, 182698 -->
517 The new <a href="/pkg/crypto/ed25519/"><code>crypto/ed25519</code></a>
518 package implements the Ed25519 signature
519 scheme. This functionality was previously provided by the
520 <a href="https://godoc.org/golang.org/x/crypto/ed25519"><code>golang.org/x/crypto/ed25519</code></a>
521 package, which becomes a wrapper for
522 <code>crypto/ed25519</code> when used with Go 1.13+.
523</p>
Russ Cox23167842019-04-30 13:46:02 -0400524
Jonathan Amsterdama4c82512019-08-05 10:14:40 -0400525<h3 id="error_wrapping">Error wrapping</h3>
526
527<p><!-- CL 163558, 176998 -->
528 Go 1.13 contains support for error wrapping, as first proposed in
529 the <a href="https://go.googlesource.com/proposal/+/master/design/29934-error-values.md">
530 Error Values proposal</a> and discussed on <a href="https://golang.org/issue/29934">the
531 associated issue</a>.
532</p>
533<p>
534 An error <code>e</code> can <em>wrap</em> another error <code>w</code> by providing
535 an <code>Unwrap</code> method that returns <code>w</code>. Both <code>e</code>
536 and <code>w</code> are available to programs, allowing <code>e</code> to provide
537 additional context to <code>w</code> or to reinterpret it while still allowing
538 programs to make decisions based on <code>w</code>.
539</p>
540<p>
541 To support wrapping, <a href="#fmt"><code>fmt.Errorf</code></a> now has a <code>%w</code>
542 verb for creating wrapped errors, and three new functions in
543 the <a href="#errors"><code>errors</code></a> package (
Toshihiro Shiino89fb80f2019-08-23 11:56:32 +0000544 <a href="/pkg/errors/#Unwrap"><code>errors.Unwrap</code></a>,
545 <a href="/pkg/errors/#Is"><code>errors.Is</code></a> and
546 <a href="/pkg/errors/#As"><code>errors.As</code></a>) simplify unwrapping
Jonathan Amsterdama4c82512019-08-05 10:14:40 -0400547 and inspecting wrapped errors.
548</p>
549<p>
550 For more information, read the <a href="/pkg/errors/"><code>errors</code> package
551 documentation</a>, or see
552 the <a href="https://golang.org/wiki/ErrorValueFAQ">Error Value FAQ</a>.
553 There will soon be a blog post as well.
554</p>
555
Russ Cox23167842019-04-30 13:46:02 -0400556<h3 id="minor_library_changes">Minor changes to the library</h3>
557
558<p>
559 As always, there are various minor changes and updates to the library,
560 made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a>
561 in mind.
562</p>
563
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400564<dl id="bytes"><dt><a href="/pkg/bytes/">bytes</a></dt>
565 <dd>
Andrew Bonventre65f53da2019-06-11 18:09:10 -0400566 <p>
567 The new <a href="/pkg/bytes/#ToValidUTF8"><code>ToValidUTF8</code></a> function returns a
568 copy of a given byte slice with each run of invalid UTF-8 byte sequences replaced by a given slice.
569 </p>
570
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400571</dl><!-- bytes -->
572
573<dl id="context"><dt><a href="/pkg/context/">context</a></dt>
574 <dd>
575 <p><!-- CL 169080 -->
Julie80f89132019-06-12 12:33:19 -0400576 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.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400577 </p>
578
579</dl><!-- context -->
580
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400581<dl id="crypto/tls"><dt><a href="/pkg/crypto/tls/">crypto/tls</a></dt>
582 <dd>
Filippo Valsordaa6a7b142019-06-27 19:00:08 -0400583 <p>
584 Support for SSL version 3.0 (SSLv3) <a href="https://golang.org/issue/32716">
Filippo Valsorda2ebc3d82019-08-26 16:18:24 -0400585 is now deprecated and will be removed in Go 1.14</a>. Note that SSLv3 is the
586 <a href="https://tools.ietf.org/html/rfc7568">cryptographically broken</a>
587 protocol predating TLS.
588 </p>
589
590 <p>
591 SSLv3 was always disabled by default, other than in Go 1.12, when it was
592 mistakenly enabled by default server-side. It is now again disabled by
593 default. (SSLv3 was never supported client-side.)
Filippo Valsordaa6a7b142019-06-27 19:00:08 -0400594 </p>
595
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400596 <p><!-- CL 177698 -->
Filippo Valsordac82e7e72019-06-17 18:28:27 -0400597 Ed25519 certificates are now supported in TLS versions 1.2 and 1.3.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400598 </p>
599
600</dl><!-- crypto/tls -->
601
Filippo Valsordac82e7e72019-06-17 18:28:27 -0400602<dl id="crypto/x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt>
603 <dd>
604 <p><!-- CL 175478 -->
605 Ed25519 keys are now supported in certificates and certificate requests
606 according to <a href="https://www.rfc-editor.org/info/rfc8410">RFC 8410</a>, as well as by the
607 <a href="/pkg/crypto/x509/#ParsePKCS8PrivateKey"><code>ParsePKCS8PrivateKey</code></a>,
608 <a href="/pkg/crypto/x509/#MarshalPKCS8PrivateKey"><code>MarshalPKCS8PrivateKey</code></a>,
609 and <a href="/pkg/crypto/x509/#ParsePKIXPublicKey"><code>ParsePKIXPublicKey</code></a> functions.
610 </p>
611
Filippo Valsorda5f7e9ce2019-06-24 13:49:06 -0400612 <p><!-- CL 169238 -->
613 The paths searched for system roots now include <code>/etc/ssl/cert.pem</code>
614 to support the default location in Alpine Linux 3.7+.
615 </p>
616
Filippo Valsordac82e7e72019-06-17 18:28:27 -0400617</dl><!-- crypto/x509 -->
618
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400619<dl id="database/sql"><dt><a href="/pkg/database/sql/">database/sql</a></dt>
620 <dd>
621 <p><!-- CL 170699 -->
Julie87367cf2019-06-12 12:51:22 -0400622 The new <a href="/pkg/database/sql/#NullTime"><code>NullTime</code></a> type represents a <code>time.Time</code> that may be null.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400623 </p>
624
625 <p><!-- CL 174178 -->
Julie87367cf2019-06-12 12:51:22 -0400626 The new <a href="/pkg/database/sql/#NullInt32"><code>NullInt32</code></a> type represents an <code>int32</code> that may be null.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400627 </p>
628
629</dl><!-- database/sql -->
630
631<dl id="debug/dwarf"><dt><a href="/pkg/debug/dwarf/">debug/dwarf</a></dt>
632 <dd>
633 <p><!-- CL 158797 -->
Austin Clementsbd7d1bb2019-06-14 15:02:35 -0400634 The <a href="/pkg/debug/dwarf/#Data.Type"><code>Data.Type</code></a>
635 method no longer panics if it encounters an unknown DWARF tag in
636 the type graph. Instead, it represents that component of the
637 type with
638 an <a href="/pkg/debug/dwarf/#UnsupportedType"><code>UnsupportedType</code></a>
639 object.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400640 </p>
641
642</dl><!-- debug/dwarf -->
643
Andrew98e1bd22019-06-24 15:28:00 -0400644<dl id="errors"><dt><a href="/pkg/errors/">errors</a></dt>
645 <dd>
646 <!-- CL 163558 -->
647 <p>
Jonathan Amsterdama4c82512019-08-05 10:14:40 -0400648 The new function <a href="/pkg/errors/#As"><code>As</code></a> finds the first
649 error in a given error’s chain (sequence of wrapped errors)
Andrew98e1bd22019-06-24 15:28:00 -0400650 that matches a given target’s type, and if so, sets the target to that error value.
651 </p>
652 <p>
653 The new function <a href="/pkg/errors/#Is"><code>Is</code></a> reports whether a given error value matches an
654 error in another’s chain.
655 </p>
656 <p>
657 The new function <a href="/pkg/errors/#Unwrap"><code>Unwrap</code></a> returns the result of calling
658 <code>Unwrap</code> on a given error, if one exists.
659 </p>
660
661</dl><!-- errors -->
662
Jonathan Amsterdam7b8234b2019-07-27 14:29:02 -0400663<dl id="fmt"><dt><a href="/pkg/fmt/">fmt</a></dt>
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400664 <dd>
Emmanuel T Odeke9e1c8642019-08-23 10:05:56 -0600665 <!-- CL 160245 -->
666 <p>
667 The printing verbs <code>%x</code> and <code>%X</code> now format floating-point and
668 complex numbers in hexadecimal notation, in lower-case and upper-case respectively.
669 </p>
670
671 <!-- CL 160246 -->
672 <p>
673 The new printing verb <code>%O</code> formats integers in base 8, emitting the <code>0o</code> prefix.
674 </p>
675
676 <!-- CL 160247 -->
677 <p>
678 The scanner now accepts hexadecimal floating-point values, digit-separating underscores
679 and leading <code>0b</code> and <code>0o</code> prefixes.
680 See the <a href="#language">Changes to the language</a> for details.
681 </p>
682
Jonathan Amsterdam7b8234b2019-07-27 14:29:02 -0400683 <!-- CL 176998 -->
684 <p>The <a href="/pkg/fmt/#Errorf"><code>Errorf</code></a> function
685 has a new verb, <code>%w</code>, whose operand must be an error.
686 The error returned from <code>Errorf</code> will have an
687 <code>Unwrap</code> method which returns the operand of <code>%w</code>.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400688 </p>
689
Jonathan Amsterdam7b8234b2019-07-27 14:29:02 -0400690</dl><!-- fmt -->
691
Robert Griesemerb5a8dcb2019-06-20 16:50:48 -0700692
693<dl id="go/scanner"><dt><a href="/pkg/go/scanner/">go/scanner</a></dt>
694 <dd>
695 <p><!-- CL 175218 -->
696 The scanner has been updated to recognize the new Go number literals, specifically
697 binary literals with <code>0b</code>/<code>0B</code> prefix, octal literals with <code>0o</code>/<code>0O</code> prefix,
698 and floating-point numbers with hexadecimal mantissa. The imaginary suffix <code>i</code> may now be used with any number
699 literal, and underscores may used as digit separators for grouping.
700 See the <a href="#language">Changes to the language</a> for details.
701 </p>
702
703 </dl><!-- go/scanner -->
704
705<dl id="go/types"><dt><a href="/pkg/go/types/">go/types</a></dt>
706 <dd>
707 <p>
708 The type-checker has been updated to follow the new rules for integer shifts.
709 See the <a href="#language">Changes to the language</a> for details.
710 </p>
711
712</dl><!-- go/types -->
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400713
Jonathan Amsterdam7b8234b2019-07-27 14:29:02 -0400714
715
716<dl id="html/template"><dt><a href="/pkg/html/template/">html/template</a></dt>
717 <dd>
718 <p><!-- CL 175218 -->
719 When using a <code>&lt;script&gt;</code> tag with "module" set as the
720 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>.
721 </p>
722
723</dl><!-- html/template -->
724
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400725<dl id="log"><dt><a href="/pkg/log/">log</a></dt>
726 <dd>
727 <p><!-- CL 168920 -->
Julie9838f4d2019-06-12 13:38:45 -0400728 The new <a href="/pkg/log/#Writer"><code>Writer</code></a> function returns the output destination for the standard logger.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400729 </p>
730
731</dl><!-- log -->
732
733<dl id="math/big"><dt><a href="/pkg/math/big/">math/big</a></dt>
734 <dd>
735 <p><!-- CL 160682 -->
Filippo Valsorda5f7e9ce2019-06-24 13:49:06 -0400736 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.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400737 </p>
738
Emmanuel T Odekee7644322019-08-20 23:09:31 -0600739 <p><!-- CL 166157 -->
740 For <a href="/pkg/math/big/#Float.Parse"><code>Float.Parse</code></a>, if base is 0, underscores
741 may be used between digits for readability.
742 See the <a href="#language">Changes to the language</a> for details.
743 </p>
744
745 <p><!-- CL 166157 -->
746 For <a href="/pkg/math/big/#Int.SetString"><code>Int.SetString</code></a>, if base is 0, underscores
747 may be used between digits for readability.
748 See the <a href="#language">Changes to the language</a> for details.
749 </p>
750
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400751 <p><!-- CL 168237 -->
Filippo Valsorda5f7e9ce2019-06-24 13:49:06 -0400752 <a href="/pkg/math/big/#Rat.SetString"><code>Rat.SetString</code></a> now accepts non-decimal floating point representations.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400753 </p>
754
755</dl><!-- math/big -->
756
757<dl id="math/bits"><dt><a href="/pkg/math/bits/">math/bits</a></dt>
758 <dd>
759 <p><!-- CL 178177 -->
Filippo Valsordac82e7e72019-06-17 18:28:27 -0400760 The execution time of <a href="/pkg/math/bits/#Add"><code>Add</code></a>,
761 <a href="/pkg/math/bits/#Sub"><code>Sub</code></a>,
762 <a href="/pkg/math/bits/#Mul"><code>Mul</code></a>,
763 <a href="/pkg/math/bits/#RotateLeft"><code>RotateLeft</code></a>, and
764 <a href="/pkg/math/bits/#ReverseBytes"><code>ReverseBytes</code></a> is now
765 guaranteed to be independent of the inputs.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400766 </p>
767
768</dl><!-- math/bits -->
769
770<dl id="net"><dt><a href="/pkg/net/">net</a></dt>
771 <dd>
772 <p><!-- CL 156366 -->
Andrew Bonventredec16792019-08-28 16:07:39 -0400773 On Unix systems where <code>use-vc</code> is set in <code>resolv.conf</code>, TCP is used for DNS resolution.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400774 </p>
775
776 <p><!-- CL 170678 -->
Andrewcb0f0d62019-06-17 16:20:53 -0400777 The new field <a href="/pkg/net/#ListenConfig.KeepAlive"><code>ListenConfig.KeepAlive</code></a>
778 specifies the keep-alive period for network connections accepted by the listener.
Ian Lance Taylor55e23cb2019-08-02 13:17:59 -0700779 If this field is 0 (the default) TCP keep-alives will be enabled.
780 To disable them, set it to a negative value.
781 </p>
782 <p>
783 Note that the error returned from I/O on a connection that was
784 closed by a keep-alive timeout will have a
785 <code>Timeout</code> method that returns <code>true</code> if called.
786 This can make a keep-alive error difficult to distinguish from
787 an error returned due to a missed deadline as set by the
Toshihiro Shiino89fb80f2019-08-23 11:56:32 +0000788 <a href="/pkg/net/#Conn"><code>SetDeadline</code></a>
Ian Lance Taylor55e23cb2019-08-02 13:17:59 -0700789 method and similar methods.
790 Code that uses deadlines and checks for them with
791 the <code>Timeout</code> method or
792 with <a href="/pkg/os/#IsTimeout"><code>os.IsTimeout</code></a>
793 may want to disable keep-alives, or
794 use <code>errors.Is(syscall.ETIMEDOUT)</code> (on Unix systems)
795 which will return true for a keep-alive timeout and false for a
796 deadline timeout.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400797 </p>
798
799</dl><!-- net -->
800
801<dl id="net/http"><dt><a href="/pkg/net/http/">net/http</a></dt>
802 <dd>
Emmanuel T Odeked6f6a462019-07-31 19:18:32 -0700803 <p><!-- CL 76410 -->
804 The new fields <a href="/pkg/net/http/#Transport.WriteBufferSize"><code>Transport.WriteBufferSize</code></a>
805 and <a href="/pkg/net/http/#Transport.ReadBufferSize"><code>Transport.ReadBufferSize</code></a>
806 allow one to specify the sizes of the write and read buffers for a <a href="/pkg/net/http/#Transport"><code>Transport</code></a>.
807 If either field is zero, a default size of 4KB is used.
808 </p>
809
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400810 <p><!-- CL 130256 -->
Andrew Bonventre5ce18192019-06-10 13:44:56 -0400811 The new field <a href="/pkg/net/http/#Transport.ForceAttemptHTTP2"><code>Transport.ForceAttemptHTTP2</code></a>
812 controls whether HTTP/2 is enabled when a non-zero <code>Dial</code>, <code>DialTLS</code>, or <code>DialContext</code>
813 func or <code>TLSClientConfig</code> is provided.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400814 </p>
815
816 <p><!-- CL 140357 -->
Andrew Bonventredec16792019-08-28 16:07:39 -0400817 <a href="/pkg/net/http/#Transport.MaxConnsPerHost"><code>Transport.MaxConnsPerHost</code></a> now works
818 properly with HTTP/2.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400819 </p>
820
821 <p><!-- CL 154383 -->
Andrew Bonventre5ce18192019-06-10 13:44:56 -0400822 <a href="/pkg/net/http/#TimeoutHandler"><code>TimeoutHandler</code></a>'s
823 <a href="/pkg/net/http/#ResponseWriter"><code>ResponseWriter</code></a> now implements the
Emmanuel T Odeke4faf8a82019-09-26 13:17:49 -0700824 <a href="/pkg/net/http/#Pusher"><code>Pusher</code></a> interface.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400825 </p>
826
Emmanuel T Odeked6f6a462019-07-31 19:18:32 -0700827 <p><!-- CL 157339 -->
828 The <code>StatusCode</code> <code>103</code> <code>"Early Hints"</code> has been added.
829 </p>
830
Emmanuel T Odekebdea3522019-07-31 18:14:56 -0700831 <p><!-- CL 163599 -->
832 <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
833 <a href="/pkg/io/#ReaderFrom"><code>io.ReaderFrom</code></a> implementation if available, to optimize writing the body.
834 </p>
835
Emmanuel T Odeked6f6a462019-07-31 19:18:32 -0700836 <p><!-- CL 167017 -->
837 On encountering unsupported transfer-encodings, <a href="/pkg/net/http/#Server"><code>http.Server</code></a> now
838 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>.
839 </p>
840
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400841 <p><!-- CL 167681 -->
Toshihiro Shiino89fb80f2019-08-23 11:56:32 +0000842 The new <a href="/pkg/net/http/#Server"><code>Server</code></a> fields
Andrew Bonventre5ce18192019-06-10 13:44:56 -0400843 <a href="/pkg/net/http/#Server.BaseContext"><code>BaseContext</code></a> and
844 <a href="/pkg/net/http/#Server.ConnContext"><code>ConnContext</code></a>
Toshihiro Shiino89fb80f2019-08-23 11:56:32 +0000845 allow finer control over the <a href="/pkg/context/#Context"><code>Context</code></a> values provided to requests and connections.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400846 </p>
847
Emmanuel T Odeked6f6a462019-07-31 19:18:32 -0700848 <p><!-- CL 167781 -->
Toshihiro Shiino89fb80f2019-08-23 11:56:32 +0000849 <a href="/pkg/net/http/#DetectContentType"><code>http.DetectContentType</code></a> now correctly detects RAR signatures, and can now also detect RAR v5 signatures.
Emmanuel T Odeked6f6a462019-07-31 19:18:32 -0700850 </p>
851
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400852 <p><!-- CL 173658 -->
Andrew Bonventre5ce18192019-06-10 13:44:56 -0400853 The new <a href="/pkg/net/http/#Header"><code>Header</code></a> method
854 <a href="/pkg/net/http/#Header.Clone"><code>Clone</code></a> returns a copy of the receiver.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400855 </p>
856
Emmanuel T Odeked6f6a462019-07-31 19:18:32 -0700857 <p><!-- CL 174324 -->
858 A new function <a href="/pkg/net/http/#NewRequestWithContext"><code>NewRequestWithContext</code></a> has been added and it
859 accepts a <a href="/pkg/context/#Context"><code>Context</code></a> that controls the entire lifetime of
860 the created outgoing <a href="/pkg/net/http/#Request"><code>Request</code></a>, suitable for use with
Toshihiro Shiinoad4ed872019-08-14 05:26:56 +0000861 <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>.
Emmanuel T Odeked6f6a462019-07-31 19:18:32 -0700862 </p>
863
864 <p><!-- CL 179457 -->
Andrew Bonventredec16792019-08-28 16:07:39 -0400865 The <a href="/pkg/net/http/#Transport"><code>Transport</code></a> no longer logs errors when servers
866 gracefully shut down idle connections using a <code>"408 Request Timeout"</code> response.
Emmanuel T Odeked6f6a462019-07-31 19:18:32 -0700867 </p>
868
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400869</dl><!-- net/http -->
870
871<dl id="os"><dt><a href="/pkg/os/">os</a></dt>
872 <dd>
Dmitri Shuralyov0b6e3bf2019-06-12 14:59:23 -0400873 <p><!-- CL 160877 -->
874 The new <a href="/pkg/os/#UserConfigDir"><code>UserConfigDir</code></a> function
875 returns the default directory to use for user-specific configuration data.
876 </p>
877
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400878 <p><!-- CL 166578 -->
Andrew Bonventre5f94d442019-06-10 17:37:34 -0400879 If a <a href="/pkg/os/#File"><code>File</code></a> is opened using the O_APPEND flag, its
880 <a href="/pkg/os/#File.WriteAt"><code>WriteAt</code></a> method will always return an error.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400881 </p>
882
883</dl><!-- os -->
884
885<dl id="os/exec"><dt><a href="/pkg/os/exec/">os/exec</a></dt>
886 <dd>
887 <p><!-- CL 174318 -->
Toshihiro Shiino89fb80f2019-08-23 11:56:32 +0000888 On Windows, the environment for a <a href="/pkg/os/exec/#Cmd"><code>Cmd</code></a> always inherits the
Andrew Bonventre5f94d442019-06-10 17:37:34 -0400889 <code>%SYSTEMROOT%</code> value of the parent process unless the
Toshihiro Shiino89fb80f2019-08-23 11:56:32 +0000890 <a href="/pkg/os/exec/#Cmd.Env"><code>Cmd.Env</code></a> field includes an explicit value for it.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400891 </p>
892
893</dl><!-- os/exec -->
894
895<dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt>
896 <dd>
897 <p><!-- CL 171337 -->
Josh Bleecher Snyder52572af2019-06-17 12:57:40 -0700898 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.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400899 </p>
900
901 <p><!-- CL 174531 -->
Josh Bleecher Snyder52572af2019-06-17 12:57:40 -0700902 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.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400903 </p>
904
905</dl><!-- reflect -->
906
Dmitri Shuralyova864cc72020-02-05 05:23:42 -0500907<dl id="pkg-runtime"><dt><a href="/pkg/runtime/">runtime</a></dt>
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400908 <dd>
Keith Randall2f387ac2019-06-10 12:51:51 -0700909 <p> <!-- CL 167780 -->
Mohit Agarwale94472a2019-07-04 21:21:02 +0530910 Tracebacks, <a href="/pkg/runtime/#Caller"><code>runtime.Caller</code></a>,
911 and <a href="/pkg/runtime/#Callers"><code>runtime.Callers</code></a> now refer to the function that
Keith Randall2f387ac2019-06-10 12:51:51 -0700912 initializes the global variables of <code>PKG</code>
Toshihiro Shiinoad4ed872019-08-14 05:26:56 +0000913 as <code>PKG.init</code> instead of <code>PKG.init.ializers</code>.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400914 </p>
915
916</dl><!-- runtime -->
917
Emmanuel T Odeke1a7c15f2019-08-24 22:08:51 -0600918<dl id="strconv"><dt><a href="/pkg/strconv/">strconv</a></dt>
Emmanuel T Odekee7644322019-08-20 23:09:31 -0600919 <dd>
920 <p><!-- CL 160243 -->
Emmanuel T Odeke1a7c15f2019-08-24 22:08:51 -0600921 For <a href="/pkg/strconv/#ParseFloat"><code>strconv.ParseFloat</code></a>,
922 <a href="/pkg/strconv/#ParseInt"><code>strconv.ParseInt</code></a>
923 and <a href="/pkg/strconv/#ParseUint"><code>strconv.ParseUint</code></a>,
Emmanuel T Odekee7644322019-08-20 23:09:31 -0600924 if base is 0, underscores may be used between digits for readability.
925 See the <a href="#language">Changes to the language</a> for details.
926 </p>
927
928</dl><!-- strconv -->
929
Emmanuel T Odeke1a7c15f2019-08-24 22:08:51 -0600930<dl id="strings"><dt><a href="/pkg/strings/">strings</a></dt>
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400931 <dd>
932 <p><!-- CL 142003 -->
Andrew Bonventre65f53da2019-06-11 18:09:10 -0400933 The new <a href="/pkg/strings/#ToValidUTF8"><code>ToValidUTF8</code></a> function returns a
934 copy of a given string with each run of invalid UTF-8 byte sequences replaced by a given string.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400935 </p>
936
Andrew Bonventre65f53da2019-06-11 18:09:10 -0400937</dl><!-- strings -->
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400938
939<dl id="sync"><dt><a href="/pkg/sync/">sync</a></dt>
940 <dd>
Carlo Alberto Ferraris39289152019-08-10 13:11:26 +0000941 <p><!-- CL 148958, CL 148959, CL 152697, CL 152698 -->
942 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>,
943 <a href="/pkg/sync/#RWMutex.Lock"><code>RWMutex.Lock</code></a>, <a href="/pkg/sync/#Mutex.RUnlock"><code>RWMutex.RUnlock</code></a>, and
944 <a href="/pkg/sync/#Once.Do"><code>Once.Do</code></a> are now inlined in their callers.
945 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
946 <a href="/pkg/sync/#Mutex"><code>Mutex</code></a>/<a href="/pkg/sync/#RWMutex"><code>RWMutex</code></a> methods up to 10% faster.
947 </p>
948
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400949 <p><!-- CL 166960 -->
Katie Hockmanf18aeb32019-06-12 13:54:50 -0400950 Large <a href="/pkg/sync/#Pool"><code>Pool</code></a> no longer increase stop-the-world pause times.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400951 </p>
952
953 <p><!-- CL 166961 -->
Katie Hockman6a4b1f72019-06-11 15:12:54 -0400954 <code>Pool</code> no longer needs to be completely repopulated after every GC. It now retains some objects across GCs,
955 as opposed to releasing all objects, reducing load spikes for heavy users of <code>Pool</code>.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400956 </p>
957
958</dl><!-- sync -->
959
960<dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt>
961 <dd>
962 <p><!-- CL 168479 -->
Alberto Donizetti5bc46cb2019-07-14 19:08:57 +0200963 Uses of <code>_getdirentries64</code> have been removed from
964 Darwin builds, to allow Go binaries to be uploaded to the macOS
965 App Store.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400966 </p>
967
968 <p><!-- CL 174197 -->
Katie Hockmanf18aeb32019-06-12 13:54:50 -0400969 The new <code>ProcessAttributes</code> and <code>ThreadAttributes</code> fields in
970 <a href="/pkg/syscall/?GOOS=windows#SysProcAttr"><code>SysProcAttr</code></a> have been introduced for Windows,
971 exposing security settings when creating new processes.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400972 </p>
973
974 <p><!-- CL 174320 -->
Katie Hockmanf18aeb32019-06-12 13:54:50 -0400975 <code>EINVAL</code> is no longer returned in zero
976 <a href="/pkg/syscall/?GOOS=windows#Chmod"><code>Chmod</code></a> mode on Windows.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400977 </p>
978
Jonathan Amsterdam65e624e2019-08-22 12:40:52 -0400979 <p><!-- CL 191337 -->
980 Values of type <code>Errno</code> can be tested against error values in
981 the <code>os</code> package,
982 like <a href="/pkg/os/#ErrExist"><code>ErrExist</code></a>, using
983 <a href="/pkg/errors/#Is"><code>errors.Is</code></a>.
984 </p>
985
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400986</dl><!-- syscall -->
987
988<dl id="syscall/js"><dt><a href="/pkg/syscall/js/">syscall/js</a></dt>
989 <dd>
990 <p><!-- CL 177537 -->
Andrew Bonventredec16792019-08-28 16:07:39 -0400991 <code>TypedArrayOf</code> has been replaced by
Katie Hockmanf18aeb32019-06-12 13:54:50 -0400992 <a href="/pkg/syscall/js/#CopyBytesToGo"><code>CopyBytesToGo</code></a> and
Andrew Bonventredec16792019-08-28 16:07:39 -0400993 <a href="/pkg/syscall/js/#CopyBytesToJS"><code>CopyBytesToJS</code></a> for copying bytes
994 between a byte slice and a <code>Uint8Array</code>.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -0400995 </p>
996
997</dl><!-- syscall/js -->
998
999<dl id="testing"><dt><a href="/pkg/testing/">testing</a></dt>
1000 <dd>
1001 <p><!-- CL 112155 -->
Andrew832959f2019-06-18 13:32:04 -04001002 When running benchmarks, <a href="/pkg/testing/#B.N"><code>B.N</code></a> is no longer rounded.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -04001003 </p>
1004
1005 <p><!-- CL 166717 -->
Andrew832959f2019-06-18 13:32:04 -04001006 The new method <a href="/pkg/testing/#B.ReportMetric"><code>B.ReportMetric</code></a> lets users report
1007 custom benchmark metrics and override built-in metrics.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -04001008 </p>
1009
1010 <p><!-- CL 173722 -->
Bryan C. Millsb9df8df2019-07-18 17:41:45 -04001011 Testing flags are now registered in the new <a href="/pkg/testing/#Init"><code>Init</code></a> function,
1012 which is invoked by the generated <code>main</code> function for the test.
1013 As a result, testing flags are now only registered when running a test binary,
1014 and packages that call <code>flag.Parse</code> during package initialization may cause tests to fail.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -04001015 </p>
1016
1017</dl><!-- testing -->
1018
1019<dl id="text/scanner"><dt><a href="/pkg/text/scanner/">text/scanner</a></dt>
1020 <dd>
Robert Griesemerb5a8dcb2019-06-20 16:50:48 -07001021 <p><!-- CL 183077 -->
1022 The scanner has been updated to recognize the new Go number literals, specifically
1023 binary literals with <code>0b</code>/<code>0B</code> prefix, octal literals with <code>0o</code>/<code>0O</code> prefix,
1024 and floating-point numbers with hexadecimal mantissa.
1025 Also, the new <a href="/pkg/text/scanner/#AllowDigitSeparators"><code>AllowDigitSeparators</code></a>
1026 mode allows number literals to contain underscores as digit separators (off by default for backwards-compatibility).
1027 See the <a href="#language">Changes to the language</a> for details.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -04001028 </p>
1029
1030</dl><!-- text/scanner -->
1031
1032<dl id="text/template"><dt><a href="/pkg/text/template/">text/template</a></dt>
1033 <dd>
1034 <p><!-- CL 161762 -->
Katie Hockmanc0c6cee2019-06-12 18:04:00 -04001035 The new <a href="/pkg/text/template/#hdr-Functions">slice function</a>
1036 returns the result of slicing its first argument by the following arguments.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -04001037 </p>
1038
1039</dl><!-- text/template -->
1040
1041<dl id="time"><dt><a href="/pkg/time/">time</a></dt>
1042 <dd>
1043 <p><!-- CL 122876 -->
Mohit Agarwale94472a2019-07-04 21:21:02 +05301044 Day-of-year is now supported by <a href="/pkg/time/#Time.Format"><code>Format</code></a>
Andrew Bonventre65f53da2019-06-11 18:09:10 -04001045 and <a href="/pkg/time/#Parse"><code>Parse</code></a>.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -04001046 </p>
1047
1048 <p><!-- CL 167387 -->
Andrew Bonventre65f53da2019-06-11 18:09:10 -04001049 The new <a href="/pkg/time/#Duration"><code>Duration</code></a> methods
1050 <a href="/pkg/time/#Duration.Microseconds"><code>Microseconds</code></a> and
1051 <a href="/pkg/time/#Duration.Milliseconds"><code>Milliseconds</code></a> return
1052 the duration as an integer count of their respectively named units.
Andrew Bonventre9ab9ca22019-06-05 11:45:01 -04001053 </p>
1054
1055</dl><!-- time -->
1056
Marcel van Lohuizen0ed86cd2019-08-05 17:57:29 +02001057<dl id="unicode"><dt><a href="/pkg/unicode/">unicode</a></dt>
1058 <dd>
1059 <p>
1060 The <a href="/pkg/unicode/"><code>unicode</code></a> package and associated
1061 support throughout the system has been upgraded from Unicode 10.0 to
1062 <a href="http://www.unicode.org/versions/Unicode11.0.0/">Unicode 11.0</a>,
1063 which adds 684 new characters, including seven new scripts, and 66 new emoji.
1064 </p>
1065
1066</dl><!-- unicode -->