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