blob: 1fe616a6d3835ace5b3b8c72d984ed46e84b18d2 [file] [log] [blame]
Rob Pike5863b7d2013-09-09 13:29:08 +10001<!--{
2 "Title": "Go 1.2 Release Notes",
3 "Path": "/doc/go1.2",
4 "Template": true
5}-->
6
7<h2 id="introduction">Introduction to Go 1.2</h2>
8
9<p>
Rob Pike6cbc5382013-09-10 15:13:45 +100010<font color=red>
Rob Pike5863b7d2013-09-09 13:29:08 +100011RED TEXT IS FROM THE 1.1 DOC AND NEEDS TO BE UPDATED. (It is here for
12formatting and style reference.)
Rob Pike5863b7d2013-09-09 13:29:08 +100013</font>
14</p>
15
16<p>
Rob Pike6cbc5382013-09-10 15:13:45 +100017Since the release of <a href="/doc/go1.1.html">Go version 1.1</a> in April, 2013,
18the release schedule has been shortened to make the release process more efficient.
19This release, Go version 1.2 or Go 1.2 for short, arrives roughly six months after 1.1,
20while 1.1 took over a year to appear after 1.0.
21Because of the shorter time scale, 1.2 is a smaller delta than the step from 1.0 to 1.1,
22but it still has some significant developments, including
23a better scheduler and one new language feature.
24Of course, Go 1.2 keeps the <a href="/doc/go1compat.html">promise
25of compatibility</a>.
26The overwhelming majority of programs built with Go 1.1 (or 1.0 for that matter)
27will run without any changes whatsoever when moved to 1.2,
28although the introduction of one restriction
29to a corner of the language may expose already-incorrect code
30(see the discussion of the <a href="#use_of_nil">use of nil</a>).
Rob Pike5863b7d2013-09-09 13:29:08 +100031</p>
32
33<h2 id="language">Changes to the language</h2>
34
35<p>
Rob Pike6cbc5382013-09-10 15:13:45 +100036In the interest of firming up the specification, one corner case has been clarified,
37with consequences for programs.
38There is also one new language feature.
Rob Pike5863b7d2013-09-09 13:29:08 +100039</p>
40
Rob Pike6cbc5382013-09-10 15:13:45 +100041<h3 id="use_of_nil">Use of nil</h3>
Rob Pike5863b7d2013-09-09 13:29:08 +100042
43<p>
Rob Pike6cbc5382013-09-10 15:13:45 +100044The language now specifies that, for safety reasons,
45certain uses of nil pointers are guaranteed to trigger a run-time panic.
46For instance, in Go 1.0, given code like
Rob Pike5863b7d2013-09-09 13:29:08 +100047</p>
48
Rob Pike6cbc5382013-09-10 15:13:45 +100049<pre>
50type T struct {
51 X [1<<24]byte
52 Field int32
53}
54
55func main() {
56 var x *T
57 ...
58}
59</pre>
60
61<p>
62the <code>nil</code> pointer <code>x</code> could be used to access memory incorrectly:
63the expression <code>x.Field</code> could access memory at address <code>1<<24</code>.
64To prevent such unsafe behavior, in Go 1.2 the compilers now guarantee that any indirection through
65a nil pointer, such as illustrated here but also in nil pointers to arrays, nil interface values,
66nil slices, and so on, will either panic or return a correct, safe non-nil value.
67In short, any expression that explicitly or implicitly requires evaluation of a nil address is an error.
68The implementation may inject extra tests into the compiled program to enforce this behavior.
69</p>
70
71<p>
72Further details are in the
73<a href="http://golang.org/s/go12nil">design document</a>.
74</p>
75
76<p>
77<em>Updating</em>:
78Most code that depended on the old behavior is erroneous and will fail when run.
79Such programs will need to be updated by hand.
80</p>
81
82<h3 id="three_index">Three-index slices</h3>
83
84<p>
85Go 1.2 adds the ability to specify the capacity as well as the length when using a slicing operation
86on an existing array or slice.
87A slicing operation creates a new slice by describing a contiguous section of an already-created array or slice:
88</p>
89
90<pre>
91var array [10]int
92slice := array[2:4]
93</pre>
94
95<p>
96The capacity of the slice is the maximum number of elements that the slice may hold, even after reslicing;
97it reflects the size of the underlying array.
98In this example, the capacity of the <code>slice</code> variable is 8.
99</p>
100
101<p>
102Go 1.2 adds new syntax to allow a slicing operation to specify the capacity as well as the length.
103A second
104colon introduces the capacity value, which must be less than or equal to the capacity of the
105source slice or array, adjusted for the origin. For instance,
106</p>
107
108<pre>
109slice = array[2:4:6]
110</pre>
111
112<p>
113sets the slice to have the same length as in the earlier example but its capacity is now only 4 elements (6-2).
114It is impossible to use this new slice value to access the last two elements of the original array.
115</p>
116
117<p>
118In this three-index notation, a missing first index (<code>[:i:j]</code>) defaults to zero but the other
119two indices must always be specified explicitly.
120It is possible that future releases of Go may introduce default values for these indices.
121</p>
122
123<p>
124Further details are in the
125<a href="http://golang.org/s/go12slice">design document</a>.
126</p>
127
128<p>
129<em>Updating</em>:
130This is a backwards-compatible change that affects no existing programs.
131</p>
Rob Pike5863b7d2013-09-09 13:29:08 +1000132
133<h2 id="impl">Changes to the implementations and tools</h2>
134
135<ul>
136<li>
137runtime: preemption of goroutines at function entry (CL 12371043).
138</li>
139
140<li>
141go/build: support including C++ code with cgo (CL 8248043).
142</li>
143</ul>
144
Rob Pike6cbc5382013-09-10 15:13:45 +1000145<h3 id="go_tools_godoc">Godoc moved to the go.tools subrepository</h3>
146
147<p>
148A binary is still included with the distribution, but the source code for the
149<code>godoc</code> command has moved to the
150<a href="http://code.google.com/p/go.tools">go.tools</a> subrepository.
151The core of the program has been split into a
152<a href="https://code.google.com/p/go/source/browse/?repo=tools#hg%2Fgodoc">library</a>,
153while the command itself is in a separate
154<a href="https://code.google.com/p/go/source/browse/?repo=tools#hg%2Fcmd%2Fgodoc">directory</a>.
155The move allows the code to be updated easily and the separation into a library and command
156makes it easier to construct custom binaries for local sites and different deployment methods.
157</p>
158
159<p>
160<em>Updating</em>:
161Since godoc was not part of the library,
162no client code depends on the godoc sources and no updating is required.
163</p>
164
165<p>
Rob Pikea97a7c52013-09-12 09:08:59 +1000166The binary distributions available from <a href="http://golang.org">golang.org</a>
Rob Pike6cbc5382013-09-10 15:13:45 +1000167include a godoc binary, so users of these distributions are unaffected.
168</p>
169
170<p>
171When building from source, users must use "go get" to install godoc.
172</p>
173
174<pre>
175$ go get code.google.com/p/go.tools/cmd/godoc
176</pre>
177
178<h3 id="go_tools_vet">The vet tool moved to the go.tools subrepository</h3>
179
180<p>
181TODO
182</p>
183
Rob Pike5863b7d2013-09-09 13:29:08 +1000184<h3 id="gccgo">Status of gccgo</h3>
185
186<p>
Rob Pikec0ac6672013-09-12 10:12:26 +1000187We expect the future GCC 4.9 release to include gccgo with full
188support for Go 1.2.
189In the current (4.8.2) release of GCC, gccgo implements Go 1.1.2.
Rob Pike5863b7d2013-09-09 13:29:08 +1000190</p>
191
192<h3 id="gc_changes">TODO</h3>
193
194<p>
195TODO: write prose
196</p>
197
198<ul>
199<li>cmd/5a: removed support for R9/R10 (use m/g instead) (CL 9840043).
200</li>
201
202<li>cmd/5l: add MOVBS, MOVHS etc for sub-word moves (CL 12682043).
203</li>
204
205<li>cmd/5l: support for external linking for linux/arm (CL 12871044).
206</li>
207
208<li>cmd/cgo, cmd/go: support including C++ code with cgo (CL 8248043).
209</li>
210
211<li>cmd/gc: make missing package error fatal (CL 12677043).
212</li>
213</ul>
214
215<h3 id="gocmd">Changes to the go command</h3>
216
217<ul>
218<li>cmd/go: test coverage (CL 10413044).
219</li>
220
221<li>cmd/go: add -t flag to 'go get' to download test dependencies (CL 12566046).
222</li>
223
224<li>cmd/go: delete 'go doc' (CL 12974043).
225</li>
226
227</ul>
228
229
230<h3 id="platforms">Additional platforms</h3>
231
232<p>
233<font color=red>
234The Go 1.1 tool chain adds experimental support for <code>freebsd/arm</code>,
235<code>netbsd/386</code>, <code>netbsd/amd64</code>, <code>netbsd/arm</code>,
236<code>openbsd/386</code> and <code>openbsd/amd64</code> platforms.
237</font>
238</p>
239
240<p>
241<font color=red>
242An ARMv6 or later processor is required for <code>freebsd/arm</code> or
243<code>netbsd/arm</code>.
244</font>
245</p>
246
247<p>
248<font color=red>
249Go 1.1 adds experimental support for <code>cgo</code> on <code>linux/arm</code>.
250</font>
251</p>
252
253<h2 id="performance">Performance</h2>
254
255<p>
256<font color=red>
257The performance of code compiled with the Go 1.1 gc tool suite should be noticeably
258better for most Go programs.
259Typical improvements relative to Go 1.0 seem to be about 30%-40%, sometimes
260much more, but occasionally less or even non-existent.
261There are too many small performance-driven tweaks through the tools and libraries
262to list them all here, but the following major changes are worth noting:
263</font>
264</p>
265
266<ul>
Rob Pikea97a7c52013-09-12 09:08:59 +1000267<li>compress/bzip2: TODO faster decompression by 30% (CL 9915043).
Rob Pike5863b7d2013-09-09 13:29:08 +1000268</li>
269
Rob Pikea97a7c52013-09-12 09:08:59 +1000270<li>crypto/des: TODO 5x faster encoding/decoding (CL 11874043, 12072045).
Rob Pike5863b7d2013-09-09 13:29:08 +1000271</li>
272
Rob Pikea97a7c52013-09-12 09:08:59 +1000273<li>encoding/json: TODO faster encoding (CL 9129044).
Rob Pike5863b7d2013-09-09 13:29:08 +1000274</li>
275
Rob Pikea97a7c52013-09-12 09:08:59 +1000276<li>net: TODO improve windows performance by up to 30% (CL 8670044).
Rob Pike5863b7d2013-09-09 13:29:08 +1000277</li>
278
Rob Pikea97a7c52013-09-12 09:08:59 +1000279<li>net: TODO improve performance on BSD by up to 30% (CL 8264043, 12927048, 13080043).
Rob Pike5863b7d2013-09-09 13:29:08 +1000280</li>
281</ul>
282
283<h2 id="library">Changes to the standard library</h2>
284
Rob Pikea97a7c52013-09-12 09:08:59 +1000285
286<h3 id="archive_tar_zip">The archive/tar and archive/zip packages</h3>
Rob Pike5863b7d2013-09-09 13:29:08 +1000287
288<p>
Rob Pikea97a7c52013-09-12 09:08:59 +1000289Breaking change: TODO
290archive/tar,archive/zip: fix os.FileInfo implementation to provide base name only (CL 13118043).
Rob Pike5863b7d2013-09-09 13:29:08 +1000291</p>
292
Rob Pikea97a7c52013-09-12 09:08:59 +1000293<h3 id="encoding">The new encoding package</h3>
Rob Pike5863b7d2013-09-09 13:29:08 +1000294
Rob Pikea97a7c52013-09-12 09:08:59 +1000295<p>
296encoding: TODO new package defining generic encoding interfaces (CL 12541051).
297</p>
Rob Pike5863b7d2013-09-09 13:29:08 +1000298
Rob Pikea97a7c52013-09-12 09:08:59 +1000299<h3 id="fmt_indexed_arguments">The fmt package</h3>
Rob Pike5863b7d2013-09-09 13:29:08 +1000300
Rob Pikea97a7c52013-09-12 09:08:59 +1000301<p>
302The <a href="/pkg/fmt/"><code>fmt</code></a> package's formatted print
303routines such as <a href="/pkg/fmt/#Printf"><code>Printf</code></a>
304now allow the data items to be printed to be accessed in arbitrary order
305by using an indexing operation in the formatting specifications.
306Wherever an argument is to be fetched from the argument list for formatting,
307either as the value to be formatted or as a width or specification integer,
308a new optional indexing notation <code>[</code><em>n</em><code>]</code>
309fetches argument <em>n</em> instead.
310The value of <em>n</em> is 1-indexed.
311After such an indexing operating, the next argument to be fetched by normal
312processing will be <em>n</em>+1.
313</p>
Rob Pike5863b7d2013-09-09 13:29:08 +1000314
Rob Pikea97a7c52013-09-12 09:08:59 +1000315<p>
316For example, the normal <code>Printf</code> call
317</p>
Rob Pike5863b7d2013-09-09 13:29:08 +1000318
Rob Pikea97a7c52013-09-12 09:08:59 +1000319<pre>
320fmt.Sprintf("%c %c %c\n", 'a', 'b', 'c')
321</pre>
322
323<p>
324would create the string <code>"a b c"</code>, but with indexing operations like this,
325</p>
326
327<pre>
328fmt.Sprintf("%[3]c %[1]c %c\n", 'a', 'b', 'c')
329</pre>
330
331<p>
332the result is "<code>"c a b"</code>. The <code>[3]</code> index accesses the third formatting
333argument, whch is <code>'c'</code>, <code>[1]</code> accesses the first, <code>'a'</code>,
334and then the next fetch accesses the argument following that one, <code>'b'</code>.
335</p>
336
337<p>
338The motivation for this feature is programmable format statements to access
339the arguments in different order for localization, but it has other uses:
340</p>
341
342<pre>
343log.Printf("trace: value %v of type %[1]T\n", expensiveFunction(a.b[c]))
344</pre>
345
346<p>
347<em>Updating</em>: The change to the syntax of format specifications
348is strictly backwards compatible, so it affects no working programs.
349</p>
350
351<h3 id="text_template">The text/template and html/template packages</h3>
352
353<p>
354The
355<a href="/pkg/text/template/"><code>text/template</code></a> package
356has a couple of changes in Go 1.2, both of which are also mirrored in the
357<a href="/pkg/html/template/"><code>html/template</code></a> package.
358</p>
359
360<p>
361First, there are new default functions for comparing basic types.
362The functions are listed in this table, which shows their names and
363the associated familiar comparison operator.
364</p>
365
366<table cellpadding="0" summary="Template comparison functions">
367<tr>
368<th width="50"></th><th width="100">Name</th> <th width="50">Operator</th>
369</tr>
370<tr>
371<td></td><td><code>eq</code></td> <td><code>==</code></td>
372</tr>
373<tr>
374<td></td><td><code>ne</code></td> <td><code>!=</code></td>
375</tr>
376<tr>
377<td></td><td><code>lt</code></td> <td><code>&lt;</code></td>
378</tr>
379<tr>
380<td></td><td><code>le</code></td> <td><code>&lt;=</code></td>
381</tr>
382<tr>
383<td></td><td><code>gt</code></td> <td><code>&gt;</code></td>
384</tr>
385<tr>
386<td></td><td><code>ge</code></td> <td><code>&gt;=</code></td>
387</tr>
388</table>
389
390<p>
391These functions behave slightly differently from the corresponding Go operators.
392First, they operate only on basic types (<code>bool</code>, <code>int</code>,
393<code>float64</code>, <code>string</code>, etc.).
394(Go allows comparison of arrays and structs as well, under some circumstances.)
395Second, values can be compared as long as they are the same sort of value:
396any signed integer value can be compared to any other signed integer value for example. (Go
397does not permit comparing an <code>int8</code> and an <code>int16</code>).
398Finally, the <code>eq</code> function (only) allows comparison of the first
399argument with one or more following arguments. The template in this example,
400</p>
401
402<pre>
403{{"{{"}}if eq .A 1 2 3 {{"}}"}} equal {{"{{"}}else{{"}}"}} not equal {{"{{"}}end{{"}}"}}
404</pre>
405
406<p>
407reports "equal" if <code>.A</code> is equal to <em>any</em> of 1, 2, or 3.
408</p>
409
410<p>
411The second change is that a small addition to the grammar makes "if else if" chains easier to write.
412Instead of writing,
413</p>
414
415<pre>
416{{"{{"}}if eq .A 1{{"}}"}} X {{"{{"}}else{{"}}"}} {{"{{"}}if eq .A 2{{"}}"}} Y {{"{{"}}end{{"}}"}} {{"{{"}}end{{"}}"}}
417</pre>
418
419<p>
420one can fold the second "if" into the "else" and have only one "end", like this:
421</p>
422
423<pre>
424{{"{{"}}if eq .A 1{{"}}"}} X {{"{{"}}else if eq .A 2{{"}}"}} Y {{"{{"}}end{{"}}"}}
425</pre>
426
427<p>
428The two forms are identical in effect; the difference is just in the syntax.
429</p>
430
431<p>
432<em>Updating</em>: Neither change affects existing programs. Those that
433already define functions called <code>eq</code> and so on through a function
434map are unaffected because the associated function map will override the new
435default function definitions.
436</p>
Rob Pike5863b7d2013-09-09 13:29:08 +1000437
Rob Pike5863b7d2013-09-09 13:29:08 +1000438<h3 id="minor_library_changes">Minor changes to the library</h3>
439
440<p>
441The following list summarizes a number of minor changes to the library, mostly additions.
442See the relevant package documentation for more information about each change.
443</p>
444
445<ul>
446
447<li>
448The <a href="/pkg/archive/zip/"><code>archive/zip</code></a> package
449adds the
450<a href="/pkg/archive/zip/#File.DataOffset"><code>DataOffset</code></a> accessor
451to return the offset of a file's (possibly compressed) data within the archive.
452</li>
453
454<li>
455The <a href="/pkg/bufio/"><code>bufio</code></a> package
456adds <a href="/pkg/bufio/#Reader.Reset"><code>Reset</code></a>
457methods to <a href="/pkg/bufio/#Reader"><code>Reader</code></a> and
458<a href="/pkg/bufio/#Writer"><code>Writer</code></a>.
459These methods allow the <a href="/pkg/Reader/"><code>Readers</code></a>
460and <a href="/pkg/Writer/"><code>Writers</code></a>
461to be re-used on new input and output readers and writers, saving
462allocation overhead.
463</li>
464
465<li>
466The <a href="/pkg/compress/bzip2/"><code>compress/bzip2</code></a>
467can now decompress concatenated archives.
468</li>
469
470<li>
471The <a href="/pkg/compress/flate/"><code>compress/flate</code></a>
472package adds a <a href="/pkg/compress/flate/#Reset"><code>Reset</code></a>
473method on the <a href="/pkg/compress/flate/#Writer"><code>Writer</code></a>,
474allowing compression of one file to start with another's dictionary.
475</li>
476
477<li>
478compress/gzip: add Reset method on Writer (CL 13435043).
479</li>
480
481<li>
482The <a href="/pkg/container/heap/"><code>container/heap</code></a> package
483adds a <a href="/pkg/container/heap/#Fix"><code>Fix</code></a>
484method to provide a more efficient way to update an item's position in the heap.
485</li>
486
487<li>
488The <a href="/pkg/container/list/"><code>container/list</code></a> package
489adds the <a href="/pkg/container/list/#MoveBefore"><code>MoveBefore</code></a>
490and
491<a href="/pkg/container/list/#MoveAfter"><code>MoveAfter</code></a>
492methods, which implement the obvious rearrangement.
493</li>
494
495<li>
496The <a href="/pkg/crypto/cipher/"><code>crypto/cipher</code></a> package
497adds the a new GCM mode (Galois Counter Mode), which is almost always
498used with AES encryption.
499</li>
500
501<li>
502The
503<a href="/pkg/crypto/md5/"><code>crypto/md5</code></a> package
504adds a new <a href="/pkg/crypto/md5/#Sum"><code>Sum</code></a> function
505to simplify hashing without sacrificing performance.
506</li>
507
508<li>
509Similarly, the
510<a href="/pkg/crypto/md5/"><code>crypto/sha1</code></a> package
511adds a new <a href="/pkg/crypto/sha1/#Sum"><code>Sum</code></a> function.
512</li>
513
514<li>
515Also, the
516<a href="/pkg/crypto/sha256/"><code>crypto/sha256</code></a> package
517adds <a href="/pkg/crypto/sha256/#Sum256"><code>Sum256</code></a>
518and <a href="/pkg/crypto/sha256/#Sum224"><code>Sum224</code></a> functions.
519</li>
520
521<li>
522Finally, the <a href="/pkg/crypto/sha512/"><code>crypto/sha512</code></a> package
523adds <a href="/pkg/crypto/sha512/#Sum512"><code>Sum512</code></a> and
524<a href="/pkg/crypto/sha512/#Sum384"><code>Sum384</code></a> functions.
525</li>
526
527<li>
528The <a href="/pkg/crypto/x509/"><code>crypto/x509</code></a> package
529adds support for reading and writing arbitrary extensions.
530</li>
531
532<li>
533The <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> package adds
534support for TLS 1.1, 1.2 and AES-GCM.
535</li>
536
537<li>
538The <a href="/pkg/database/sql/"><code>database/sql</code></a> package adds a
539<a href="/pkg/database/sql/#DB.SetMaxOpenConns"><code>SetMaxOpenConns</code></a>
540method on <a href="/pkg/database/sql/#DB"><code>DB</code></a> to limit the
541number of open connections to the database.
542</li>
543
544<li>
545The <a href="/pkg/encoding/csv/"><code>encoding/csv</code></a> package
546now always allows trailing commas on fields.
547</li>
548
549<li>
550The <a href="/pkg/encoding/gob/"><code>encoding/gob</code></a> package
551now supports the generic encoding interfaces of the
552<a href="/pkg/encoding/"><code>encoding</code></a> package
553described above.
554</li>
555
556<li>
557The <a href="/pkg/encoding/json/"><code>encoding/json</code></a> package
Rob Pike6cbc5382013-09-10 15:13:45 +1000558now will always escape ampersands as "\u0026" when printing strings.
Rob Pike5863b7d2013-09-09 13:29:08 +1000559It will now accept but correct invalid UTF-8 in
560<a href="/pkg/encoding/json/#Marshal"><code>Marshal</code></a>
561(such input was previously rejected).
562Finally, it now supports the generic encoding interfaces of the
563<a href="/pkg/encoding/"><code>encoding</code></a> package
564described above.
565</li>
566
567<li>
568The <a href="/pkg/encoding/xml/"><code>encoding/xml</code></a> package
569now allows attributes stored in pointers to be marshaled.
570It also supports the generic encoding interfaces of the
571<a href="/pkg/encoding/"><code>encoding</code></a> package
572described above through the new
573<a href="/pkg/encoding/xml/#Marshaler"><code>Marshaler</code></a>,
Rob Pike6cbc5382013-09-10 15:13:45 +1000574<a href="/pkg/encoding/xml/#Unmarshaler"><code>Unmarshaler</code></a>,
Rob Pike5863b7d2013-09-09 13:29:08 +1000575and related
576<a href="/pkg/encoding/xml/#MarshalerAttr"><code>MarshalerAttr</code></a> and
577<a href="/pkg/encoding/xml/#UnmarshalerAttr"><code>UnmarshalerAttr</code></a>
578interfaces.
579</li>
580
581<li>
582The <a href="/pkg/flag/"><code>flag</code></a> package now
583has a <a href="/pkg/flag/#Getter"><code>Getter</code></a> interface
584to allow the value of a flag to be retrieved. Due to the
585Go 1 compatibility guidelines, this method cannot be added to the existing
586<a href="/pkg/flag/#Value"><code>Value</code></a>
587interface, but all the existing standard flag types implement it.
588The package also now exports the <a href="/pkg/flag/#CommandLine"><code>CommandLine</code></a>
589flag set, which holds the flags from the command line.
590</li>
591
592<li>
593The <a href="/pkg/go/build/"><code>go/build</code></a> package adds
594the <a href="/pkg/go/build/#Package.AllTags"><code>AllTags</code></a> field
595to the <a href="/pkg/go/build/#Package"><code>Package</code></a> type,
596to make it easier to process build tags.
597</li>
598
599<li>
600The <a href="/pkg/image/draw/"><code>image/draw</code></a> package now
601exports an interface, <a href="/pkg/image/draw/#Drawer"><code>Drawer</code></a>,
602that wraps the standard <a href="/pkg/image/draw/#Draw"><code>Draw</code></a> method.
603The Porter-Duff operators now implement this interface, in effect binding an operation to
604the draw operator rather than providing it explicitly.
605Given a paletted image as its destination, the new
606<a href="/pkg/image/draw/#FloydSteinberg"><code>FloydSteinberg</code></a>
607implementation of the
608<a href="/pkg/image/draw/#Drawer"><code>Drawer</code></a>
609interface will use the Floyd-Steinberg error diffusion algorithm to draw the image.
610To create palettes suitable for such processing, the new
611<a href="/pkg/image/draw/#Quantizer"><code>Quantizer</code></a> interface
612represents implementations of quantization algorithms that choose a palette
613given a full-color image.
614There are no implementations of this interface in the library.
615</li>
616
617<li>
618The <a href="/pkg/image/gif/"><code>image/gif</code></a> package
619can now create GIF files using the new
620<a href="/pkg/image/gif/#Encode"><code>Encode</code></a>
621and <a href="/pkg/image/gif/#EncodeAll"><code>EncodeAll</code></a>
622functions.
623Their options argument allows specification of an image
624<a href="/pkg/image/draw/#Quantizer"><code>Quantizer</code></a> to use;
625if it is <code>nil</code>, the generated GIF will use the
626<a href="/pkg/image/color/palette/#Plan9"><code>Plan9</code></a>
627color map (palette) defined in the new
628<a href="/pkg/image/color/palette/"><code>image/color/palette</code></a> package.
629The options also specify a
630<a href="/pkg/image/draw/#Drawer"><code>Drawer</code></a>
631to use to create the output image;
632if it is <code>nil</code>, Floyd-Steinberg error diffusion is used.
633</li>
634
635<li>
Mikio Hara28a8e9b2013-09-12 15:12:40 +0900636The <a href="/pkg/io/#Copy"><code>Copy</code></a> method of the
Rob Pike5863b7d2013-09-09 13:29:08 +1000637<a href="/pkg/io/"><code>io</code></a> package now prioritizes its
638arguments differently.
639If one argument implements <a href="/pkg/io/#WriterTo"><code>WriterTo</code></a>
Mikio Hara28a8e9b2013-09-12 15:12:40 +0900640and the other implements <a href="/pkg/io/#ReaderFrom"><code>ReaderFrom</code></a>,
Rob Pike5863b7d2013-09-09 13:29:08 +1000641<a href="/pkg/io/#Copy"><code>Copy</code></a> will now invoke
642<a href="/pkg/io/#WriterTo"><code>WriterTo</code></a> to do the work,
643so that less intermediate buffering is required in general.
644</li>
645
646<li>
Rob Pikea97a7c52013-09-12 09:08:59 +1000647net: TODO new build tag netgo for building a pure Go net package (CL 7100050).
Rob Pike5863b7d2013-09-09 13:29:08 +1000648</li>
649
650<li>
Mikio Hara28a8e9b2013-09-12 15:12:40 +0900651The <a href="/pkg/net/"><code>net</code></a> package adds a new field
652<code>DualStack</code> to the <a href="/pkg/net/#Dialer"><code>Dialer</code></a>
653struct for TCP connection setup using a dual IP stack as described in
654<a href="http://tools.ietf.org/html/rfc6555">RFC 6555</a>.
655</li>
656
657<li>
Rob Pikea97a7c52013-09-12 09:08:59 +1000658net/http: TODO don't allow sending invalid cookie lines (CL 12204043).
Rob Pike5863b7d2013-09-09 13:29:08 +1000659</li>
660
661<li>
Rob Pikea97a7c52013-09-12 09:08:59 +1000662net/http: TODO allow ReadResponse with nil *Request parameter (CL 9821043).
Rob Pike5863b7d2013-09-09 13:29:08 +1000663</li>
664
665<li>
Rob Pikea97a7c52013-09-12 09:08:59 +1000666net/http: TODO allow responses to HEAD requests, detect type and length (CL 12583043).
Rob Pike5863b7d2013-09-09 13:29:08 +1000667</li>
668
669<li>
670The <a href="/pkg/runtime/"><code>runtime</code></a> package relaxes
671the constraints on finalizer functions in
672<a href="/pkg/runtime/#SetFinalizer"><code>SetFinalizer</code></a>: the
673actual argument can now be any type that is assignable to the formal type of
674the function, as is the case for any normal function call in Go.
675</li>
676
677<li>
678The <a href="/pkg/sort/"><code>sort</code></a> package has a new
679<a href="/pkg/sort/#Stable"><code>Stable</code></a> function that implements
680stable sorting. It is less efficient than the normal sort algorithm, however.
681</li>
682
683<li>
684The <a href="/pkg/strings/"><code>strings</code></a> package adds
685an <a href="/pkg/strings/#IndexByte"><code>IndexByte</code></a>
686function for consistency with the <a href="/pkg/bytes/"><code>bytes</code></a> package.
687</li>
688
689<li>
Rob Pikea97a7c52013-09-12 09:08:59 +1000690The <a href="/pkg/sync/atomic/"><code>sync/atomic</code></a> package
691adds a new set of swap functions that atomically exchange the argument with the
692value stored in the pointer, returning the old value.
693The functions are
694<a href="/pkg/sync/atomic/#SwapInt32"><code>SwapInt32</code></a>,
695<a href="/pkg/sync/atomic/#SwapInt64"><code>SwapInt64</code></a>,
696<a href="/pkg/sync/atomic/#SwapUint32"><code>SwapUint32</code></a>,
697<a href="/pkg/sync/atomic/#SwapUint64"><code>SwapUint64</code></a>,
698<a href="/pkg/sync/atomic/#SwapUintptr"><code>SwapUintptr</code></a>,
699and
700<a href="/pkg/sync/atomic/#SwapPointer"><code>SwapPointer</code></a>,
701which swaps an <code>unsafe.Pointer</code>.
702</li>
703
704<li>
Rob Pike5863b7d2013-09-09 13:29:08 +1000705syscall: implemented Sendfile for Darwin, added Syscall9 for Darwin/amd64 (CL 10980043).
706</li>
707
708<li>
709The <a href="/pkg/testing/"><code>testing</code></a> package
710now exports the<a href="/pkg/testing/#TB"><code>TB</code></a> interface.
711It records the methods in common with the
712<a href="/pkg/testing/#T"><code>T</code></a>
713and
714<a href="/pkg/testing/#B"><code>B</code></a> types,
715to make it easier to share code between tests and benchmarks.
716Also, the
717<a href="/pkg/testing/#AllocsPerRun"><code>AllocsPerRun</code></a>
718function now quantizes the return value to an integer (although it
719still has type <code>float64</code>), to round off any error caused by
720initialization and make the result more repeatable.
721</li>
722
723<li>
724The <a href="/pkg/text/template/"><code>text/template</code></a> package
725now automatically dereferences pointer values when evaluating the arguments
726to "escape" functions such as "html", to bring the behavior of such functions
727in agreement with that of other printing functions such as "printf".
728</li>
729
730<li>
731In the <a href="/pkg/time/"><code>time</code></a> package, the
732<a href="/pkg/time/#Parse"><code>Parse</code></a> function
733and
734<a href="/pkg/time/#Format"><code>Format</code></a>
735method
736now handle time zone offsets with seconds, such as in the historical
737date "1871-01-01T05:33:02+00:34:08".
738Also, pattern matching in the formats for those routines is stricter: a non-lowercase letter
739must now follow the standard words such as "Jan" and "Mon".
740</li>
741
742<li>
743The <a href="/pkg/unicode/"><code>unicode</code></a> package
744adds <a href="/pkg/unicode/#In"><code>In</code></a>,
745a nicer-to-use but equivalent version of the original
746<a href="/pkg/unicode/#IsOneOf"><code>IsOneOf</code></a>,
747to see whether a character is a member of a Unicode category.
748</li>
749
750</ul>