blob: 2c77cf41697236c20cf8e15eeecbef3a0d428cc9 [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.
Rob Pike54eb9ef2015-08-19 13:44:33 +100086An example will make this clear.
87As of Go 1.5, this map literal,
Rob Pike751eef82015-06-25 16:20:27 +100088</p>
89
Rob Piked6ef6eb2015-06-25 14:36:49 +100090<pre>
Rob Pike751eef82015-06-25 16:20:27 +100091m := map[Point]string{
92 Point{29.935523, 52.891566}: "Persepolis",
93 Point{-25.352594, 131.034361}: "Uluru",
94 Point{37.422455, -122.084306}: "Googleplex",
95}
96</pre>
Brad Fitzpatrickfd2642b2015-01-18 16:00:10 -080097
Rob Pike751eef82015-06-25 16:20:27 +100098<p>
99may be written as follows, without the <code>Point</code> type listed explicitly:
100</p>
Robert Griesemer754bb712015-03-20 16:17:13 -0700101
Rob Pike751eef82015-06-25 16:20:27 +1000102<pre>
103m := map[Point]string{
104 {29.935523, 52.891566}: "Persepolis",
105 {-25.352594, 131.034361}: "Uluru",
106 {37.422455, -122.084306}: "Googleplex",
107}
108</pre>
Brad Fitzpatrickfd2642b2015-01-18 16:00:10 -0800109
Rob Pike751eef82015-06-25 16:20:27 +1000110<h2 id="implementation">The Implementation</h2>
Russ Coxcbbe9f62015-04-27 19:28:16 -0400111
Rob Pike751eef82015-06-25 16:20:27 +1000112<h3 id="c">No more C</h3>
Brad Fitzpatrickfb7e2442015-05-14 16:02:53 -0700113
Rob Pike751eef82015-06-25 16:20:27 +1000114<p>
115The compiler and runtime are now implemented in Go and assembler, without C.
116The only C source left in the tree is related to testing or to <code>cgo</code>.
117There was a C compiler in the tree in 1.4 and earlier.
118It was used to build the runtime; a custom compiler was necessary in part to
119guarantee the C code would work with the stack management of goroutines.
120Since 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 +1000121Details of the process to eliminate C are discussed <a href="https://golang.org/s/go13compiler">elsewhere</a>.
Rob Pike751eef82015-06-25 16:20:27 +1000122</p>
123
124<p>
125The conversion from C was done with the help of custom tools created for the job.
126Most important, the compiler was actually moved by automatic translation of
127the C code into Go.
128It is in effect the same program in a different language.
129It is not a new implementation
130of the compiler so we expect the process will not have introduced new compiler
131bugs.
132An overview of this process is available in the slides for
133<a href="https://talks.golang.org/2015/gogo.slide">this presentation</a>.
134</p>
135
Rob Pikeef371842015-07-06 09:01:32 +1000136<h3 id="compiler_and_tools">Compiler and tools</h3>
Rob Pike751eef82015-06-25 16:20:27 +1000137
138<p>
139Independent of but encouraged by the move to Go, the names of the tools have changed.
140The old names <code>6g</code>, <code>8g</code> and so on are gone; instead there
141is just one binary, accessible as <code>go</code> <code>tool</code> <code>compile</code>,
142that compiles Go source into binaries suitable for the architecture and operating system
143specified by <code>$GOARCH</code> and <code>$GOOS</code>.
Rob Pikec418fe72015-06-29 19:51:56 +1000144Similarly, there is now one linker (<code>go</code> <code>tool</code> <code>link</code>)
Rob Pike751eef82015-06-25 16:20:27 +1000145and one assembler (<code>go</code> <code>tool</code> <code>asm</code>).
146The linker was translated automatically from the old C implementation,
147but the assembler is a new native Go implementation discussed
148in more detail below.
149</p>
150
151<p>
152Similar to the drop of the names <code>6g</code>, <code>8g</code>, and so on,
153the output of the compiler and assembler are now given a plain <code>.o</code> suffix
154rather than <code>.8</code>, <code>.6</code>, etc.
155</p>
156
157
158<h3 id="gc">Garbage collector</h3>
159
160<p>
Rob Pikeef371842015-07-06 09:01:32 +1000161The garbage collector has been re-engineered for 1.5 as part of the development
162outlined in the <a href="https://golang.org/s/go14gc">design document</a>.
163Expected latencies are much lower than with the collector
164in prior releases, through a combination of advanced algorithms,
165better <a href="https://golang.org/s/go15gcpacing">scheduling</a> of the collector,
166and running more of the collection in parallel with the user program.
167The "stop the world" phase of the collector
168will almost always be under 10 milliseconds and usually much less.
169</p>
170
171<p>
172For systems that benefit from low latency, such as user-responsive web sites,
173the drop in expected latency with the new collector may be important.
174</p>
175
176<p>
Rob Pike6163cf82015-07-16 14:45:46 +1000177Details of the new collector were presented in a
178<a href="https://talks.golang.org/2015/go-gc.pdf">talk</a> at GopherCon 2015.
Rob Pike751eef82015-06-25 16:20:27 +1000179</p>
180
181<h3 id="runtime">Runtime</h3>
182
183<p>
184In Go 1.5, the order in which goroutines are scheduled has been changed.
185The properties of the scheduler were never defined by the language,
Rob Pike54eb9ef2015-08-19 13:44:33 +1000186but programs that depend on the scheduling order may be broken
Rob Pike751eef82015-06-25 16:20:27 +1000187by this change.
188We have seen a few (erroneous) programs affected by this change.
189If you have programs that implicitly depend on the scheduling
190order, you will need to update them.
191</p>
192
193<p>
194Another potentially breaking change is that the runtime now
195sets the default number of threads to run simultaneously,
196defined by <code>GOMAXPROCS</code>, to the number
197of cores available on the CPU.
Rob Pike54eb9ef2015-08-19 13:44:33 +1000198In prior releases the default was 1.
Rob Pike751eef82015-06-25 16:20:27 +1000199Programs that do not expect to run with multiple cores may
200break inadvertently.
201They can be updated by removing the restriction or by setting
Rob Pike902345e2015-07-14 15:20:19 +1000202<code>GOMAXPROCS</code> explicitly.
Ian Lance Taylord5f5e652015-08-03 12:35:59 -0700203For a more detailed discussion of this change, see
204the <a href="https://golang.org/s/go15gomaxprocs">design document</a>.
Rob Pike751eef82015-06-25 16:20:27 +1000205</p>
206
207<h3 id="build">Build</h3>
208
209<p>
210Now that the Go compiler and runtime are implemented in Go, a Go compiler
211must be available to compile the distribution from source.
212Thus, to build the Go core, a working Go distribution must already be in place.
213(Go programmers who do not work on the core are unaffected by this change.)
214Any Go 1.4 or later distribution (including <code>gccgo</code>) will serve.
Rob Pikeef371842015-07-06 09:01:32 +1000215For details, see the <a href="https://golang.org/s/go15bootstrap">design document</a>.
Rob Pike751eef82015-06-25 16:20:27 +1000216</p>
217
218<h2 id="ports">Ports</h2>
219
220<p>
Jonathan Rudenberg9e88f792015-07-14 18:53:13 -0400221Due mostly to the industry's move away from the 32-bit x86 architecture,
Rob Pike751eef82015-06-25 16:20:27 +1000222the set of binary downloads provided is reduced in 1.5.
223A distribution for the OS X operating system is provided only for the
224<code>amd64</code> architecture, not <code>386</code>.
225Similarly, the ports for Snow Leopard (Apple OS X 10.6) still work but are no
226longer released as a download or maintained since Apple no longer maintains that version
227of the operating system.
228Also, the <code>dragonfly/386</code> port is no longer supported at all
229because DragonflyBSD itself no longer supports the 32-bit 386 architecture.
230</p>
231
232<p>
233There are however several new ports available to be built from source.
234These include <code>darwin/arm</code> and <code>darwin/arm64</code>.
235The new port <code>linux/arm64</code> is mostly in place, but <code>cgo</code>
236is only supported using external linking.
237</p>
238
Rob Pike0ea3f582015-06-26 11:52:21 +1000239<p>
Russ Cox16c38382015-08-17 21:32:40 -0400240Also available as experiments are <code>ppc64</code>
241and <code>ppc64le</code> (64-bit PowerPC, big- and little-endian).
Rob Pikef4c775e2015-07-30 15:53:10 +1000242Both these ports support <code>cgo</code> but
243only with internal linking.
Rob Pike0908fad2015-07-22 11:24:27 +1000244</p>
245
246<p>
Rob Pike0ea3f582015-06-26 11:52:21 +1000247On FreeBSD, Go 1.5 requires FreeBSD 8-STABLE+ because of its new use of the <code>SYSCALL</code> instruction.
248</p>
249
250<p>
Dave Cheneye7f4df72015-08-07 10:52:18 +1000251On NaCl, Go 1.5 requires SDK version pepper-41. Later pepper versions are not
252compatible due to the removal of the sRPC subsystem from the NaCl runtime.
Rob Pike0ea3f582015-06-26 11:52:21 +1000253</p>
254
David Crawshawebb67832015-07-16 15:30:47 -0400255<p>
256On Darwin, the use of the system X.509 certificate interface can be disabled
257with the <code>ios</code> build tag.
258</p>
259
Rob Pike4e0be152015-07-31 09:03:58 +1000260<p>
261The Solaris port now has full support for cgo and the packages
262<a href="/pkg/net/"><code>net</code></a> and
263<a href="/pkg/crypto/x509/"><code>crypto/x509</code></a>,
264as well as a number of other fixes and improvements.
265</p>
266
Rob Pikecd2e2f62015-07-01 15:49:40 +1000267<h2 id="tools">Tools</h2>
Rob Pike1a27c072015-01-13 10:16:30 +1100268
Rob Pikeef371842015-07-06 09:01:32 +1000269<h3 id="translate">Translating</h3>
Rob Pike751eef82015-06-25 16:20:27 +1000270
Rob Pikeef371842015-07-06 09:01:32 +1000271<p>
272As part of the process to eliminate C from the tree, the compiler and
273linker were translated from C to Go.
274It was a genuine (machine assisted) translation, so the new programs are essentially
275the old programs translated rather than new ones with new bugs.
276We are confident the translation process has introduced few if any new bugs,
277and in fact uncovered a number of previously unknown bugs, now fixed.
278</p>
279
280<p>
281The assembler is a new program, however; it is described below.
282</p>
283
284<h3 id="rename">Renaming</h3>
285
286<p>
287The suites of programs that were the compilers (<code>6g</code>, <code>8g</code>, etc.),
288the assemblers (<code>6a</code>, <code>8a</code>, etc.),
289and the linkers (<code>6l</code>, <code>8l</code>, etc.)
290have each been consolidated into a single tool that is configured
291by the environment variables <code>GOOS</code> and <code>GOARCH</code>.
292The old names are gone; the new tools are available through the <code>go</code> <code>tool</code>
293mechanism as <code>go tool compile</code>,
294<code>go tool asm</code>,
295<code>and go tool link</code>.
Rob Pike54eb9ef2015-08-19 13:44:33 +1000296Also, the file suffixes <code>.6</code>, <code>.8</code>, etc. for the
Rob Pikeef371842015-07-06 09:01:32 +1000297intermediate object files are also gone; now they are just plain <code>.o</code> files.
298</p>
299
300<p>
301For example, to build and link a program on amd64 for Darwin
302using the tools directly, rather than through <code>go build</code>,
303one would run:
304</p>
305
306<pre>
307$ export GOOS=darwin GOARCH=amd64
308$ go tool compile program.go
309$ go tool link program.o
Rob Piked6ef6eb2015-06-25 14:36:49 +1000310</pre>
Rob Pike751eef82015-06-25 16:20:27 +1000311
Rob Pikeef371842015-07-06 09:01:32 +1000312<h3 id="moving">Moving</h3>
313
314<p>
315Because the <a href="/pkg/go/types/"><code>go/types</code></a> package
316has now moved into the main repository (see below),
317the <a href="/cmd/vet"><code>vet</code></a> and
318<a href="/cmd/cover"><code>cover</code></a>
319tools have also been moved.
320They are no longer maintained in the external <code>golang.org/x/tools</code> repository,
321although (deprecated) source still resides there for compatibility with old releases.
322</p>
323
324<h3 id="compiler">Compiler</h3>
325
326<p>
327As described above, the compiler in Go 1.5 is a single Go program,
328translated from the old C source, that replaces <code>6g</code>, <code>8g</code>,
329and so on.
330Its target is configured by the environment variables <code>GOOS</code> and <code>GOARCH</code>.
331</p>
332
333<p>
334The 1.5 compiler is mostly equivalent to the old,
335but some internal details have changed.
336One significant change is that evaluation of constants now uses
337the <a href="/pkg/math/big/"><code>math/big</code></a> package
338rather than a custom (and less well tested) implementation of high precision
339arithmetic.
340We do not expect this to affect the results.
341</p>
342
343<p>
344For the amd64 architecture only, the compiler has a new option, <code>-dynlink</code>,
345that assists dynamic linking by supporting references to Go symbols
346defined in external shared libraries.
347</p>
348
Rob Pike09b54632015-07-02 12:56:51 +1000349<h3 id="assembler">Assembler</h3>
350
351<p>
Rob Pikeef371842015-07-06 09:01:32 +1000352Like the compiler and linker, the assembler in Go 1.5 is a single program
353that replaces the suite of assemblers (<code>6a</code>,
354<code>8a</code>, etc.) and the environment variables
Rob Pike09b54632015-07-02 12:56:51 +1000355<code>GOARCH</code> and <code>GOOS</code>
Rob Pikeef371842015-07-06 09:01:32 +1000356configure the architecture and operating system.
357Unlike the other programs, the assembler is a wholly new program
358written in Go.
Rob Pike09b54632015-07-02 12:56:51 +1000359</p>
Rob Pike902345e2015-07-14 15:20:19 +1000360
Rob Pike09b54632015-07-02 12:56:51 +1000361 <p>
362The new assembler is very nearly compatible with the previous
Rob Pikeef371842015-07-06 09:01:32 +1000363ones, but there are a few changes that may affect some
Rob Pike09b54632015-07-02 12:56:51 +1000364assembler source files.
Rob Pikeef371842015-07-06 09:01:32 +1000365See the updated <a href="/doc/asm">assembler guide</a>
366for more specific information about these changes. In summary:
367
Rob Pike09b54632015-07-02 12:56:51 +1000368</p>
369
370<p>
371First, the expression evaluation used for constants is a little
372different.
373It now uses unsigned 64-bit arithmetic and the precedence
374of operators (<code>+</code>, <code>-</code>, <code><<</code>, etc.)
375comes from Go, not C.
Rob Pikeef371842015-07-06 09:01:32 +1000376We expect these changes to affect very few programs but
377manual verification may be required.
Rob Pike09b54632015-07-02 12:56:51 +1000378</p>
379
380<p>
Rob Pikee71276c2015-07-09 10:10:12 +1000381Perhaps more important is that on machines where
382<code>SP</code> or <code>PC</code> is only an alias
383for a numbered register,
384such as <code>R13</code> for the stack pointer and
385<code>R15</code> for the hardware program counter
Rob Pike2e6ed612015-07-09 15:06:15 +1000386on ARM,
Rob Pikee71276c2015-07-09 10:10:12 +1000387a reference to such a register that does not include a symbol
388is now illegal.
389For example, <code>SP</code> and <code>4(SP)</code> are
390illegal but <code>sym+4(SP)</code> is fine.
391On such machines, to refer to the hardware register use its
392true <code>R</code> name.
Rob Pike09b54632015-07-02 12:56:51 +1000393</p>
394
395<p>
396One minor change is that some of the old assemblers
397permitted the notation
398</p>
399
400<pre>
401constant=value
402</pre>
403
404<p>
405to define a named constant.
406Since this is always possible to do with the traditional
407C-like <code>#define</code> notation, which is still
408supported (the assembler includes an implementation
409of a simplified C preprocessor), the feature was removed.
410</p>
411
Rob Pikeef371842015-07-06 09:01:32 +1000412<h3 id="link">Linker</h3>
413
414<p>
415The linker in Go 1.5 is now one Go program,
416that replaces <code>6l</code>, <code>8l</code>, etc.
417Its operating system and instruction set are specified
418by the environment variables <code>GOOS</code> and <code>GOARCH</code>.
419</p>
420
421<p>
Rob Pike99912272015-08-03 11:05:05 +1000422There are several other changes.
423The most significant is the addition of a <code>-buildmode</code> option that
Rob Pikeef371842015-07-06 09:01:32 +1000424expands the style of linking; it now supports
425situations such as building shared libraries and allowing other languages
426to call into Go libraries.
427Some of these were outlined in a <a href="https://golang.org/s/execmodes">design document</a>.
428For a list of the available build modes and their use, run
429</p>
Rob Pikecd2e2f62015-07-01 15:49:40 +1000430
431<pre>
Rob Pikeef371842015-07-06 09:01:32 +1000432$ go help buildmode
Rob Pikecd2e2f62015-07-01 15:49:40 +1000433</pre>
434
Rob Pikeef371842015-07-06 09:01:32 +1000435<p>
436Another minor change is that the linker no longer records build time stamps in
437the header of Windows executables.
438Also, although this may be fixed, Windows cgo executables are missing some
439DWARF information.
440</p>
441
Rob Pike99912272015-08-03 11:05:05 +1000442<p>
443Finally, the <code>-X</code> flag, which takes two arguments,
444as in
445</p>
446
447<pre>
448-X importpath.name value
449</pre>
450
451<p>
452now also accepts a more common Go flag style with a single argument
453that is itself a <code>name=value</code> pair:
454</p>
455
456<pre>
457-X importpath.name=value
458</pre>
459
460<p>
461Although the old syntax still works, it is recommended that uses of this
462flag in scripts and the like be updated to the new form.
463</p>
464
Rob Pikeef371842015-07-06 09:01:32 +1000465<h3 id="go_command">Go command</h3>
466
467<p>
468The <a href="/cmd/go"><code>go</code></a> command's basic operation
469is unchanged, but there are a number of changes worth noting.
470</p>
471
472<p>
473The previous release introduced the idea of a directory internal to a package
474being unimportable through the <code>go</code> command.
475In 1.4, it was tested with the introduction of some internal elements
476in the core repository.
477As suggested in the <a href="https://golang.org/s/go14internal">design document</a>,
478that change is now being made available to all repositories.
479The rules are explained in the design document, but in summary any
480package in or under a directory named <code>internal</code> may
481be imported by packages rooted in the same subtree.
482Existing packages with directory elements named <code>internal</code> may be
483inadvertently broken by this change, which was why it was advertised
484in the last release.
485</p>
486
487<p>
488Another change in how packages are handled is the experimental
489addition of support for "vendoring".
Russ Coxaad4fe42015-07-22 11:33:42 -0400490For details, see the documentation for the <a href="/cmd/go/#hdr-Vendor_Directories"><code>go</code> command</a>
491and the <a href="https://golang.org/s/go15vendor">design document</a>.
Rob Pikeef371842015-07-06 09:01:32 +1000492</p>
493
494<p>
495There have also been several minor changes.
496Read the <a href="/cmd/go">documentation</a> for full details.
497</p>
498
499<ul>
500
501<li>
502SWIG support has been updated such that
503<code>.swig</code> and <code>.swigcxx</code>
504now require SWIG 3.0.6 or later.
505</li>
506
507<li>
Rob Pike43156622015-09-08 10:58:21 -0700508The <code>install</code> subcommand now removes the
509binary created by the <code>build</code> subcommand
510in the source directory, if present,
511to avoid problems having two binaries present in the tree.
512</li>
513
514<li>
Rob Pikeef371842015-07-06 09:01:32 +1000515The <code>std</code> (standard library) wildcard package name
516now excludes commands.
517A new <code>cmd</code> wildcard covers the commands.
518</li>
519
520<li>
Russ Cox91a480c2015-07-14 00:34:36 -0400521A new <code>-asmflags</code> build option
522sets flags to pass to the assembler.
Rob Pike54eb9ef2015-08-19 13:44:33 +1000523However,
Russ Cox91a480c2015-07-14 00:34:36 -0400524the <code>-ccflags</code> build option has been dropped;
525it was specific to the old, now deleted C compiler .
Rob Pikeef371842015-07-06 09:01:32 +1000526</li>
527
528<li>
Russ Cox91a480c2015-07-14 00:34:36 -0400529A new <code>-buildmode</code> build option
530sets the build mode, described above.
Rob Pikeef371842015-07-06 09:01:32 +1000531</li>
532
533<li>
Russ Cox91a480c2015-07-14 00:34:36 -0400534A new <code>-pkgdir</code> build option
535sets the location of installed package archives,
536to help isolate custom builds.
537</li>
538
539<li>
540A new <code>-toolexec</code> build option
541allows substitution of a different command to invoke
542the compiler and so on.
543This acts as a custom replacement for <code>go tool</code>.
544</li>
545
546<li>
Rob Pikee71276c2015-07-09 10:10:12 +1000547The <code>test</code> subcommand now has a <code>-count</code>
548flag to specify how many times to run each test and benchmark.
Rob Pike54eb9ef2015-08-19 13:44:33 +1000549The <a href="/pkg/testing/"><code>testing</code></a> package
Rob Pikeae4dc8f2015-08-20 11:46:05 +1000550does the work here, through the <code>-test.count</code> flag.
Rob Pikeef371842015-07-06 09:01:32 +1000551</li>
552
553<li>
554The <code>generate</code> subcommand has a couple of new features.
555The <code>-run</code> option specifies a regular expression to select which directives
556to execute; this was proposed but never implemented in 1.4.
557The executing pattern now has access to two new environment variables:
558<code>$GOLINE</code> returns the source line number of the directive
559and <code>$DOLLAR</code> expands to a dollar sign.
560</li>
561
Rob Pikee71276c2015-07-09 10:10:12 +1000562<li>
563The <code>get</code> subcommand now has a <code>-insecure</code>
564flag that must be enabled if fetching from an insecure repository, one that
565does not encrypt the connection.
566</li>
567
Rob Pikeef371842015-07-06 09:01:32 +1000568</ul>
569
570<h3 id="vet_command">Go vet command</h3>
571
572<p>
573The <a href="/cmd/vet"><code>go tool vet</code></a> command now does
574more thorough validation of struct tags.
575</p>
576
577<h3 id="trace_command">Trace command</h3>
578
Rob Pike6163cf82015-07-16 14:45:46 +1000579<p>
580A new tool is available for dynamic execution tracing of Go programs.
581The usage is analogous to how the test coverage tool works.
582Generation of traces is integrated into <code>go test</code>,
583and then a separate execution of the tracing tool itself analyzes the results:
584</p>
585
Rob Pikeef371842015-07-06 09:01:32 +1000586<pre>
Rob Pike6163cf82015-07-16 14:45:46 +1000587$ go test -trace=trace.out path/to/package
588$ go tool trace [flags] pkg.test trace.out
Rob Pikeef371842015-07-06 09:01:32 +1000589</pre>
590
Rob Pike6163cf82015-07-16 14:45:46 +1000591<p>
592The flags enable the output to be displayed in a browser window.
593For details, run <code>go tool trace -help</code>.
594There is also a description of the tracing facility in this
595<a href="https://talks.golang.org/2015/dynamic-tools.slide">talk</a>
596from GopherCon 2015.
597</p>
598
Rob Pikeef371842015-07-06 09:01:32 +1000599<h3 id="doc_command">Go doc command</h3>
600
601<p>
602A few releases back, the <code>go doc</code>
603command was deleted as being unnecessary.
604One could always run "<code>godoc .</code>" instead.
605The 1.5 release introduces a new <a href="/cmd/doc"><code>go doc</code></a>
606command with a more convenient command-line interface than
607<code>godoc</code>'s.
608It is designed for command-line usage specifically, and provides a more
609compact and focused presentation of the documentation for a package
610or its elements, according to the invocation.
611It also provides case-insensitive matching and
612support for showing the documentation for unexported symbols.
613For details run "<code>go help doc</code>".
614</p>
615
616<h3 id="cgo">Cgo</h3>
617
618<p>
619When parsing <code>#cgo</code> lines,
620the invocation <code>${SRCDIR}</code> is now
621expanded into the path to the source directory.
622This allows options to be passed to the
623compiler and linker that involve file paths relative to the
624source code directory. Without the expansion the paths would be
625invalid when the current working directory changes.
626</p>
627
628<p>
Rob Pike4e0be152015-07-31 09:03:58 +1000629Solaris now has full cgo support.
630</p>
631
632<p>
Rob Pikeef371842015-07-06 09:01:32 +1000633On Windows, cgo now uses external linking by default.
634</p>
635
Ian Lance Taylora5d23fc2015-07-30 09:01:22 -0700636<p>
637When a C struct ends with a zero-sized field, but the struct itself is
638not zero-sized, Go code can no longer refer to the zero-sized field.
639Any such references will have to be rewritten.
640</p>
641
Rob Pikeef371842015-07-06 09:01:32 +1000642<h2 id="performance">Performance</h2>
643
644<p>
645As always, the changes are so general and varied that precise statements
646about performance are difficult to make.
647The changes are even broader ranging than usual in this release, which
648includes a new garbage collector and a conversion of the runtime to Go.
649Some programs may run faster, some slower.
650On average the programs in the Go 1 benchmark suite run a few percent faster in Go 1.5
651than they did in Go 1.4,
652while as mentioned above the garbage collector's pauses are
653dramatically shorter, and almost always under 10 milliseconds.
654</p>
655
656<p>
657Builds in Go 1.5 will be slower by a factor of about two.
658The automatic translation of the compiler and linker from C to Go resulted in
659unidiomatic Go code that performs poorly compared to well-written Go.
660Analysis tools and refactoring helped to improve the code, but much remains to be done.
661Further profiling and optimization will continue in Go 1.6 and future releases.
662For more details, see these <a href="https://talks.golang.org/2015/gogo.slide">slides</a>
663and associated <a href="https://www.youtube.com/watch?v=cF1zJYkBW4A">video</a>.
664</p>
665
666<h2 id="library">Core library</h2>
Rob Pike6fe9c4a2015-07-01 08:48:19 +1000667
668<h3 id="flag">Flag</h3>
669
670<p>
671The flag package's
Rob Pike902345e2015-07-14 15:20:19 +1000672<a href="/pkg/flag/#PrintDefaults"><code>PrintDefaults</code></a>
Rob Pike6fe9c4a2015-07-01 08:48:19 +1000673function, and method on <a href="/pkg/flag/#FlagSet"><code>FlagSet</code></a>,
674have been modified to create nicer usage messages.
675The format has been changed to be more human-friendly and in the usage
676messages a word quoted with `backquotes` is taken to be the name of the
677flag's operand to display in the usage message.
678For instance, a flag created with the invocation,
679</p>
680
681<pre>
682cpuFlag = flag.Int("cpu", 1, "run `N` processes in parallel")
683</pre>
684
685<p>
686will show the help message,
687</p>
688
689<pre>
690-cpu N
691 run N processes in parallel (default 1)
692</pre>
693
694<p>
695Also, the default is now listed only when it is not the zero value for the type.
696</p>
697
698<h3 id="math_big">Floats in math/big</h3>
699
700<p>
701The <a href="/pkg/math/big/"><code>math/big</code></a> package
702has a new, fundamental data type,
703<a href="/pkg/math/big/#Float"><code>Float</code></a>,
704which implements arbitrary-precision floating-point numbers.
705A <code>Float</code> value is represented by a boolean sign,
706a variable-length mantissa, and a 32-bit fixed-size signed exponent.
707The precision of a <code>Float</code> (the mantissa size in bits)
708can be specified explicitly or is otherwise determined by the first
709operation that creates the value.
710Once created, the size of a <code>Float</code>'s mantissa may be modified with the
711<a href="/pkg/math/big/#Float.SetPrec"><code>SetPrec</code></a> method.
712<code>Floats</code> support the concept of infinities, such as are created by
713overflow, but values that would lead to the equivalent of IEEE 754 NaNs
714trigger a panic.
715<code>Float</code> operations support all IEEE-754 rounding modes.
716When the precision is set to 24 (53) bits,
717operations that stay within the range of normalized <code>float32</code>
718(<code>float64</code>)
719values produce the same results as the corresponding IEEE-754
720arithmetic on those values.
721</p>
722
Rob Pikecd2e2f62015-07-01 15:49:40 +1000723<h3 id="go_types">Go types</h3>
724
725<p>
726The <a href="/pkg/go/types/"><code>go/types</code></a> package
727up to now has been maintained in the <code>golang.org/x</code>
728repository; as of Go 1.5 it has been relocated to the main repository.
729The code at the old location is now deprecated.
730There is also a modest API change in the package, discussed below.
731</p>
732
733<p>
734Associated with this move, the
735<a href="/pkg/go/constant/"><code>go/constant</code></a>
736package also moved to the main repository;
737it was <code>golang.org/x/tools/exact</code> before.
738The <a href="/pkg/go/importer/"><code>go/importer</code></a> package
739also moved to the main repository,
740as well as some tools described above.
741</p>
742
743<h3 id="net">Net</h3>
744
745<p>
746The DNS resolver in the net package has almost always used <code>cgo</code> to access
747the system interface.
748A change in Go 1.5 means that on most Unix systems DNS resolution
749will no longer require <code>cgo</code>, which simplifies execution
750on those platforms.
751Now, if the system's networking configuration permits, the native Go resolver
752will suffice.
753The important effect of this change is that each DNS resolution occupies a goroutine
754rather than a thread,
755so a program with multiple outstanding DNS requests will consume fewer operating
756system resources.
757</p>
758
759<p>
760The decision of how to run the resolver applies at run time, not build time.
761The <code>netgo</code> build tag that has been used to enforce the use
762of the Go resolver is no longer necessary, although it still works.
Brad Fitzpatrick60315002015-07-17 09:25:45 -0700763A new <code>netcgo</code> build tag forces the use of the <code>cgo</code> resolver at
764build time.
765To force <code>cgo</code> resolution at run time set
766<code>GODEBUG=netdns=cgo</code> in the environment.
767More debug options are documented <a href="https://golang.org/cl/11584">here</a>.
Rob Pikecd2e2f62015-07-01 15:49:40 +1000768</p>
769
770<p>
771This change applies to Unix systems only.
772Windows, Mac OS X, and Plan 9 systems behave as before.
773</p>
774
Rob Pike6fe9c4a2015-07-01 08:48:19 +1000775<h3 id="reflect">Reflect</h3>
776
777<p>
778The <a href="/pkg/reflect/"><code>reflect</code></a> package
779has two new functions: <a href="/pkg/reflect/#ArrayOf"><code>ArrayOf</code></a>
780and <a href="/pkg/reflect/#FuncOf"><code>FuncOf</code></a>.
781These functions, analogous to the extant
Rob Pikecd2e2f62015-07-01 15:49:40 +1000782<a href="/pkg/reflect/#SliceOf"><code>SliceOf</code></a> function,
Rob Pike6fe9c4a2015-07-01 08:48:19 +1000783create new types at runtime to describe arrays and functions.
784</p>
785
786<h3 id="hardening">Hardening</h3>
787
788<p>
789Several dozen bugs were found in the standard library
790through randomized testing with the
791<a href="https://github.com/dvyukov/go-fuzz"><code>go-fuzz</code></a> tool.
792Bugs were fixed in the
793<a href="/pkg/archive/tar/"><code>archive/tar</code></a>,
794<a href="/pkg/archive/zip/"><code>archive/zip</code></a>,
795<a href="/pkg/compress/flate/"><code>compress/flate</code></a>,
796<a href="/pkg/encoding/gob/"><code>encoding/gob</code></a>,
797<a href="/pkg/fmt/"><code>fmt</code></a>,
798<a href="/pkg/html/template/"><code>html/template</code></a>,
799<a href="/pkg/image/gif/"><code>image/gif</code></a>,
800<a href="/pkg/image/jpeg/"><code>image/jpeg</code></a>,
801<a href="/pkg/image/png/"><code>image/png</code></a>, and
802<a href="/pkg/text/template/"><code>text/template</code></a>,
803packages.
804The fixes harden the implementation against incorrect and malicious inputs.
805</p>
806
Rob Pike751eef82015-06-25 16:20:27 +1000807<h3 id="minor_library_changes">Minor changes to the library</h3>
808
809<ul>
810
811<li>
Rob Pikec418fe72015-06-29 19:51:56 +1000812The <a href="/pkg/archive/zip/"><code>archive/zip</code></a> package's
813<a href="/pkg/archive/zip/#Writer"><code>Writer</code></a> type now has a
814<a href="/pkg/archive/zip/#Writer.SetOffset"><code>SetOffset</code></a>
815method to specify the location within the output stream at which to write the archive.
Rob Pike751eef82015-06-25 16:20:27 +1000816</li>
817
818<li>
Rob Pikec418fe72015-06-29 19:51:56 +1000819The <a href="/pkg/bufio/#Reader"><code>Reader</code></a> in the
820<a href="/pkg/bufio/"><code>bufio</code></a> package now has a
821<a href="/pkg/bufio/#Reader.Discard"><code>Discard</code></a>
822method to discard data from the input.
Rob Pike751eef82015-06-25 16:20:27 +1000823</li>
824
825<li>
Andrew Gerrandabe70af2015-08-07 04:16:43 +0000826In the <a href="/pkg/bytes/"><code>bytes</code></a> package,
Rob Pikec418fe72015-06-29 19:51:56 +1000827the <a href="/pkg/bytes/#Buffer"><code>Buffer</code></a> type
828now has a <a href="/pkg/bytes/#Buffer.Cap"><code>Cap</code></a> method
829that reports the number of bytes allocated within the buffer.
Brad Fitzpatrickaee4f422015-07-20 19:46:12 -0700830Similarly, in both the <a href="/pkg/bytes/"><code>bytes</code></a>
Rob Pikec418fe72015-06-29 19:51:56 +1000831and <a href="/pkg/strings/"><code>strings</code></a> packages,
832the <a href="/pkg/bytes/#Reader"><code>Reader</code></a>
833type now has a <a href="/pkg/bytes/#Reader.Size"><code>Size</code></a>
834method that reports the original length of the underlying slice or string.
Rob Pike751eef82015-06-25 16:20:27 +1000835</li>
836
837<li>
Rob Pikec418fe72015-06-29 19:51:56 +1000838Both the <a href="/pkg/bytes/"><code>bytes</code></a> and
839<a href="/pkg/strings/"><code>strings</code></a> packages
840also now have a <a href="/pkg/bytes/#LastIndexByte"><code>LastIndexByte</code></a>
841function that locates the rightmost byte with that value in the argument.
Rob Pike751eef82015-06-25 16:20:27 +1000842</li>
843
844<li>
Rob Pike09b54632015-07-02 12:56:51 +1000845The <a href="/pkg/crypto/"><code>crypto</code></a> package
846has a new interface, <a href="/pkg/crypto/#Decrypter"><code>Decrypter</code></a>,
847that abstracts the behavior of a private key used in asymmetric decryption.
Rob Pike751eef82015-06-25 16:20:27 +1000848</li>
849
850<li>
Rob Pike09b54632015-07-02 12:56:51 +1000851In the <a href="/pkg/crypto/cipher/"><code>crypto/cipher</code></a> package,
852the documentation for the <a href="/pkg/crypto/cipher/#Stream"><code>Stream</code></a>
853interface has been clarified regarding the behavior when the source and destination are
854different lengths.
855If the destination is shorter than the source, the method will panic.
856This is not a change in the implementation, only the documentation.
Rob Pike751eef82015-06-25 16:20:27 +1000857</li>
858
859<li>
Rob Pike09b54632015-07-02 12:56:51 +1000860Also in the <a href="/pkg/crypto/cipher/"><code>crypto/cipher</code></a> package,
861there is now support for nonce lengths other than 96 bytes in AES's Galois/Counter mode (GCM),
862which some protocols require.
Rob Pike751eef82015-06-25 16:20:27 +1000863</li>
864
865<li>
Rob Pike09b54632015-07-02 12:56:51 +1000866In the <a href="/pkg/crypto/elliptic/"><code>crypto/elliptic</code></a> package,
867there is now a <code>Name</code> field in the
868<a href="/pkg/crypto/elliptic/#CurveParams"><code>CurveParams</code></a> struct,
869and the curves implemented in the package have been given names.
870These names provide a safer way to select a curve, as opposed to
871selecting its bit size, for cryptographic systems that are curve-dependent.
Rob Pike751eef82015-06-25 16:20:27 +1000872</li>
873
874<li>
Rob Pike09b54632015-07-02 12:56:51 +1000875Also in the <a href="/pkg/crypto/elliptic/"><code>crypto/elliptic</code></a> package,
876the <a href="/pkg/crypto/elliptic/#Unmarshal"><code>Unmarshal</code></a> function
877now verifies that the point is actually on the curve.
878(If it is not, the function returns nils).
879This change guards against certain attacks.
Rob Pike751eef82015-06-25 16:20:27 +1000880</li>
881
882<li>
Brad Fitzpatrick1b5eaa42015-07-20 15:14:01 -0700883The <a href="/pkg/crypto/sha512/"><code>crypto/sha512</code></a>
884package now has support for the two truncated versions of
885the SHA-512 hash algorithm, SHA-512/224 and SHA-512/256.
886</li>
887
888<li>
Rob Pike09b54632015-07-02 12:56:51 +1000889The <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> package
Jonathan Rudenbergaed74b92015-07-14 19:16:01 -0400890minimum protocol version now defaults to TLS 1.0.
Rob Pike09b54632015-07-02 12:56:51 +1000891The 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 +1000892</li>
893
894<li>
Jonathan Rudenbergaed74b92015-07-14 19:16:01 -0400895The <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> package
Rob Pike09b54632015-07-02 12:56:51 +1000896now supports Signed Certificate Timestamps (SCTs) as specified in RFC 6962.
897The server serves them if they are listed in the
898<a href="/pkg/crypto/tls/#Certificate"><code>Certificate</code></a> struct,
Rob Pikeef371842015-07-06 09:01:32 +1000899and the client requests them and exposes them, if present,
Rob Pike09b54632015-07-02 12:56:51 +1000900in its <a href="/pkg/crypto/tls/#ConnectionState"><code>ConnectionState</code></a> struct.
Jonathan Rudenbergaed74b92015-07-14 19:16:01 -0400901
902<li>
903The stapled OCSP response to a <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> client connection,
904previously only available via the
905<a href="/pkg/crypto/tls/#Conn.OCSPResponse"><code>OCSPResponse</code></a> method,
906is now exposed in the <a href="/pkg/crypto/tls/#ConnectionState"><code>ConnectionState</code></a> struct.
907</li>
908
909<li>
910The <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> server implementation
911will now always call the
Rob Pike09b54632015-07-02 12:56:51 +1000912<code>GetCertificate</code> function in
913the <a href="/pkg/crypto/tls/#Config"><code>Config</code></a> struct
914to select a certificate for the connection when none is supplied.
Rob Pike751eef82015-06-25 16:20:27 +1000915</li>
916
917<li>
Rob Pike09b54632015-07-02 12:56:51 +1000918Finally, the session ticket keys in the
919<a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> package
Jonathan Rudenbergaed74b92015-07-14 19:16:01 -0400920can now be changed while the server is running.
Rob Pike902345e2015-07-14 15:20:19 +1000921This is done through the new
Rob Pike09b54632015-07-02 12:56:51 +1000922<a href="/pkg/crypto/tls/#Config.SetSessionTicketKeys"><code>SetSessionTicketKeys</code></a>
923method of the
924<a href="/pkg/crypto/tls/#Config"><code>Config</code></a> type.
Rob Pike751eef82015-06-25 16:20:27 +1000925</li>
926
927<li>
Rob Pike09b54632015-07-02 12:56:51 +1000928In the <a href="/pkg/crypto/x509/"><code>crypto/x509</code></a> package,
929wildcards are now accepted only in the leftmost label as defined in
930<a href="https://tools.ietf.org/html/rfc6125#section-6.4.3">the specification</a>.
Rob Pike751eef82015-06-25 16:20:27 +1000931</li>
932
933<li>
Rob Pike09b54632015-07-02 12:56:51 +1000934Also in the <a href="/pkg/crypto/x509/"><code>crypto/x509</code></a> package,
935the handling of unknown critical extensions has been changed.
936They used to cause parse errors but now they are parsed and caused errors only
937in <a href="/pkg/crypto/x509/#Certificate.Verify"><code>Verify</code></a>.
938The new field <code>UnhandledCriticalExtensions</code> of
939<a href="/pkg/crypto/x509/#Certificate"><code>Certificate</code></a> records these extensions.
Rob Pike751eef82015-06-25 16:20:27 +1000940</li>
941
942<li>
Rob Pikec418fe72015-06-29 19:51:56 +1000943The <a href="/pkg/database/sql/#DB"><code>DB</code></a> type of the
944<a href="/pkg/database/sql/"><code>database/sql</code></a> package
945now has a <a href="/pkg/database/sql/#DB.Stats"><code>Stats</code></a> method
946to retrieve database statistics.
Rob Pike751eef82015-06-25 16:20:27 +1000947</li>
948
949<li>
Rob Pike09b54632015-07-02 12:56:51 +1000950The <a href="/pkg/debug/dwarf/"><code>debug/dwarf</code></a>
951package has extensive additions to better support DWARF version 4.
952See for example the definition of the new type
953<a href="/pkg/debug/dwarf/#Class"><code>Class</code></a>.
954</li>
955
956<li>
Austin Clements43a404c2015-08-04 15:57:07 -0400957The <a href="/pkg/debug/dwarf/"><code>debug/dwarf</code></a> package
958also now supports decoding of DWARF line tables.
959</li>
960
961<li>
Rob Pike09b54632015-07-02 12:56:51 +1000962The <a href="/pkg/debug/elf/"><code>debug/elf</code></a>
Russ Cox16c38382015-08-17 21:32:40 -0400963package now has support for the 64-bit PowerPC architecture.
Rob Pike09b54632015-07-02 12:56:51 +1000964</li>
965
966<li>
Rob Pikec418fe72015-06-29 19:51:56 +1000967The <a href="/pkg/encoding/base64/"><code>encoding/base64</code></a> package
968now supports unpadded encodings through two new encoding variables,
969<a href="/pkg/encoding/base64/#RawStdEncoding"><code>RawStdEncoding</code></a> and
970<a href="/pkg/encoding/base64/#RawURLEncoding"><code>RawURLEncoding</code></a>.
Rob Pike751eef82015-06-25 16:20:27 +1000971</li>
972
973<li>
Rob Pike09b54632015-07-02 12:56:51 +1000974The <a href="/pkg/encoding/json/"><code>encoding/json</code></a> package
975now returns an <a href="/pkg/encoding/json/#UnmarshalTypeError"><code>UnmarshalTypeError</code></a>
976if a JSON value is not appropriate for the target variable or component
977to which it is being unmarshaled.
978</li>
979
980<li>
Rob Pikeff991942015-07-29 09:43:32 +1000981The <code>encoding/json</code>'s
982<a href="/pkg/encoding/json/#Decoder"><code>Decoder</code></a>
983type has a new method that provides a streaming interface for decoding
984a JSON document:
985<a href="/pkg/encoding/json/#Decoder.Token"><code>Token</code></a>.
986It also interoperates with the existing functionality of <code>Decode</code>,
987which will continue a decode operation already started with <code>Decoder.Token</code>.
988</li>
989
990<li>
Rob Pike09b54632015-07-02 12:56:51 +1000991The <a href="/pkg/flag/"><code>flag</code></a> package
992has a new function, <a href="/pkg/flag/#UnquoteUsage"><code>UnquoteUsage</code></a>,
993to assist in the creation of usage messages using the new convention
994described above.
995</li>
996
997<li>
Jonathan Rudenbergf4b4c882015-07-14 19:22:24 -0400998In the <a href="/pkg/fmt/"><code>fmt</code></a> package,
Rob Pike0ea3f582015-06-26 11:52:21 +1000999a value of type <a href="/pkg/reflect/#Value"><code>Value</code></a> now
1000prints what it holds, rather than use the <code>reflect.Value</code>'s <code>Stringer</code>
1001method, which produces things like <code>&lt;int Value&gt;</code>.
Rob Pike751eef82015-06-25 16:20:27 +10001002</li>
1003
1004<li>
Rob Pikec418fe72015-06-29 19:51:56 +10001005The <a href="/pkg/ast/#EmptyStmt"><code>EmptyStmt</code></a> type
1006in the <a href="/pkg/go/ast/"><code>go/ast</code></a> package now
1007has a boolean <code>Implicit</code> field that records whether the
1008semicolon was implicitly added or was present in the source.
Rob Pike751eef82015-06-25 16:20:27 +10001009</li>
1010
1011<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001012For forward compatibility the <a href="/pkg/go/build/"><code>go/build</code></a> package
1013reserves <code>GOARCH</code> values for a number of architectures that Go might support one day.
1014This is not a promise that it will.
Rob Pike09b54632015-07-02 12:56:51 +10001015Also, the <a href="/pkg/go/build/#Package"><code>Package</code></a> struct
1016now has a <code>PkgTargetRoot</code> field that stores the
1017architecture-dependent root directory in which to install, if known.
Rob Pike751eef82015-06-25 16:20:27 +10001018</li>
1019
1020<li>
Rob Pikecd2e2f62015-07-01 15:49:40 +10001021The (newly migrated) <a href="/pkg/go/types/"><code>go/types</code></a>
1022package allows one to control the prefix attached to package-level names using
1023the new <a href="/pkg/go/types/#Qualifier"><code>Qualifier</code></a>
1024function type as an argument to several functions. This is an API change for
1025the package, but since it is new to the core, it is not breaking the Go 1 compatibility
1026rules since code that uses the package must explicitly ask for it at its new location.
Rob Pike6163cf82015-07-16 14:45:46 +10001027To update, run
1028<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 +10001029</li>
1030
1031<li>
Rob Pike09b54632015-07-02 12:56:51 +10001032In the <a href="/pkg/image/"><code>image</code></a> package,
1033the <a href="/pkg/image/#Rectangle"><code>Rectangle</code></a> type
1034now implements the <a href="/pkg/image/#Image"><code>Image</code></a> interface,
Rob Pike54eb9ef2015-08-19 13:44:33 +10001035so a <code>Rectangle</code> can serve as a mask when drawing.
Rob Pike09b54632015-07-02 12:56:51 +10001036</li>
1037
1038<li>
1039Also in the <a href="/pkg/image/"><code>image</code></a> package,
1040to assist in the handling of some JPEG images,
1041there is now support for 4:1:1 and 4:1:0 YCbCr subsampling and basic
Rob Pike54eb9ef2015-08-19 13:44:33 +10001042CMYK support, represented by the new <code>image.CMYK</code> struct.
Rob Pike09b54632015-07-02 12:56:51 +10001043</li>
1044
1045<li>
1046The <a href="/pkg/image/color/"><code>image/color</code></a> package
1047adds basic CMYK support, through the new
1048<a href="/pkg/image/color/#CMYK"><code>CMYK</code></a> struct,
1049the <a href="/pkg/image/color/#CMYKModel"><code>CMYKModel</code></a> color model, and the
1050<a href="/pkg/image/color/#CMYKToRGB"><code>CMYKToRGB</code></a> function, as
1051needed by some JPEG images.
1052</li>
1053
1054<li>
Rob Pike902345e2015-07-14 15:20:19 +10001055Also in the <a href="/pkg/image/color/"><code>image/color</code></a> package,
1056the conversion of a <a href="/pkg/image/color/#YCbCr"><code>YCbCr</code></a>
1057value to <code>RGBA</code> has become more precise.
1058Previously, the low 8 bits were just an echo of the high 8 bits;
1059now they contain more accurate information.
1060Because of the echo property of the old code, the operation
Ian Lance Taylor443ec4f2015-07-14 08:14:03 -07001061<code>uint8(r)</code> to extract an 8-bit red value worked, but is incorrect.
Rob Pike902345e2015-07-14 15:20:19 +10001062In Go 1.5, that operation may yield a different value.
1063The correct code is, and always was, to select the high 8 bits:
1064<code>uint8(r&gt;&gt;8)</code>.
Rob Pike54eb9ef2015-08-19 13:44:33 +10001065Incidentally, the <code>image/draw</code> package
Rob Pike902345e2015-07-14 15:20:19 +10001066provides better support for such conversions; see
1067<a href="https://blog.golang.org/go-imagedraw-package">this blog post</a>
1068for more information.
1069</li>
1070
1071<li>
1072Finally, as of Go 1.5 the closest match check in
1073<a href="/pkg/image/color/#Palette.Index"><code>Index</code></a>
1074now honors the alpha channel.
1075</li>
1076
1077<li>
Rob Pike09b54632015-07-02 12:56:51 +10001078The <a href="/pkg/image/gif/"><code>image/gif</code></a> package
1079includes a couple of generalizations.
1080A multiple-frame GIF file can now have an overall bounds different
1081from all the contained single frames' bounds.
1082Also, the <a href="/pkg/image/gif/#GIF"><code>GIF</code></a> struct
1083now has a <code>Disposal</code> field
1084that specifies the disposal method for each frame.
1085</li>
1086
1087<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001088The <a href="/pkg/io/"><code>io</code></a> package
1089adds a <a href="/pkg/io/#CopyBuffer"><code>CopyBuffer</code></a> function
1090that is like <a href="/pkg/io/#Copy"><code>Copy</code></a> but
1091uses a caller-provided buffer, permitting control of allocation and buffer size.
Rob Pike751eef82015-06-25 16:20:27 +10001092</li>
1093
1094<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001095The <a href="/pkg/log/"><code>log</code></a> package
1096has a new <a href="/pkg/log/#LUTC"><code>LUTC</code></a> flag
1097that causes time stamps to be printed in the UTC time zone.
Ian Lance Taylord7aae332015-08-16 12:20:31 -07001098It also adds a <a href="/pkg/log/#Logger.SetOutput"><code>SetOutput</code></a> method
1099for user-created loggers.
Rob Pike751eef82015-06-25 16:20:27 +10001100</li>
1101
1102<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001103In Go 1.4, <a href="/pkg/math/#Max"><code>Max</code></a> was not detecting all possible NaN bit patterns.
1104This is fixed in Go 1.5, so programs that use <code>math.Max</code> on data including NaNs may behave differently,
1105but now correctly according to the IEEE754 definition of NaNs.
Rob Pike751eef82015-06-25 16:20:27 +10001106</li>
1107
1108<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001109The <a href="/pkg/math/big/"><code>math/big</code></a> package
1110adds a new <a href="/pkg/math/big/#Jacobi"><code>Jacobi</code></a>
Rob Pike54eb9ef2015-08-19 13:44:33 +10001111function for integers and a new
Rob Pike0ea3f582015-06-26 11:52:21 +10001112<a href="/pkg/math/big/#Int.ModSqrt"><code>ModSqrt</code></a>
1113method for the <a href="/pkg/math/big/#Int"><code>Int</code></a> type.
Rob Pike751eef82015-06-25 16:20:27 +10001114</li>
1115
1116<li>
Rob Pike09b54632015-07-02 12:56:51 +10001117The mime package
1118adds a new <a href="/pkg/mime/#WordDecoder"><code>WordDecoder</code></a> type
1119to decode MIME headers containing RFC 204-encoded words.
1120It also provides <a href="/pkg/mime/#BEncoding"><code>BEncoding</code></a> and
1121<a href="/pkg/mime/#QEncoding"><code>QEncoding</code></a>
1122as implementations of the encoding schemes of RFC 2045 and RFC 2047.
1123</li>
1124
1125<li>
1126The <a href="/pkg/mime/"><code>mime</code></a> package also adds an
Rob Pikec418fe72015-06-29 19:51:56 +10001127<a href="/pkg/mime/#ExtensionsByType"><code>ExtensionsByType</code></a>
1128function that returns the MIME extensions know to be associated with a given MIME type.
Rob Pike751eef82015-06-25 16:20:27 +10001129</li>
1130
1131<li>
Rob Pike6fe9c4a2015-07-01 08:48:19 +10001132There is a new <a href="/pkg/mime/quotedprintable/"><code>mime/quotedprintable</code></a>
1133package that implements the quoted-printable encoding defined by RFC 2045.
1134</li>
1135
1136<li>
Paul Marksabf943a2015-07-17 14:23:26 -07001137The <a href="/pkg/net/"><code>net</code></a> package will now
1138<a href="/pkg/net/#Dial"><code>Dial</code></a> hostnames by trying each
1139IP address in order until one succeeds.
1140The <code><a href="/pkg/net/#Dialer">Dialer</a>.DualStack</code>
1141mode now implements Happy Eyeballs
1142(<a href="https://tools.ietf.org/html/rfc6555">RFC 6555</a>) by giving the
1143first address family a 300ms head start; this value can be overridden by
1144the new <code>Dialer.FallbackDelay</code>.
Rob Pike751eef82015-06-25 16:20:27 +10001145</li>
1146
1147<li>
Rob Pikecd2e2f62015-07-01 15:49:40 +10001148A number of inconsistencies in the types returned by errors in the
1149<a href="/pkg/net/"><code>net</code></a> package have been
1150tidied up.
1151Most now return an
1152<a href="/pkg/net/#OpError"><code>OpError</code></a> value
1153with more information than before.
1154Also, the <a href="/pkg/net/#OpError"><code>OpError</code></a>
1155type now includes a <code>Source</code> field that holds the local
1156network address.
Rob Pike751eef82015-06-25 16:20:27 +10001157</li>
1158
1159<li>
Rob Pikecd2e2f62015-07-01 15:49:40 +10001160The <a href="/pkg/net/http/"><code>net/http</code></a> package now
1161has support for setting trailers from a server <a href="/pkg/net/http/#Handler"><code>Handler</code></a>.
1162For details, see the documentation for
1163<a href="/pkg/net/http/#ResponseWriter"><code>ResponseWriter</code></a>.
Rob Pike751eef82015-06-25 16:20:27 +10001164</li>
1165
1166<li>
Brad Fitzpatricke28ff1f2015-07-20 12:30:06 -07001167There is a new method to cancel a <a href="/pkg/net/http/"><code>net/http</code></a>
1168<code>Request</code> by setting the new
1169<a href="/pkg/net/http/#Request"><code>Request.Cancel</code></a>
1170field.
1171It is supported by <code>http.Transport</code>.
1172The <code>Cancel</code> field's type is compatible with the
1173<a href="https://godoc.org/golang.org/x/net/context"><code>context.Context.Done</code></a>
1174return value.
1175</li>
1176
1177<li>
Rob Pikecd2e2f62015-07-01 15:49:40 +10001178Also in the <a href="/pkg/net/http/"><code>net/http</code></a> package,
1179there is code to ignore the zero <a href="/pkg/time/#Time"><code>Time</code></a> value
1180in the <a href="/pkg/net/#ServeContent"><code>ServeContent</code></a> function.
1181As of Go 1.5, it now also ignores a time value equal to the Unix epoch.
Rob Pike751eef82015-06-25 16:20:27 +10001182</li>
1183
1184<li>
Rob Pike09b54632015-07-02 12:56:51 +10001185The <a href="/pkg/net/http/fcgi/"><code>net/http/fcgi</code></a> package
1186exports two new errors,
1187<a href="/pkg/net/http/fcgi/#ErrConnClosed"><code>ErrConnClosed</code></a> and
1188<a href="/pkg/net/http/fcgi/#ErrRequestAborted"><code>ErrRequestAborted</code></a>,
1189to report the corresponding error conditions.
1190</li>
1191
1192<li>
Rob Pikecd2e2f62015-07-01 15:49:40 +10001193The <a href="/pkg/net/http/cgi/"><code>net/http/cgi</code></a> package
1194had a bug that mishandled the values of the environment variables
Mikio Hara91e3b352015-08-06 11:18:27 +09001195<code>REMOTE_ADDR</code> and <code>REMOTE_HOST</code>.
Rob Pikecd2e2f62015-07-01 15:49:40 +10001196This has been fixed.
1197Also, starting with Go 1.5 the package sets the <code>REMOTE_PORT</code>
1198variable.
Rob Pike751eef82015-06-25 16:20:27 +10001199</li>
1200
1201<li>
Rob Pikecd2e2f62015-07-01 15:49:40 +10001202The <a href="/pkg/net/mail/"><code>net/mail</code></a> package
Rob Pike54eb9ef2015-08-19 13:44:33 +10001203adds an <a href="/pkg/net/mail/#AddressParser"><code>AddressParser</code></a>
Rob Pikecd2e2f62015-07-01 15:49:40 +10001204type that can parse mail addresses.
Rob Pike751eef82015-06-25 16:20:27 +10001205</li>
1206
1207<li>
Rob Pikecd2e2f62015-07-01 15:49:40 +10001208The <a href="/pkg/net/smtp/"><code>net/smtp</code></a> package
1209now has a <a href="/pkg/net/smtp/#Client.TLSConnectionState"><code>TLSConnectionState</code></a>
1210accessor to the <a href="/pkg/net/smtp/#Client"><code>Client</code></a>
1211type that returns the client's TLS state.
Rob Pike751eef82015-06-25 16:20:27 +10001212</li>
1213
1214<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001215The <a href="/pkg/os/"><code>os</code></a> package
1216has a new <a href="/pkg/os/#LookupEnv"><code>LookupEnv</code></a> function
1217that is similar to <a href="/pkg/os/#Getenv"><code>Getenv</code></a>
1218but can distinguish between an empty environment variable and a missing one.
Rob Pike751eef82015-06-25 16:20:27 +10001219</li>
1220
1221<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001222The <a href="/pkg/os/signal/"><code>os/signal</code></a> package
1223adds new <a href="/pkg/os/signal/#Ignore"><code>Ignore</code></a> and
1224<a href="/pkg/os/signal/#Reset"><code>Reset</code></a> functions.
Rob Pike751eef82015-06-25 16:20:27 +10001225</li>
1226
1227<li>
Rob Pike09b54632015-07-02 12:56:51 +10001228The <a href="/pkg/runtime/"><code>runtime</code></a>,
Russ Cox15798222015-08-05 10:20:02 -04001229<a href="/pkg/runtime/trace/"><code>runtime/trace</code></a>,
Rob Pike09b54632015-07-02 12:56:51 +10001230and <a href="/pkg/net/http/pprof/"><code>net/http/pprof</code></a> packages
1231each have new functions to support the tracing facilities described above:
1232<a href="/pkg/runtime/#ReadTrace"><code>ReadTrace</code></a>,
1233<a href="/pkg/runtime/#StartTrace"><code>StartTrace</code></a>,
1234<a href="/pkg/runtime/#StopTrace"><code>StopTrace</code></a>,
Dmitry Vyukovde641ef2015-08-04 09:11:06 +02001235<a href="/pkg/runtime/trace/#Start"><code>Start</code></a>,
1236<a href="/pkg/runtime/trace/#Stop"><code>Stop</code></a>, and
Rob Pike09b54632015-07-02 12:56:51 +10001237<a href="/pkg/net/http/pprof/#Trace"><code>Trace</code></a>.
1238See the respective documentation for details.
1239</li>
1240
1241<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001242The <a href="/pkg/runtime/pprof/"><code>runtime/pprof</code></a> package
1243by default now includes overall memory statistics in all memory profiles.
Rob Pike751eef82015-06-25 16:20:27 +10001244</li>
1245
1246<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001247The <a href="/pkg/strings/"><code>strings</code></a> package
1248has a new <a href="/pkg/strings/#Compare"><code>Compare</code></a> function.
1249This is present to provide symmetry with the <a href="/pkg/bytes/"><code>bytes</code></a> package
1250but is otherwise unnecessary as strings support comparison natively.
Rob Pike751eef82015-06-25 16:20:27 +10001251</li>
1252
1253<li>
Russ Cox4b145d42015-08-06 16:05:56 -04001254The <a href="/pkg/sync/#WaitGroup"><code>WaitGroup</code></a> implementation in
Rob Pikec418fe72015-06-29 19:51:56 +10001255package <a href="/pkg/sync/"><code>sync</code></a>
1256now diagnoses code that races a call to <a href="/pkg/sync/#WaitGroup.Add"><code>Add</code></a>
1257against a return from <a href="/pkg/sync/#WaitGroup.Wait"><code>Wait</code></a>.
Russ Cox4b145d42015-08-06 16:05:56 -04001258If it detects this condition, the implementation panics.
Rob Pikec418fe72015-06-29 19:51:56 +10001259</li>
1260
1261<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001262In the <a href="/pkg/syscall/"><code>syscall</code></a> package,
1263the Linux <code>SysProcAttr</code> struct now has a
1264<code>GidMappingsEnableSetgroups</code> field, made necessary
1265by security changes in Linux 3.19.
1266On all Unix systems, the struct also has new <code>Foreground</code> and <code>Pgid</code> fields
1267to provide more control when exec'ing.
1268On Darwin, there is now a <code>Syscall9</code> function
1269to support calls with too many arguments.
Rob Pike751eef82015-06-25 16:20:27 +10001270</li>
1271
1272<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001273The <a href="/pkg/testing/quick/"><code>testing/quick</code></a> will now
1274generate <code>nil</code> values for pointer types,
1275making it possible to use with recursive data structures.
1276Also, the package now supports generation of array types.
Rob Pike751eef82015-06-25 16:20:27 +10001277</li>
1278
1279<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001280In the <a href="/pkg/text/template/"><code>text/template</code></a> and
1281<a href="/pkg/html/template/"><code>html/template</code></a> packages,
1282integer constants too large to be represented as a Go integer now trigger a
1283parse error. Before, they were silently converted to floating point, losing
1284precision.
Rob Pike751eef82015-06-25 16:20:27 +10001285</li>
1286
1287<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001288Also in the <a href="/pkg/text/template/"><code>text/template</code></a> and
1289<a href="/pkg/html/template/"><code>html/template</code></a> packages,
Rob Pike54eb9ef2015-08-19 13:44:33 +10001290a new <a href="/pkg/text/template/#Template.Option"><code>Option</code></a> method
Rob Pike0ea3f582015-06-26 11:52:21 +10001291allows customization of the behavior of the template during execution.
1292The sole implemented option allows control over how a missing key is
1293handled when indexing a map.
1294The default, which can now be overridden, is as before: to continue with an invalid value.
Rob Pike751eef82015-06-25 16:20:27 +10001295</li>
1296
1297<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001298The <a href="/pkg/time/"><code>time</code></a> package's
1299<code>Time</code> type has a new method
Rob Pike902345e2015-07-14 15:20:19 +10001300<a href="/pkg/time/#Time.AppendFormat"><code>AppendFormat</code></a>,
Rob Pike0ea3f582015-06-26 11:52:21 +10001301which can be used to avoid allocation when printing a time value.
Rob Pike751eef82015-06-25 16:20:27 +10001302</li>
1303
1304<li>
Rob Pike0ea3f582015-06-26 11:52:21 +10001305The <a href="/pkg/unicode/"><code>unicode</code></a> package and associated
1306support throughout the system has been upgraded from version 7.0 to
1307<a href="http://www.unicode.org/versions/Unicode8.0.0/">Unicode 8.0</a>.
Rob Pike751eef82015-06-25 16:20:27 +10001308</li>
1309
1310</ul>