blob: 4e173d130a9cdeda4938e1179174e74a431f39c0 [file] [log] [blame]
Rob Piked6ef6eb2015-06-25 14:36:49 +10001<!--{
2 "Title": "Go 1.5 Release Notes",
3 "Path": "/doc/go1.5",
4 "Template": true
5}-->
6
Rob Pike751eef82015-06-25 16:20:27 +10007
8<h2 id="introduction">Introduction to Go 1.5</h2>
9
10<p>
11The latest Go release, version 1.5,
12is a significant release, including major architectural changes to the implementation.
13Despite that, we expect almost all Go programs to continue to compile and run as before,
14because the release still maintains the Go 1 <a href="/doc/go1compat.html">promise
15of compatibility</a>.
16</p>
17
18<p>
19The biggest developments in the implementation are:
20</p>
21
22<ul>
23
24<li>
25The compiler and runtime are now written entirely in Go (with a little assembler).
26C is no longer involved in the implementation, and so the C compiler that was
27once necessary for building the distribution is gone.
28</li>
29
30<li>
Rob Pikeef371842015-07-06 09:01:32 +100031The garbage collector is now <a href="https://golang.org/s/go14gc">concurrent</a> and provides dramatically lower
Rob Pike751eef82015-06-25 16:20:27 +100032pause times by running, when possible, in parallel with other goroutines.
33</li>
34
35<li>
36By default, Go programs run with <code>GOMAXPROCS</code> set to the
37number of cores available; in prior releases it defaulted to 1.
38</li>
39
40<li>
Brad Fitzpatrick2ae77372015-07-10 17:17:11 -060041Support for <a href="https://golang.org/s/go14internal">internal packages</a>
Rob Pike751eef82015-06-25 16:20:27 +100042is now provided for all repositories, not just the Go core.
43</li>
44
45<li>
Rob Pikeef371842015-07-06 09:01:32 +100046The <code>go</code> command now provides <a href="https://golang.org/s/go15vendor">experimental
Rob Pike751eef82015-06-25 16:20:27 +100047support</a> for "vendoring" external dependencies.
48</li>
49
Rob Pikeef371842015-07-06 09:01:32 +100050<li>
51A new <code>go tool trace</code> command supports fine-grained
52tracing of program execution.
53</li>
54
55<li>
56A new <code>go doc</code> command (distinct from <code>godoc</code>)
57is customized for command-line use.
58</li>
59
Rob Pike751eef82015-06-25 16:20:27 +100060</ul>
61
62<p>
63These and a number of other changes to the implementation and tools
64are discussed below.
65</p>
66
67<p>
68The release also contains one small language change involving map literals.
69</p>
70
71<p>
Rob Pikeef371842015-07-06 09:01:32 +100072Finally, the timing of the <a href="https://golang.org/s/releasesched">release</a>
Rob Pike751eef82015-06-25 16:20:27 +100073strays from the usual six-month interval,
74both to provide more time to prepare this major release and to shift the schedule thereafter to
75time the release dates more conveniently.
76</p>
77
78<h2 id="language">Changes to the language</h2>
79
Rob Pikeef371842015-07-06 09:01:32 +100080<h3 id="map_literals">Map literals</h3>
Rob Pike751eef82015-06-25 16:20:27 +100081
82<p>
83Due to an oversight, the rule that allowed the element type to be elided from slice literals was not
84applied to map keys.
85This has been <a href="/cl/2591">corrected</a> in Go 1.5.
86An example will make this clear: as of Go 1.5, this map literal,
87</p>
88
Rob Piked6ef6eb2015-06-25 14:36:49 +100089<pre>
Rob Pike751eef82015-06-25 16:20:27 +100090m := map[Point]string{
91 Point{29.935523, 52.891566}: "Persepolis",
92 Point{-25.352594, 131.034361}: "Uluru",
93 Point{37.422455, -122.084306}: "Googleplex",
94}
95</pre>
Brad Fitzpatrickfd2642b2015-01-18 16:00:10 -080096
Rob Pike751eef82015-06-25 16:20:27 +100097<p>
98may be written as follows, without the <code>Point</code> type listed explicitly:
99</p>
Robert Griesemer754bb712015-03-20 16:17:13 -0700100
Rob Pike751eef82015-06-25 16:20:27 +1000101<pre>
102m := map[Point]string{
103 {29.935523, 52.891566}: "Persepolis",
104 {-25.352594, 131.034361}: "Uluru",
105 {37.422455, -122.084306}: "Googleplex",
106}
107</pre>
Brad Fitzpatrickfd2642b2015-01-18 16:00:10 -0800108
Rob Pike751eef82015-06-25 16:20:27 +1000109<h2 id="implementation">The Implementation</h2>
Russ Coxcbbe9f62015-04-27 19:28:16 -0400110
Rob Pike751eef82015-06-25 16:20:27 +1000111<h3 id="c">No more C</h3>
Brad Fitzpatrickfb7e2442015-05-14 16:02:53 -0700112
Rob Pike751eef82015-06-25 16:20:27 +1000113<p>
114The compiler and runtime are now implemented in Go and assembler, without C.
115The only C source left in the tree is related to testing or to <code>cgo</code>.
116There was a C compiler in the tree in 1.4 and earlier.
117It was used to build the runtime; a custom compiler was necessary in part to
118guarantee the C code would work with the stack management of goroutines.
119Since the runtime is in Go now, there is no need for this C compiler and it is gone.
Rob Pikeef371842015-07-06 09:01:32 +1000120Details of the process to eliminate C are discussed <a href="https://golang.org/s/go13compiler">elsewhere</a>.
Rob Pike751eef82015-06-25 16:20:27 +1000121</p>
122
123<p>
124The conversion from C was done with the help of custom tools created for the job.
125Most important, the compiler was actually moved by automatic translation of
126the C code into Go.
127It is in effect the same program in a different language.
128It is not a new implementation
129of the compiler so we expect the process will not have introduced new compiler
130bugs.
131An overview of this process is available in the slides for
132<a href="https://talks.golang.org/2015/gogo.slide">this presentation</a>.
133</p>
134
Rob Pikeef371842015-07-06 09:01:32 +1000135<h3 id="compiler_and_tools">Compiler and tools</h3>
Rob Pike751eef82015-06-25 16:20:27 +1000136
137<p>
138Independent of but encouraged by the move to Go, the names of the tools have changed.
139The old names <code>6g</code>, <code>8g</code> and so on are gone; instead there
140is just one binary, accessible as <code>go</code> <code>tool</code> <code>compile</code>,
141that compiles Go source into binaries suitable for the architecture and operating system
142specified by <code>$GOARCH</code> and <code>$GOOS</code>.
Rob Pikec418fe72015-06-29 19:51:56 +1000143Similarly, there is now one linker (<code>go</code> <code>tool</code> <code>link</code>)
Rob Pike751eef82015-06-25 16:20:27 +1000144and one assembler (<code>go</code> <code>tool</code> <code>asm</code>).
145The linker was translated automatically from the old C implementation,
146but the assembler is a new native Go implementation discussed
147in more detail below.
148</p>
149
150<p>
151Similar to the drop of the names <code>6g</code>, <code>8g</code>, and so on,
152the output of the compiler and assembler are now given a plain <code>.o</code> suffix
153rather than <code>.8</code>, <code>.6</code>, etc.
154</p>
155
156
157<h3 id="gc">Garbage collector</h3>
158
159<p>
Rob Pikeef371842015-07-06 09:01:32 +1000160The garbage collector has been re-engineered for 1.5 as part of the development
161outlined in the <a href="https://golang.org/s/go14gc">design document</a>.
162Expected latencies are much lower than with the collector
163in prior releases, through a combination of advanced algorithms,
164better <a href="https://golang.org/s/go15gcpacing">scheduling</a> of the collector,
165and running more of the collection in parallel with the user program.
166The "stop the world" phase of the collector
167will almost always be under 10 milliseconds and usually much less.
168</p>
169
170<p>
171For systems that benefit from low latency, such as user-responsive web sites,
172the drop in expected latency with the new collector may be important.
173</p>
174
175<p>
Rob Pike6163cf82015-07-16 14:45:46 +1000176Details of the new collector were presented in a
177<a href="https://talks.golang.org/2015/go-gc.pdf">talk</a> at GopherCon 2015.
Rob Pike751eef82015-06-25 16:20:27 +1000178</p>
179
180<h3 id="runtime">Runtime</h3>
181
182<p>
183In Go 1.5, the order in which goroutines are scheduled has been changed.
184The properties of the scheduler were never defined by the language,
185but programs that depended on the scheduling order may be broken
186by this change.
187We have seen a few (erroneous) programs affected by this change.
188If you have programs that implicitly depend on the scheduling
189order, you will need to update them.
190</p>
191
192<p>
193Another potentially breaking change is that the runtime now
194sets the default number of threads to run simultaneously,
195defined by <code>GOMAXPROCS</code>, to the number
196of cores available on the CPU.
197In prior releases it defaulted to 1.
198Programs that do not expect to run with multiple cores may
199break inadvertently.
200They can be updated by removing the restriction or by setting
Rob Pike902345e2015-07-14 15:20:19 +1000201<code>GOMAXPROCS</code> explicitly.
Rob Pike751eef82015-06-25 16:20:27 +1000202</p>
203
204<h3 id="build">Build</h3>
205
206<p>
207Now that the Go compiler and runtime are implemented in Go, a Go compiler
208must be available to compile the distribution from source.
209Thus, to build the Go core, a working Go distribution must already be in place.
210(Go programmers who do not work on the core are unaffected by this change.)
211Any Go 1.4 or later distribution (including <code>gccgo</code>) will serve.
Rob Pikeef371842015-07-06 09:01:32 +1000212For details, see the <a href="https://golang.org/s/go15bootstrap">design document</a>.
Rob Pike751eef82015-06-25 16:20:27 +1000213</p>
214
215<h2 id="ports">Ports</h2>
216
217<p>
Jonathan Rudenberg9e88f792015-07-14 18:53:13 -0400218Due mostly to the industry's move away from the 32-bit x86 architecture,
Rob Pike751eef82015-06-25 16:20:27 +1000219the set of binary downloads provided is reduced in 1.5.
220A distribution for the OS X operating system is provided only for the
221<code>amd64</code> architecture, not <code>386</code>.
222Similarly, the ports for Snow Leopard (Apple OS X 10.6) still work but are no
223longer released as a download or maintained since Apple no longer maintains that version
224of the operating system.
225Also, the <code>dragonfly/386</code> port is no longer supported at all
226because DragonflyBSD itself no longer supports the 32-bit 386 architecture.
227</p>
228
229<p>
230There are however several new ports available to be built from source.
231These include <code>darwin/arm</code> and <code>darwin/arm64</code>.
232The new port <code>linux/arm64</code> is mostly in place, but <code>cgo</code>
233is only supported using external linking.
234</p>
235
Rob Pike0ea3f582015-06-26 11:52:21 +1000236<p>
Rob Pike0908fad2015-07-22 11:24:27 +1000237Also available as experiments are <code>ppc64</code> (IBM Power 64)
238and <code>ppc64le</code> (IBM Power 64, little-endian).
239Both these ports support <code>cgo</code>,
240but for <code>ppc64</code> it requires external linking while
241for <code>ppc64le</code> it requires internal linking.
242</p>
243
244<p>
Rob Pike0ea3f582015-06-26 11:52:21 +1000245On FreeBSD, Go 1.5 requires FreeBSD 8-STABLE+ because of its new use of the <code>SYSCALL</code> instruction.
246</p>
247
248<p>
249On NaCl, Go 1.5 requires SDK version pepper-39 or above because it now uses the
250<code>get_random_bytes</code> system call.
251</p>
252
David Crawshawebb67832015-07-16 15:30:47 -0400253<p>
254On Darwin, the use of the system X.509 certificate interface can be disabled
255with the <code>ios</code> build tag.
256</p>
257
Rob Pikecd2e2f62015-07-01 15:49:40 +1000258<h2 id="tools">Tools</h2>
Rob Pike1a27c072015-01-13 10:16:30 +1100259
Rob Pikeef371842015-07-06 09:01:32 +1000260<h3 id="translate">Translating</h3>
Rob Pike751eef82015-06-25 16:20:27 +1000261
Rob Pikeef371842015-07-06 09:01:32 +1000262<p>
263As part of the process to eliminate C from the tree, the compiler and
264linker were translated from C to Go.
265It was a genuine (machine assisted) translation, so the new programs are essentially
266the old programs translated rather than new ones with new bugs.
267We are confident the translation process has introduced few if any new bugs,
268and in fact uncovered a number of previously unknown bugs, now fixed.
269</p>
270
271<p>
272The assembler is a new program, however; it is described below.
273</p>
274
275<h3 id="rename">Renaming</h3>
276
277<p>
278The suites of programs that were the compilers (<code>6g</code>, <code>8g</code>, etc.),
279the assemblers (<code>6a</code>, <code>8a</code>, etc.),
280and the linkers (<code>6l</code>, <code>8l</code>, etc.)
281have each been consolidated into a single tool that is configured
282by the environment variables <code>GOOS</code> and <code>GOARCH</code>.
283The old names are gone; the new tools are available through the <code>go</code> <code>tool</code>
284mechanism as <code>go tool compile</code>,
285<code>go tool asm</code>,
286<code>and go tool link</code>.
287Also, the file suffixes <code>.6</code>, <code>.8</code> etc. for the
288intermediate object files are also gone; now they are just plain <code>.o</code> files.
289</p>
290
291<p>
292For example, to build and link a program on amd64 for Darwin
293using the tools directly, rather than through <code>go build</code>,
294one would run:
295</p>
296
297<pre>
298$ export GOOS=darwin GOARCH=amd64
299$ go tool compile program.go
300$ go tool link program.o
Rob Piked6ef6eb2015-06-25 14:36:49 +1000301</pre>
Rob Pike751eef82015-06-25 16:20:27 +1000302
Rob Pikeef371842015-07-06 09:01:32 +1000303<h3 id="moving">Moving</h3>
304
305<p>
306Because the <a href="/pkg/go/types/"><code>go/types</code></a> package
307has now moved into the main repository (see below),
308the <a href="/cmd/vet"><code>vet</code></a> and
309<a href="/cmd/cover"><code>cover</code></a>
310tools have also been moved.
311They are no longer maintained in the external <code>golang.org/x/tools</code> repository,
312although (deprecated) source still resides there for compatibility with old releases.
313</p>
314
315<h3 id="compiler">Compiler</h3>
316
317<p>
318As described above, the compiler in Go 1.5 is a single Go program,
319translated from the old C source, that replaces <code>6g</code>, <code>8g</code>,
320and so on.
321Its target is configured by the environment variables <code>GOOS</code> and <code>GOARCH</code>.
322</p>
323
324<p>
325The 1.5 compiler is mostly equivalent to the old,
326but some internal details have changed.
327One significant change is that evaluation of constants now uses
328the <a href="/pkg/math/big/"><code>math/big</code></a> package
329rather than a custom (and less well tested) implementation of high precision
330arithmetic.
331We do not expect this to affect the results.
332</p>
333
334<p>
335For the amd64 architecture only, the compiler has a new option, <code>-dynlink</code>,
336that assists dynamic linking by supporting references to Go symbols
337defined in external shared libraries.
338</p>
339
Rob Pike09b54632015-07-02 12:56:51 +1000340<h3 id="assembler">Assembler</h3>
341
342<p>
Rob Pikeef371842015-07-06 09:01:32 +1000343Like the compiler and linker, the assembler in Go 1.5 is a single program
344that replaces the suite of assemblers (<code>6a</code>,
345<code>8a</code>, etc.) and the environment variables
Rob Pike09b54632015-07-02 12:56:51 +1000346<code>GOARCH</code> and <code>GOOS</code>
Rob Pikeef371842015-07-06 09:01:32 +1000347configure the architecture and operating system.
348Unlike the other programs, the assembler is a wholly new program
349written in Go.
Rob Pike09b54632015-07-02 12:56:51 +1000350</p>
Rob Pike902345e2015-07-14 15:20:19 +1000351
Rob Pike09b54632015-07-02 12:56:51 +1000352 <p>
353The new assembler is very nearly compatible with the previous
Rob Pikeef371842015-07-06 09:01:32 +1000354ones, but there are a few changes that may affect some
Rob Pike09b54632015-07-02 12:56:51 +1000355assembler source files.
Rob Pikeef371842015-07-06 09:01:32 +1000356See the updated <a href="/doc/asm">assembler guide</a>
357for more specific information about these changes. In summary:
358
Rob Pike09b54632015-07-02 12:56:51 +1000359</p>
360
361<p>
362First, the expression evaluation used for constants is a little
363different.
364It now uses unsigned 64-bit arithmetic and the precedence
365of operators (<code>+</code>, <code>-</code>, <code><<</code>, etc.)
366comes from Go, not C.
Rob Pikeef371842015-07-06 09:01:32 +1000367We expect these changes to affect very few programs but
368manual verification may be required.
Rob Pike09b54632015-07-02 12:56:51 +1000369</p>
370
371<p>
Rob Pikee71276c2015-07-09 10:10:12 +1000372Perhaps more important is that on machines where
373<code>SP</code> or <code>PC</code> is only an alias
374for a numbered register,
375such as <code>R13</code> for the stack pointer and
376<code>R15</code> for the hardware program counter
Rob Pike2e6ed612015-07-09 15:06:15 +1000377on ARM,
Rob Pikee71276c2015-07-09 10:10:12 +1000378a reference to such a register that does not include a symbol
379is now illegal.
380For example, <code>SP</code> and <code>4(SP)</code> are
381illegal but <code>sym+4(SP)</code> is fine.
382On such machines, to refer to the hardware register use its
383true <code>R</code> name.
Rob Pike09b54632015-07-02 12:56:51 +1000384</p>
385
386<p>
387One minor change is that some of the old assemblers
388permitted the notation
389</p>
390
391<pre>
392constant=value
393</pre>
394
395<p>
396to define a named constant.
397Since this is always possible to do with the traditional
398C-like <code>#define</code> notation, which is still
399supported (the assembler includes an implementation
400of a simplified C preprocessor), the feature was removed.
401</p>
402
Rob Pikeef371842015-07-06 09:01:32 +1000403<h3 id="link">Linker</h3>
404
405<p>
406The linker in Go 1.5 is now one Go program,
407that replaces <code>6l</code>, <code>8l</code>, etc.
408Its operating system and instruction set are specified
409by the environment variables <code>GOOS</code> and <code>GOARCH</code>.
410</p>
411
412<p>
413There are a couple of other changes.
414The more significant is the addition of a <code>-buildmode</code> option that
415expands the style of linking; it now supports
416situations such as building shared libraries and allowing other languages
417to call into Go libraries.
418Some of these were outlined in a <a href="https://golang.org/s/execmodes">design document</a>.
419For a list of the available build modes and their use, run
420</p>
Rob Pikecd2e2f62015-07-01 15:49:40 +1000421
422<pre>
Rob Pikeef371842015-07-06 09:01:32 +1000423$ go help buildmode
Rob Pikecd2e2f62015-07-01 15:49:40 +1000424</pre>
425
Rob Pikeef371842015-07-06 09:01:32 +1000426<p>
427Another minor change is that the linker no longer records build time stamps in
428the header of Windows executables.
429Also, although this may be fixed, Windows cgo executables are missing some
430DWARF information.
431</p>
432
433<h3 id="go_command">Go command</h3>
434
435<p>
436The <a href="/cmd/go"><code>go</code></a> command's basic operation
437is unchanged, but there are a number of changes worth noting.
438</p>
439
440<p>
441The previous release introduced the idea of a directory internal to a package
442being unimportable through the <code>go</code> command.
443In 1.4, it was tested with the introduction of some internal elements
444in the core repository.
445As suggested in the <a href="https://golang.org/s/go14internal">design document</a>,
446that change is now being made available to all repositories.
447The rules are explained in the design document, but in summary any
448package in or under a directory named <code>internal</code> may
449be imported by packages rooted in the same subtree.
450Existing packages with directory elements named <code>internal</code> may be
451inadvertently broken by this change, which was why it was advertised
452in the last release.
453</p>
454
455<p>
456Another change in how packages are handled is the experimental
457addition of support for "vendoring".
Russ Coxaad4fe42015-07-22 11:33:42 -0400458For details, see the documentation for the <a href="/cmd/go/#hdr-Vendor_Directories"><code>go</code> command</a>
459and the <a href="https://golang.org/s/go15vendor">design document</a>.
Rob Pikeef371842015-07-06 09:01:32 +1000460</p>
461
462<p>
463There have also been several minor changes.
464Read the <a href="/cmd/go">documentation</a> for full details.
465</p>
466
467<ul>
468
469<li>
470SWIG support has been updated such that
471<code>.swig</code> and <code>.swigcxx</code>
472now require SWIG 3.0.6 or later.
473</li>
474
475<li>
476The <code>std</code> (standard library) wildcard package name
477now excludes commands.
478A new <code>cmd</code> wildcard covers the commands.
479</li>
480
481<li>
Russ Cox91a480c2015-07-14 00:34:36 -0400482A new <code>-asmflags</code> build option
483sets flags to pass to the assembler.
484However,
485the <code>-ccflags</code> build option has been dropped;
486it was specific to the old, now deleted C compiler .
Rob Pikeef371842015-07-06 09:01:32 +1000487</li>
488
489<li>
Russ Cox91a480c2015-07-14 00:34:36 -0400490A new <code>-buildmode</code> build option
491sets the build mode, described above.
Rob Pikeef371842015-07-06 09:01:32 +1000492</li>
493
494<li>
495An <code>-asmflags</code> build option has been added to provide
496flags to the assembler.
Rob Pike902345e2015-07-14 15:20:19 +1000497However,
Rob Pikee71276c2015-07-09 10:10:12 +1000498the <code>-ccflags</code> build option has been dropped;
499it was specific to the old, now deleted C compiler .
Rob Pikeef371842015-07-06 09:01:32 +1000500</li>
501
502<li>
Russ Cox91a480c2015-07-14 00:34:36 -0400503A new <code>-pkgdir</code> build option
504sets the location of installed package archives,
505to help isolate custom builds.
506</li>
507
508<li>
509A new <code>-toolexec</code> build option
510allows substitution of a different command to invoke
511the compiler and so on.
512This acts as a custom replacement for <code>go tool</code>.
513</li>
514
515<li>
Rob Pikee71276c2015-07-09 10:10:12 +1000516The <code>test</code> subcommand now has a <code>-count</code>
517flag to specify how many times to run each test and benchmark.
518<a href="/pkg/testing/"><code>testing</code></a> package
519does the work here, through by the <code>-test.count</code> flag.
Rob Pikeef371842015-07-06 09:01:32 +1000520</li>
521
522<li>
523The <code>generate</code> subcommand has a couple of new features.
524The <code>-run</code> option specifies a regular expression to select which directives
525to execute; this was proposed but never implemented in 1.4.
526The executing pattern now has access to two new environment variables:
527<code>$GOLINE</code> returns the source line number of the directive
528and <code>$DOLLAR</code> expands to a dollar sign.
529</li>
530
Rob Pikee71276c2015-07-09 10:10:12 +1000531<li>
532The <code>get</code> subcommand now has a <code>-insecure</code>
533flag that must be enabled if fetching from an insecure repository, one that
534does not encrypt the connection.
535</li>
536
Rob Pikeef371842015-07-06 09:01:32 +1000537</ul>
538
539<h3 id="vet_command">Go vet command</h3>
540
541<p>
542The <a href="/cmd/vet"><code>go tool vet</code></a> command now does
543more thorough validation of struct tags.
544</p>
545
546<h3 id="trace_command">Trace command</h3>
547
Rob Pike6163cf82015-07-16 14:45:46 +1000548<p>
549A new tool is available for dynamic execution tracing of Go programs.
550The usage is analogous to how the test coverage tool works.
551Generation of traces is integrated into <code>go test</code>,
552and then a separate execution of the tracing tool itself analyzes the results:
553</p>
554
Rob Pikeef371842015-07-06 09:01:32 +1000555<pre>
Rob Pike6163cf82015-07-16 14:45:46 +1000556$ go test -trace=trace.out path/to/package
557$ go tool trace [flags] pkg.test trace.out
Rob Pikeef371842015-07-06 09:01:32 +1000558</pre>
559
Rob Pike6163cf82015-07-16 14:45:46 +1000560<p>
561The flags enable the output to be displayed in a browser window.
562For details, run <code>go tool trace -help</code>.
563There is also a description of the tracing facility in this
564<a href="https://talks.golang.org/2015/dynamic-tools.slide">talk</a>
565from GopherCon 2015.
566</p>
567
Rob Pikeef371842015-07-06 09:01:32 +1000568<h3 id="doc_command">Go doc command</h3>
569
570<p>
571A few releases back, the <code>go doc</code>
572command was deleted as being unnecessary.
573One could always run "<code>godoc .</code>" instead.
574The 1.5 release introduces a new <a href="/cmd/doc"><code>go doc</code></a>
575command with a more convenient command-line interface than
576<code>godoc</code>'s.
577It is designed for command-line usage specifically, and provides a more
578compact and focused presentation of the documentation for a package
579or its elements, according to the invocation.
580It also provides case-insensitive matching and
581support for showing the documentation for unexported symbols.
582For details run "<code>go help doc</code>".
583</p>
584
585<h3 id="cgo">Cgo</h3>
586
587<p>
588When parsing <code>#cgo</code> lines,
589the invocation <code>${SRCDIR}</code> is now
590expanded into the path to the source directory.
591This allows options to be passed to the
592compiler and linker that involve file paths relative to the
593source code directory. Without the expansion the paths would be
594invalid when the current working directory changes.
595</p>
596
597<p>
598On Windows, cgo now uses external linking by default.
599</p>
600
601<h2 id="performance">Performance</h2>
602
603<p>
604As always, the changes are so general and varied that precise statements
605about performance are difficult to make.
606The changes are even broader ranging than usual in this release, which
607includes a new garbage collector and a conversion of the runtime to Go.
608Some programs may run faster, some slower.
609On average the programs in the Go 1 benchmark suite run a few percent faster in Go 1.5
610than they did in Go 1.4,
611while as mentioned above the garbage collector's pauses are
612dramatically shorter, and almost always under 10 milliseconds.
613</p>
614
615<p>
616Builds in Go 1.5 will be slower by a factor of about two.
617The automatic translation of the compiler and linker from C to Go resulted in
618unidiomatic Go code that performs poorly compared to well-written Go.
619Analysis tools and refactoring helped to improve the code, but much remains to be done.
620Further profiling and optimization will continue in Go 1.6 and future releases.
621For more details, see these <a href="https://talks.golang.org/2015/gogo.slide">slides</a>
622and associated <a href="https://www.youtube.com/watch?v=cF1zJYkBW4A">video</a>.
623</p>
624
625<h2 id="library">Core library</h2>
Rob Pike6fe9c4a2015-07-01 08:48:19 +1000626
627<h3 id="flag">Flag</h3>
628
629<p>
630The flag package's
Rob Pike902345e2015-07-14 15:20:19 +1000631<a href="/pkg/flag/#PrintDefaults"><code>PrintDefaults</code></a>
Rob Pike6fe9c4a2015-07-01 08:48:19 +1000632function, and method on <a href="/pkg/flag/#FlagSet"><code>FlagSet</code></a>,
633have been modified to create nicer usage messages.
634The format has been changed to be more human-friendly and in the usage
635messages a word quoted with `backquotes` is taken to be the name of the
636flag's operand to display in the usage message.
637For instance, a flag created with the invocation,
638</p>
639
640<pre>
641cpuFlag = flag.Int("cpu", 1, "run `N` processes in parallel")
642</pre>
643
644<p>
645will show the help message,
646</p>
647
648<pre>
649-cpu N
650 run N processes in parallel (default 1)
651</pre>
652
653<p>
654Also, the default is now listed only when it is not the zero value for the type.
655</p>
656
657<h3 id="math_big">Floats in math/big</h3>
658
659<p>
660The <a href="/pkg/math/big/"><code>math/big</code></a> package
661has a new, fundamental data type,
662<a href="/pkg/math/big/#Float"><code>Float</code></a>,
663which implements arbitrary-precision floating-point numbers.
664A <code>Float</code> value is represented by a boolean sign,
665a variable-length mantissa, and a 32-bit fixed-size signed exponent.
666The precision of a <code>Float</code> (the mantissa size in bits)
667can be specified explicitly or is otherwise determined by the first
668operation that creates the value.
669Once created, the size of a <code>Float</code>'s mantissa may be modified with the
670<a href="/pkg/math/big/#Float.SetPrec"><code>SetPrec</code></a> method.
671<code>Floats</code> support the concept of infinities, such as are created by
672overflow, but values that would lead to the equivalent of IEEE 754 NaNs
673trigger a panic.
674<code>Float</code> operations support all IEEE-754 rounding modes.
675When the precision is set to 24 (53) bits,
676operations that stay within the range of normalized <code>float32</code>
677(<code>float64</code>)
678values produce the same results as the corresponding IEEE-754
679arithmetic on those values.
680</p>
681
Rob Pikecd2e2f62015-07-01 15:49:40 +1000682<h3 id="go_types">Go types</h3>
683
684<p>
685The <a href="/pkg/go/types/"><code>go/types</code></a> package
686up to now has been maintained in the <code>golang.org/x</code>
687repository; as of Go 1.5 it has been relocated to the main repository.
688The code at the old location is now deprecated.
689There is also a modest API change in the package, discussed below.
690</p>
691
692<p>
693Associated with this move, the
694<a href="/pkg/go/constant/"><code>go/constant</code></a>
695package also moved to the main repository;
696it was <code>golang.org/x/tools/exact</code> before.
697The <a href="/pkg/go/importer/"><code>go/importer</code></a> package
698also moved to the main repository,
699as well as some tools described above.
700</p>
701
702<h3 id="net">Net</h3>
703
704<p>
705The DNS resolver in the net package has almost always used <code>cgo</code> to access
706the system interface.
707A change in Go 1.5 means that on most Unix systems DNS resolution
708will no longer require <code>cgo</code>, which simplifies execution
709on those platforms.
710Now, if the system's networking configuration permits, the native Go resolver
711will suffice.
712The important effect of this change is that each DNS resolution occupies a goroutine
713rather than a thread,
714so a program with multiple outstanding DNS requests will consume fewer operating
715system resources.
716</p>
717
718<p>
719The decision of how to run the resolver applies at run time, not build time.
720The <code>netgo</code> build tag that has been used to enforce the use
721of the Go resolver is no longer necessary, although it still works.
Brad Fitzpatrick60315002015-07-17 09:25:45 -0700722A new <code>netcgo</code> build tag forces the use of the <code>cgo</code> resolver at
723build time.
724To force <code>cgo</code> resolution at run time set
725<code>GODEBUG=netdns=cgo</code> in the environment.
726More debug options are documented <a href="https://golang.org/cl/11584">here</a>.
Rob Pikecd2e2f62015-07-01 15:49:40 +1000727</p>
728
729<p>
730This change applies to Unix systems only.
731Windows, Mac OS X, and Plan 9 systems behave as before.
732</p>
733
Rob Pike6fe9c4a2015-07-01 08:48:19 +1000734<h3 id="reflect">Reflect</h3>
735
736<p>
737The <a href="/pkg/reflect/"><code>reflect</code></a> package
738has two new functions: <a href="/pkg/reflect/#ArrayOf"><code>ArrayOf</code></a>
739and <a href="/pkg/reflect/#FuncOf"><code>FuncOf</code></a>.
740These functions, analogous to the extant
Rob Pikecd2e2f62015-07-01 15:49:40 +1000741<a href="/pkg/reflect/#SliceOf"><code>SliceOf</code></a> function,
Rob Pike6fe9c4a2015-07-01 08:48:19 +1000742create new types at runtime to describe arrays and functions.
743</p>
744
745<h3 id="hardening">Hardening</h3>
746
747<p>
748Several dozen bugs were found in the standard library
749through randomized testing with the
750<a href="https://github.com/dvyukov/go-fuzz"><code>go-fuzz</code></a> tool.
751Bugs were fixed in the
752<a href="/pkg/archive/tar/"><code>archive/tar</code></a>,
753<a href="/pkg/archive/zip/"><code>archive/zip</code></a>,
754<a href="/pkg/compress/flate/"><code>compress/flate</code></a>,
755<a href="/pkg/encoding/gob/"><code>encoding/gob</code></a>,
756<a href="/pkg/fmt/"><code>fmt</code></a>,
757<a href="/pkg/html/template/"><code>html/template</code></a>,
758<a href="/pkg/image/gif/"><code>image/gif</code></a>,
759<a href="/pkg/image/jpeg/"><code>image/jpeg</code></a>,
760<a href="/pkg/image/png/"><code>image/png</code></a>, and
761<a href="/pkg/text/template/"><code>text/template</code></a>,
762packages.
763The fixes harden the implementation against incorrect and malicious inputs.
764</p>
765
Rob Pike751eef82015-06-25 16:20:27 +1000766<h3 id="minor_library_changes">Minor changes to the library</h3>
767
768<ul>
769
770<li>
Rob Pikec418fe72015-06-29 19:51:56 +1000771The <a href="/pkg/archive/zip/"><code>archive/zip</code></a> package's
772<a href="/pkg/archive/zip/#Writer"><code>Writer</code></a> type now has a
773<a href="/pkg/archive/zip/#Writer.SetOffset"><code>SetOffset</code></a>
774method to specify the location within the output stream at which to write the archive.
Rob Pike751eef82015-06-25 16:20:27 +1000775</li>
776
777<li>
Rob Pikec418fe72015-06-29 19:51:56 +1000778The <a href="/pkg/bufio/#Reader"><code>Reader</code></a> in the
779<a href="/pkg/bufio/"><code>bufio</code></a> package now has a
780<a href="/pkg/bufio/#Reader.Discard"><code>Discard</code></a>
781method to discard data from the input.
Rob Pike751eef82015-06-25 16:20:27 +1000782</li>
783
784<li>
Rob Pikec418fe72015-06-29 19:51:56 +1000785Also in the <a href="/pkg/bytes/"><code>bytes</code></a> package,
786the <a href="/pkg/bytes/#Buffer"><code>Buffer</code></a> type
787now has a <a href="/pkg/bytes/#Buffer.Cap"><code>Cap</code></a> method
788that reports the number of bytes allocated within the buffer.
Brad Fitzpatrickaee4f422015-07-20 19:46:12 -0700789Similarly, in both the <a href="/pkg/bytes/"><code>bytes</code></a>
Rob Pikec418fe72015-06-29 19:51:56 +1000790and <a href="/pkg/strings/"><code>strings</code></a> packages,
791the <a href="/pkg/bytes/#Reader"><code>Reader</code></a>
792type now has a <a href="/pkg/bytes/#Reader.Size"><code>Size</code></a>
793method that reports the original length of the underlying slice or string.
Rob Pike751eef82015-06-25 16:20:27 +1000794</li>
795
796<li>
Rob Pikec418fe72015-06-29 19:51:56 +1000797Both the <a href="/pkg/bytes/"><code>bytes</code></a> and
798<a href="/pkg/strings/"><code>strings</code></a> packages
799also now have a <a href="/pkg/bytes/#LastIndexByte"><code>LastIndexByte</code></a>
800function that locates the rightmost byte with that value in the argument.
Rob Pike751eef82015-06-25 16:20:27 +1000801</li>
802
803<li>
Rob Pike09b54632015-07-02 12:56:51 +1000804The <a href="/pkg/crypto/"><code>crypto</code></a> package
805has a new interface, <a href="/pkg/crypto/#Decrypter"><code>Decrypter</code></a>,
806that abstracts the behavior of a private key used in asymmetric decryption.
Rob Pike751eef82015-06-25 16:20:27 +1000807</li>
808
809<li>
Rob Pike09b54632015-07-02 12:56:51 +1000810In the <a href="/pkg/crypto/cipher/"><code>crypto/cipher</code></a> package,
811the documentation for the <a href="/pkg/crypto/cipher/#Stream"><code>Stream</code></a>
812interface has been clarified regarding the behavior when the source and destination are
813different lengths.
814If the destination is shorter than the source, the method will panic.
815This is not a change in the implementation, only the documentation.
Rob Pike751eef82015-06-25 16:20:27 +1000816</li>
817
818<li>
Rob Pike09b54632015-07-02 12:56:51 +1000819Also in the <a href="/pkg/crypto/cipher/"><code>crypto/cipher</code></a> package,
820there is now support for nonce lengths other than 96 bytes in AES's Galois/Counter mode (GCM),
821which some protocols require.
Rob Pike751eef82015-06-25 16:20:27 +1000822</li>
823
824<li>
Rob Pike09b54632015-07-02 12:56:51 +1000825In the <a href="/pkg/crypto/elliptic/"><code>crypto/elliptic</code></a> package,
826there is now a <code>Name</code> field in the
827<a href="/pkg/crypto/elliptic/#CurveParams"><code>CurveParams</code></a> struct,
828and the curves implemented in the package have been given names.
829These names provide a safer way to select a curve, as opposed to
830selecting its bit size, for cryptographic systems that are curve-dependent.
Rob Pike751eef82015-06-25 16:20:27 +1000831</li>
832
833<li>
Rob Pike09b54632015-07-02 12:56:51 +1000834Also in the <a href="/pkg/crypto/elliptic/"><code>crypto/elliptic</code></a> package,
835the <a href="/pkg/crypto/elliptic/#Unmarshal"><code>Unmarshal</code></a> function
836now verifies that the point is actually on the curve.
837(If it is not, the function returns nils).
838This change guards against certain attacks.
Rob Pike751eef82015-06-25 16:20:27 +1000839</li>
840
841<li>
Brad Fitzpatrick1b5eaa42015-07-20 15:14:01 -0700842The <a href="/pkg/crypto/sha512/"><code>crypto/sha512</code></a>
843package now has support for the two truncated versions of
844the SHA-512 hash algorithm, SHA-512/224 and SHA-512/256.
845</li>
846
847<li>
Rob Pike09b54632015-07-02 12:56:51 +1000848The <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> package
Jonathan Rudenbergaed74b92015-07-14 19:16:01 -0400849minimum protocol version now defaults to TLS 1.0.
Rob Pike09b54632015-07-02 12:56:51 +1000850The old default, SSLv3, is still available through <a href="/pkg/crypto/tls/#Config"><code>Config</code></a> if needed.
Rob Pike751eef82015-06-25 16:20:27 +1000851</li>
852
853<li>
Jonathan Rudenbergaed74b92015-07-14 19:16:01 -0400854The <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> package
Rob Pike09b54632015-07-02 12:56:51 +1000855now supports Signed Certificate Timestamps (SCTs) as specified in RFC 6962.
856The server serves them if they are listed in the
857<a href="/pkg/crypto/tls/#Certificate"><code>Certificate</code></a> struct,
Rob Pikeef371842015-07-06 09:01:32 +1000858and the client requests them and exposes them, if present,
Rob Pike09b54632015-07-02 12:56:51 +1000859in its <a href="/pkg/crypto/tls/#ConnectionState"><code>ConnectionState</code></a> struct.
Jonathan Rudenbergaed74b92015-07-14 19:16:01 -0400860
861<li>
862The stapled OCSP response to a <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> client connection,
863previously only available via the
864<a href="/pkg/crypto/tls/#Conn.OCSPResponse"><code>OCSPResponse</code></a> method,
865is now exposed in the <a href="/pkg/crypto/tls/#ConnectionState"><code>ConnectionState</code></a> struct.
866</li>
867
868<li>
869The <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> server implementation
870will now always call the
Rob Pike09b54632015-07-02 12:56:51 +1000871<code>GetCertificate</code> function in
872the <a href="/pkg/crypto/tls/#Config"><code>Config</code></a> struct
873to select a certificate for the connection when none is supplied.
Rob Pike751eef82015-06-25 16:20:27 +1000874</li>
875
876<li>
Rob Pike09b54632015-07-02 12:56:51 +1000877Finally, the session ticket keys in the
878<a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> package
Jonathan Rudenbergaed74b92015-07-14 19:16:01 -0400879can now be changed while the server is running.
Rob Pike902345e2015-07-14 15:20:19 +1000880This is done through the new
Rob Pike09b54632015-07-02 12:56:51 +1000881<a href="/pkg/crypto/tls/#Config.SetSessionTicketKeys"><code>SetSessionTicketKeys</code></a>
882method of the
883<a href="/pkg/crypto/tls/#Config"><code>Config</code></a> type.
Rob Pike751eef82015-06-25 16:20:27 +1000884</li>
885
886<li>
Rob Pike09b54632015-07-02 12:56:51 +1000887In the <a href="/pkg/crypto/x509/"><code>crypto/x509</code></a> package,
888wildcards are now accepted only in the leftmost label as defined in
889<a href="https://tools.ietf.org/html/rfc6125#section-6.4.3">the specification</a>.
Rob Pike751eef82015-06-25 16:20:27 +1000890</li>
891
892<li>
Rob Pike09b54632015-07-02 12:56:51 +1000893Also in the <a href="/pkg/crypto/x509/"><code>crypto/x509</code></a> package,
894the handling of unknown critical extensions has been changed.
895They used to cause parse errors but now they are parsed and caused errors only
896in <a href="/pkg/crypto/x509/#Certificate.Verify"><code>Verify</code></a>.
897The new field <code>UnhandledCriticalExtensions</code> of
898<a href="/pkg/crypto/x509/#Certificate"><code>Certificate</code></a> records these extensions.
Rob Pike751eef82015-06-25 16:20:27 +1000899</li>
900
901<li>
Rob Pikec418fe72015-06-29 19:51:56 +1000902The <a href="/pkg/database/sql/#DB"><code>DB</code></a> type of the
903<a href="/pkg/database/sql/"><code>database/sql</code></a> package
904now has a <a href="/pkg/database/sql/#DB.Stats"><code>Stats</code></a> method
905to retrieve database statistics.
Rob Pike751eef82015-06-25 16:20:27 +1000906</li>
907
908<li>
Rob Pike09b54632015-07-02 12:56:51 +1000909The <a href="/pkg/debug/dwarf/"><code>debug/dwarf</code></a>
910package has extensive additions to better support DWARF version 4.
911See for example the definition of the new type
912<a href="/pkg/debug/dwarf/#Class"><code>Class</code></a>.
913</li>
914
915<li>
916The <a href="/pkg/debug/elf/"><code>debug/elf</code></a>
917package now has support for the 64-bit Power architecture.
918</li>
919
920<li>
Rob Pikec418fe72015-06-29 19:51:56 +1000921The <a href="/pkg/encoding/base64/"><code>encoding/base64</code></a> package
922now supports unpadded encodings through two new encoding variables,
923<a href="/pkg/encoding/base64/#RawStdEncoding"><code>RawStdEncoding</code></a> and
924<a href="/pkg/encoding/base64/#RawURLEncoding"><code>RawURLEncoding</code></a>.
Rob Pike751eef82015-06-25 16:20:27 +1000925</li>
926
927<li>
Rob Pike09b54632015-07-02 12:56:51 +1000928The <a href="/pkg/encoding/json/"><code>encoding/json</code></a> package
929now returns an <a href="/pkg/encoding/json/#UnmarshalTypeError"><code>UnmarshalTypeError</code></a>
930if a JSON value is not appropriate for the target variable or component
931to which it is being unmarshaled.
932</li>
933
934<li>
Rob Pikeff991942015-07-29 09:43:32 +1000935The <code>encoding/json</code>'s
936<a href="/pkg/encoding/json/#Decoder"><code>Decoder</code></a>
937type has a new method that provides a streaming interface for decoding
938a JSON document:
939<a href="/pkg/encoding/json/#Decoder.Token"><code>Token</code></a>.
940It also interoperates with the existing functionality of <code>Decode</code>,
941which will continue a decode operation already started with <code>Decoder.Token</code>.
942</li>
943
944<li>
Rob Pike09b54632015-07-02 12:56:51 +1000945The <a href="/pkg/flag/"><code>flag</code></a> package
946has a new function, <a href="/pkg/flag/#UnquoteUsage"><code>UnquoteUsage</code></a>,
947to assist in the creation of usage messages using the new convention
948described above.
949</li>
950
951<li>
Jonathan Rudenbergf4b4c882015-07-14 19:22:24 -0400952In the <a href="/pkg/fmt/"><code>fmt</code></a> package,
Rob Pike0ea3f582015-06-26 11:52:21 +1000953a value of type <a href="/pkg/reflect/#Value"><code>Value</code></a> now
954prints what it holds, rather than use the <code>reflect.Value</code>'s <code>Stringer</code>
955method, which produces things like <code>&lt;int Value&gt;</code>.
Rob Pike751eef82015-06-25 16:20:27 +1000956</li>
957
958<li>
Rob Pikec418fe72015-06-29 19:51:56 +1000959The <a href="/pkg/ast/#EmptyStmt"><code>EmptyStmt</code></a> type
960in the <a href="/pkg/go/ast/"><code>go/ast</code></a> package now
961has a boolean <code>Implicit</code> field that records whether the
962semicolon was implicitly added or was present in the source.
Rob Pike751eef82015-06-25 16:20:27 +1000963</li>
964
965<li>
Rob Pike0ea3f582015-06-26 11:52:21 +1000966For forward compatibility the <a href="/pkg/go/build/"><code>go/build</code></a> package
967reserves <code>GOARCH</code> values for a number of architectures that Go might support one day.
968This is not a promise that it will.
Rob Pike09b54632015-07-02 12:56:51 +1000969Also, the <a href="/pkg/go/build/#Package"><code>Package</code></a> struct
970now has a <code>PkgTargetRoot</code> field that stores the
971architecture-dependent root directory in which to install, if known.
Rob Pike751eef82015-06-25 16:20:27 +1000972</li>
973
974<li>
Rob Pikecd2e2f62015-07-01 15:49:40 +1000975The (newly migrated) <a href="/pkg/go/types/"><code>go/types</code></a>
976package allows one to control the prefix attached to package-level names using
977the new <a href="/pkg/go/types/#Qualifier"><code>Qualifier</code></a>
978function type as an argument to several functions. This is an API change for
979the package, but since it is new to the core, it is not breaking the Go 1 compatibility
980rules since code that uses the package must explicitly ask for it at its new location.
Rob Pike6163cf82015-07-16 14:45:46 +1000981To update, run
982<a href="https://golang.org/cmd/go/#hdr-Run_go_tool_fix_on_packages"><code>go fix</code></a> on your package.
Rob Pikecd2e2f62015-07-01 15:49:40 +1000983</li>
984
985<li>
Rob Pike09b54632015-07-02 12:56:51 +1000986In the <a href="/pkg/image/"><code>image</code></a> package,
987the <a href="/pkg/image/#Rectangle"><code>Rectangle</code></a> type
988now implements the <a href="/pkg/image/#Image"><code>Image</code></a> interface,
989mask image when drawing.
990</li>
991
992<li>
993Also in the <a href="/pkg/image/"><code>image</code></a> package,
994to assist in the handling of some JPEG images,
995there is now support for 4:1:1 and 4:1:0 YCbCr subsampling and basic
996CMYK support, represented by the new image.CMYK struct.
997</li>
998
999<li>
1000The <a href="/pkg/image/color/"><code>image/color</code></a> package
1001adds basic CMYK support, through the new
1002<a href="/pkg/image/color/#CMYK"><code>CMYK</code></a> struct,
1003the <a href="/pkg/image/color/#CMYKModel"><code>CMYKModel</code></a> color model, and the
1004<a href="/pkg/image/color/#CMYKToRGB"><code>CMYKToRGB</code></a> function, as
1005needed by some JPEG images.
1006</li>
1007
1008<li>
Rob Pike902345e2015-07-14 15:20:19 +10001009Also in the <a href="/pkg/image/color/"><code>image/color</code></a> package,
1010the conversion of a <a href="/pkg/image/color/#YCbCr"><code>YCbCr</code></a>
1011value to <code>RGBA</code> has become more precise.
1012Previously, the low 8 bits were just an echo of the high 8 bits;
1013now they contain more accurate information.
1014Because of the echo property of the old code, the operation
Ian Lance Taylor443ec4f2015-07-14 08:14:03 -07001015<code>uint8(r)</code> to extract an 8-bit red value worked, but is incorrect.
Rob Pike902345e2015-07-14 15:20:19 +10001016In Go 1.5, that operation may yield a different value.
1017The correct code is, and always was, to select the high 8 bits:
1018<code>uint8(r&gt;&gt;8)</code>.
1019Incidentally, <code>image/draw</code> package
1020provides better support for such conversions; see
1021<a href="https://blog.golang.org/go-imagedraw-package">this blog post</a>
1022for more information.
1023</li>
1024
1025<li>
1026Finally, as of Go 1.5 the closest match check in
1027<a href="/pkg/image/color/#Palette.Index"><code>Index</code></a>
1028now honors the alpha channel.
1029</li>
1030
1031<li>
Rob Pike09b54632015-07-02 12:56:51 +10001032The <a href="/pkg/image/gif/"><code>image/gif</code></a> package
1033includes a couple of generalizations.
1034A multiple-frame GIF file can now have an overall bounds different
1035from all the contained single frames' bounds.
1036Also, the <a href="/pkg/image/gif/#GIF"><code>GIF</code></a> struct
1037now has a <code>Disposal</code> field
1038that specifies the disposal method for each frame.
1039</li>
1040
1041<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001042The <a href="/pkg/io/"><code>io</code></a> package
1043adds a <a href="/pkg/io/#CopyBuffer"><code>CopyBuffer</code></a> function
1044that is like <a href="/pkg/io/#Copy"><code>Copy</code></a> but
1045uses a caller-provided buffer, permitting control of allocation and buffer size.
Rob Pike751eef82015-06-25 16:20:27 +10001046</li>
1047
1048<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001049The <a href="/pkg/log/"><code>log</code></a> package
1050has a new <a href="/pkg/log/#LUTC"><code>LUTC</code></a> flag
1051that causes time stamps to be printed in the UTC time zone.
1052It also adds a <a href="/pkg/log/#SetOutput"><code>SetOutput</code></a> function
1053to set the output destination for the standard logger
1054and a corresponding method for user-created loggers.
Rob Pike751eef82015-06-25 16:20:27 +10001055</li>
1056
1057<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001058In Go 1.4, <a href="/pkg/math/#Max"><code>Max</code></a> was not detecting all possible NaN bit patterns.
1059This is fixed in Go 1.5, so programs that use <code>math.Max</code> on data including NaNs may behave differently,
1060but now correctly according to the IEEE754 definition of NaNs.
Rob Pike751eef82015-06-25 16:20:27 +10001061</li>
1062
1063<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001064The <a href="/pkg/math/big/"><code>math/big</code></a> package
1065adds a new <a href="/pkg/math/big/#Jacobi"><code>Jacobi</code></a>
1066function for integers and a new method
1067<a href="/pkg/math/big/#Int.ModSqrt"><code>ModSqrt</code></a>
1068method for the <a href="/pkg/math/big/#Int"><code>Int</code></a> type.
Rob Pike751eef82015-06-25 16:20:27 +10001069</li>
1070
1071<li>
Rob Pike09b54632015-07-02 12:56:51 +10001072The mime package
1073adds a new <a href="/pkg/mime/#WordDecoder"><code>WordDecoder</code></a> type
1074to decode MIME headers containing RFC 204-encoded words.
1075It also provides <a href="/pkg/mime/#BEncoding"><code>BEncoding</code></a> and
1076<a href="/pkg/mime/#QEncoding"><code>QEncoding</code></a>
1077as implementations of the encoding schemes of RFC 2045 and RFC 2047.
1078</li>
1079
1080<li>
1081The <a href="/pkg/mime/"><code>mime</code></a> package also adds an
Rob Pikec418fe72015-06-29 19:51:56 +10001082<a href="/pkg/mime/#ExtensionsByType"><code>ExtensionsByType</code></a>
1083function that returns the MIME extensions know to be associated with a given MIME type.
Rob Pike751eef82015-06-25 16:20:27 +10001084</li>
1085
1086<li>
Rob Pike6fe9c4a2015-07-01 08:48:19 +10001087There is a new <a href="/pkg/mime/quotedprintable/"><code>mime/quotedprintable</code></a>
1088package that implements the quoted-printable encoding defined by RFC 2045.
1089</li>
1090
1091<li>
Paul Marksabf943a2015-07-17 14:23:26 -07001092The <a href="/pkg/net/"><code>net</code></a> package will now
1093<a href="/pkg/net/#Dial"><code>Dial</code></a> hostnames by trying each
1094IP address in order until one succeeds.
1095The <code><a href="/pkg/net/#Dialer">Dialer</a>.DualStack</code>
1096mode now implements Happy Eyeballs
1097(<a href="https://tools.ietf.org/html/rfc6555">RFC 6555</a>) by giving the
1098first address family a 300ms head start; this value can be overridden by
1099the new <code>Dialer.FallbackDelay</code>.
Rob Pike751eef82015-06-25 16:20:27 +10001100</li>
1101
1102<li>
Rob Pikecd2e2f62015-07-01 15:49:40 +10001103A number of inconsistencies in the types returned by errors in the
1104<a href="/pkg/net/"><code>net</code></a> package have been
1105tidied up.
1106Most now return an
1107<a href="/pkg/net/#OpError"><code>OpError</code></a> value
1108with more information than before.
1109Also, the <a href="/pkg/net/#OpError"><code>OpError</code></a>
1110type now includes a <code>Source</code> field that holds the local
1111network address.
Rob Pike751eef82015-06-25 16:20:27 +10001112</li>
1113
1114<li>
Rob Pikecd2e2f62015-07-01 15:49:40 +10001115The <a href="/pkg/net/http/"><code>net/http</code></a> package now
1116has support for setting trailers from a server <a href="/pkg/net/http/#Handler"><code>Handler</code></a>.
1117For details, see the documentation for
1118<a href="/pkg/net/http/#ResponseWriter"><code>ResponseWriter</code></a>.
Rob Pike751eef82015-06-25 16:20:27 +10001119</li>
1120
1121<li>
Brad Fitzpatricke28ff1f2015-07-20 12:30:06 -07001122There is a new method to cancel a <a href="/pkg/net/http/"><code>net/http</code></a>
1123<code>Request</code> by setting the new
1124<a href="/pkg/net/http/#Request"><code>Request.Cancel</code></a>
1125field.
1126It is supported by <code>http.Transport</code>.
1127The <code>Cancel</code> field's type is compatible with the
1128<a href="https://godoc.org/golang.org/x/net/context"><code>context.Context.Done</code></a>
1129return value.
1130</li>
1131
1132<li>
Rob Pikecd2e2f62015-07-01 15:49:40 +10001133Also in the <a href="/pkg/net/http/"><code>net/http</code></a> package,
1134there is code to ignore the zero <a href="/pkg/time/#Time"><code>Time</code></a> value
1135in the <a href="/pkg/net/#ServeContent"><code>ServeContent</code></a> function.
1136As of Go 1.5, it now also ignores a time value equal to the Unix epoch.
Rob Pike751eef82015-06-25 16:20:27 +10001137</li>
1138
1139<li>
Rob Pike09b54632015-07-02 12:56:51 +10001140The <a href="/pkg/net/http/fcgi/"><code>net/http/fcgi</code></a> package
1141exports two new errors,
1142<a href="/pkg/net/http/fcgi/#ErrConnClosed"><code>ErrConnClosed</code></a> and
1143<a href="/pkg/net/http/fcgi/#ErrRequestAborted"><code>ErrRequestAborted</code></a>,
1144to report the corresponding error conditions.
1145</li>
1146
1147<li>
Rob Pikecd2e2f62015-07-01 15:49:40 +10001148The <a href="/pkg/net/http/cgi/"><code>net/http/cgi</code></a> package
1149had a bug that mishandled the values of the environment variables
1150<code>REMOTE_ADDR</code> ad <code>REMOTE_HOST</code>.
1151This has been fixed.
1152Also, starting with Go 1.5 the package sets the <code>REMOTE_PORT</code>
1153variable.
Rob Pike751eef82015-06-25 16:20:27 +10001154</li>
1155
1156<li>
Rob Pikecd2e2f62015-07-01 15:49:40 +10001157The <a href="/pkg/net/mail/"><code>net/mail</code></a> package
1158adds a <a href="/pkg/net/mail/#AddressParser"><code>AddressParser</code></a>
1159type that can parse mail addresses.
Rob Pike751eef82015-06-25 16:20:27 +10001160</li>
1161
1162<li>
Rob Pikecd2e2f62015-07-01 15:49:40 +10001163The <a href="/pkg/net/smtp/"><code>net/smtp</code></a> package
1164now has a <a href="/pkg/net/smtp/#Client.TLSConnectionState"><code>TLSConnectionState</code></a>
1165accessor to the <a href="/pkg/net/smtp/#Client"><code>Client</code></a>
1166type that returns the client's TLS state.
Rob Pike751eef82015-06-25 16:20:27 +10001167</li>
1168
1169<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001170The <a href="/pkg/os/"><code>os</code></a> package
1171has a new <a href="/pkg/os/#LookupEnv"><code>LookupEnv</code></a> function
1172that is similar to <a href="/pkg/os/#Getenv"><code>Getenv</code></a>
1173but can distinguish between an empty environment variable and a missing one.
Rob Pike751eef82015-06-25 16:20:27 +10001174</li>
1175
1176<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001177The <a href="/pkg/os/signal/"><code>os/signal</code></a> package
1178adds new <a href="/pkg/os/signal/#Ignore"><code>Ignore</code></a> and
1179<a href="/pkg/os/signal/#Reset"><code>Reset</code></a> functions.
Rob Pike751eef82015-06-25 16:20:27 +10001180</li>
1181
1182<li>
Rob Pike09b54632015-07-02 12:56:51 +10001183The <a href="/pkg/runtime/"><code>runtime</code></a>,
1184<a href="/pkg/runtime/pprof/"><code>runtime/pprof</code></a>,
1185and <a href="/pkg/net/http/pprof/"><code>net/http/pprof</code></a> packages
1186each have new functions to support the tracing facilities described above:
1187<a href="/pkg/runtime/#ReadTrace"><code>ReadTrace</code></a>,
1188<a href="/pkg/runtime/#StartTrace"><code>StartTrace</code></a>,
1189<a href="/pkg/runtime/#StopTrace"><code>StopTrace</code></a>,
1190<a href="/pkg/runtime/pprof/#StartTrace"><code>StartTrace</code></a>,
1191<a href="/pkg/runtime/pprof/#StopTrace"><code>StopTrace</code></a>, and
1192<a href="/pkg/net/http/pprof/#Trace"><code>Trace</code></a>.
1193See the respective documentation for details.
1194</li>
1195
1196<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001197The <a href="/pkg/runtime/pprof/"><code>runtime/pprof</code></a> package
1198by default now includes overall memory statistics in all memory profiles.
Rob Pike751eef82015-06-25 16:20:27 +10001199</li>
1200
1201<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001202The <a href="/pkg/strings/"><code>strings</code></a> package
1203has a new <a href="/pkg/strings/#Compare"><code>Compare</code></a> function.
1204This is present to provide symmetry with the <a href="/pkg/bytes/"><code>bytes</code></a> package
1205but is otherwise unnecessary as strings support comparison natively.
Rob Pike751eef82015-06-25 16:20:27 +10001206</li>
1207
1208<li>
Rob Pikec418fe72015-06-29 19:51:56 +10001209The <a href="/pkg/sync/#WaitGroup"><code>WaitGroup</code></a> function in
1210package <a href="/pkg/sync/"><code>sync</code></a>
1211now diagnoses code that races a call to <a href="/pkg/sync/#WaitGroup.Add"><code>Add</code></a>
1212against a return from <a href="/pkg/sync/#WaitGroup.Wait"><code>Wait</code></a>.
1213If it detects this condition, <code>WaitGroup</code> panics.
1214</li>
1215
1216<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001217In the <a href="/pkg/syscall/"><code>syscall</code></a> package,
1218the Linux <code>SysProcAttr</code> struct now has a
1219<code>GidMappingsEnableSetgroups</code> field, made necessary
1220by security changes in Linux 3.19.
1221On all Unix systems, the struct also has new <code>Foreground</code> and <code>Pgid</code> fields
1222to provide more control when exec'ing.
1223On Darwin, there is now a <code>Syscall9</code> function
1224to support calls with too many arguments.
Rob Pike751eef82015-06-25 16:20:27 +10001225</li>
1226
1227<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001228The <a href="/pkg/testing/quick/"><code>testing/quick</code></a> will now
1229generate <code>nil</code> values for pointer types,
1230making it possible to use with recursive data structures.
1231Also, the package now supports generation of array types.
Rob Pike751eef82015-06-25 16:20:27 +10001232</li>
1233
1234<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001235In the <a href="/pkg/text/template/"><code>text/template</code></a> and
1236<a href="/pkg/html/template/"><code>html/template</code></a> packages,
1237integer constants too large to be represented as a Go integer now trigger a
1238parse error. Before, they were silently converted to floating point, losing
1239precision.
Rob Pike751eef82015-06-25 16:20:27 +10001240</li>
1241
1242<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001243Also in the <a href="/pkg/text/template/"><code>text/template</code></a> and
1244<a href="/pkg/html/template/"><code>html/template</code></a> packages,
1245a new <a href="/pkg/text/template/#Option"><code>Option</code></a> type
1246allows customization of the behavior of the template during execution.
1247The sole implemented option allows control over how a missing key is
1248handled when indexing a map.
1249The default, which can now be overridden, is as before: to continue with an invalid value.
Rob Pike751eef82015-06-25 16:20:27 +10001250</li>
1251
1252<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001253The <a href="/pkg/time/"><code>time</code></a> package's
1254<code>Time</code> type has a new method
Rob Pike902345e2015-07-14 15:20:19 +10001255<a href="/pkg/time/#Time.AppendFormat"><code>AppendFormat</code></a>,
Rob Pike0ea3f582015-06-26 11:52:21 +10001256which can be used to avoid allocation when printing a time value.
Rob Pike751eef82015-06-25 16:20:27 +10001257</li>
1258
1259<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001260The <a href="/pkg/unicode/"><code>unicode</code></a> package and associated
1261support throughout the system has been upgraded from version 7.0 to
1262<a href="http://www.unicode.org/versions/Unicode8.0.0/">Unicode 8.0</a>.
Rob Pike751eef82015-06-25 16:20:27 +10001263</li>
1264
1265</ul>