Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 1 | <!--{ |
| 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 Pike | 6cbc538 | 2013-09-10 15:13:45 +1000 | [diff] [blame] | 10 | <font color=red> |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 11 | RED TEXT IS FROM THE 1.1 DOC AND NEEDS TO BE UPDATED. (It is here for |
| 12 | formatting and style reference.) |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 13 | </font> |
| 14 | </p> |
| 15 | |
| 16 | <p> |
Rob Pike | 6cbc538 | 2013-09-10 15:13:45 +1000 | [diff] [blame] | 17 | Since the release of <a href="/doc/go1.1.html">Go version 1.1</a> in April, 2013, |
| 18 | the release schedule has been shortened to make the release process more efficient. |
| 19 | This release, Go version 1.2 or Go 1.2 for short, arrives roughly six months after 1.1, |
| 20 | while 1.1 took over a year to appear after 1.0. |
| 21 | Because of the shorter time scale, 1.2 is a smaller delta than the step from 1.0 to 1.1, |
| 22 | but it still has some significant developments, including |
| 23 | a better scheduler and one new language feature. |
| 24 | Of course, Go 1.2 keeps the <a href="/doc/go1compat.html">promise |
| 25 | of compatibility</a>. |
| 26 | The overwhelming majority of programs built with Go 1.1 (or 1.0 for that matter) |
| 27 | will run without any changes whatsoever when moved to 1.2, |
| 28 | although the introduction of one restriction |
| 29 | to 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 Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 31 | </p> |
| 32 | |
| 33 | <h2 id="language">Changes to the language</h2> |
| 34 | |
| 35 | <p> |
Rob Pike | 6cbc538 | 2013-09-10 15:13:45 +1000 | [diff] [blame] | 36 | In the interest of firming up the specification, one corner case has been clarified, |
| 37 | with consequences for programs. |
| 38 | There is also one new language feature. |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 39 | </p> |
| 40 | |
Rob Pike | 6cbc538 | 2013-09-10 15:13:45 +1000 | [diff] [blame] | 41 | <h3 id="use_of_nil">Use of nil</h3> |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 42 | |
| 43 | <p> |
Rob Pike | 6cbc538 | 2013-09-10 15:13:45 +1000 | [diff] [blame] | 44 | The language now specifies that, for safety reasons, |
| 45 | certain uses of nil pointers are guaranteed to trigger a run-time panic. |
| 46 | For instance, in Go 1.0, given code like |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 47 | </p> |
| 48 | |
Rob Pike | 6cbc538 | 2013-09-10 15:13:45 +1000 | [diff] [blame] | 49 | <pre> |
| 50 | type T struct { |
| 51 | X [1<<24]byte |
| 52 | Field int32 |
| 53 | } |
| 54 | |
| 55 | func main() { |
| 56 | var x *T |
| 57 | ... |
| 58 | } |
| 59 | </pre> |
| 60 | |
| 61 | <p> |
| 62 | the <code>nil</code> pointer <code>x</code> could be used to access memory incorrectly: |
| 63 | the expression <code>x.Field</code> could access memory at address <code>1<<24</code>. |
| 64 | To prevent such unsafe behavior, in Go 1.2 the compilers now guarantee that any indirection through |
| 65 | a nil pointer, such as illustrated here but also in nil pointers to arrays, nil interface values, |
| 66 | nil slices, and so on, will either panic or return a correct, safe non-nil value. |
| 67 | In short, any expression that explicitly or implicitly requires evaluation of a nil address is an error. |
| 68 | The implementation may inject extra tests into the compiled program to enforce this behavior. |
| 69 | </p> |
| 70 | |
| 71 | <p> |
| 72 | Further details are in the |
| 73 | <a href="http://golang.org/s/go12nil">design document</a>. |
| 74 | </p> |
| 75 | |
| 76 | <p> |
| 77 | <em>Updating</em>: |
| 78 | Most code that depended on the old behavior is erroneous and will fail when run. |
| 79 | Such programs will need to be updated by hand. |
| 80 | </p> |
| 81 | |
| 82 | <h3 id="three_index">Three-index slices</h3> |
| 83 | |
| 84 | <p> |
| 85 | Go 1.2 adds the ability to specify the capacity as well as the length when using a slicing operation |
| 86 | on an existing array or slice. |
| 87 | A slicing operation creates a new slice by describing a contiguous section of an already-created array or slice: |
| 88 | </p> |
| 89 | |
| 90 | <pre> |
| 91 | var array [10]int |
| 92 | slice := array[2:4] |
| 93 | </pre> |
| 94 | |
| 95 | <p> |
| 96 | The capacity of the slice is the maximum number of elements that the slice may hold, even after reslicing; |
| 97 | it reflects the size of the underlying array. |
| 98 | In this example, the capacity of the <code>slice</code> variable is 8. |
| 99 | </p> |
| 100 | |
| 101 | <p> |
| 102 | Go 1.2 adds new syntax to allow a slicing operation to specify the capacity as well as the length. |
| 103 | A second |
| 104 | colon introduces the capacity value, which must be less than or equal to the capacity of the |
| 105 | source slice or array, adjusted for the origin. For instance, |
| 106 | </p> |
| 107 | |
| 108 | <pre> |
| 109 | slice = array[2:4:6] |
| 110 | </pre> |
| 111 | |
| 112 | <p> |
| 113 | sets the slice to have the same length as in the earlier example but its capacity is now only 4 elements (6-2). |
| 114 | It is impossible to use this new slice value to access the last two elements of the original array. |
| 115 | </p> |
| 116 | |
| 117 | <p> |
| 118 | In this three-index notation, a missing first index (<code>[:i:j]</code>) defaults to zero but the other |
| 119 | two indices must always be specified explicitly. |
| 120 | It is possible that future releases of Go may introduce default values for these indices. |
| 121 | </p> |
| 122 | |
| 123 | <p> |
| 124 | Further details are in the |
| 125 | <a href="http://golang.org/s/go12slice">design document</a>. |
| 126 | </p> |
| 127 | |
| 128 | <p> |
| 129 | <em>Updating</em>: |
| 130 | This is a backwards-compatible change that affects no existing programs. |
| 131 | </p> |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 132 | |
| 133 | <h2 id="impl">Changes to the implementations and tools</h2> |
| 134 | |
| 135 | <ul> |
| 136 | <li> |
| 137 | runtime: preemption of goroutines at function entry (CL 12371043). |
| 138 | </li> |
| 139 | |
| 140 | <li> |
| 141 | go/build: support including C++ code with cgo (CL 8248043). |
| 142 | </li> |
| 143 | </ul> |
| 144 | |
Rob Pike | 6cbc538 | 2013-09-10 15:13:45 +1000 | [diff] [blame] | 145 | <h3 id="go_tools_godoc">Godoc moved to the go.tools subrepository</h3> |
| 146 | |
| 147 | <p> |
| 148 | A 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. |
| 151 | The 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>, |
| 153 | while 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>. |
| 155 | The move allows the code to be updated easily and the separation into a library and command |
| 156 | makes it easier to construct custom binaries for local sites and different deployment methods. |
| 157 | </p> |
| 158 | |
| 159 | <p> |
| 160 | <em>Updating</em>: |
| 161 | Since godoc was not part of the library, |
| 162 | no client code depends on the godoc sources and no updating is required. |
| 163 | </p> |
| 164 | |
| 165 | <p> |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 166 | The binary distributions available from <a href="http://golang.org">golang.org</a> |
Rob Pike | 6cbc538 | 2013-09-10 15:13:45 +1000 | [diff] [blame] | 167 | include a godoc binary, so users of these distributions are unaffected. |
| 168 | </p> |
| 169 | |
| 170 | <p> |
| 171 | When 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> |
| 181 | TODO |
| 182 | </p> |
| 183 | |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 184 | <h3 id="gccgo">Status of gccgo</h3> |
| 185 | |
| 186 | <p> |
Rob Pike | c0ac667 | 2013-09-12 10:12:26 +1000 | [diff] [blame] | 187 | We expect the future GCC 4.9 release to include gccgo with full |
| 188 | support for Go 1.2. |
| 189 | In the current (4.8.2) release of GCC, gccgo implements Go 1.1.2. |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 190 | </p> |
| 191 | |
| 192 | <h3 id="gc_changes">TODO</h3> |
| 193 | |
| 194 | <p> |
| 195 | TODO: 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> |
| 234 | The 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> |
| 242 | An 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> |
| 249 | Go 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> |
| 257 | The performance of code compiled with the Go 1.1 gc tool suite should be noticeably |
| 258 | better for most Go programs. |
| 259 | Typical improvements relative to Go 1.0 seem to be about 30%-40%, sometimes |
| 260 | much more, but occasionally less or even non-existent. |
| 261 | There are too many small performance-driven tweaks through the tools and libraries |
| 262 | to list them all here, but the following major changes are worth noting: |
| 263 | </font> |
| 264 | </p> |
| 265 | |
| 266 | <ul> |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 267 | <li>compress/bzip2: TODO faster decompression by 30% (CL 9915043). |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 268 | </li> |
| 269 | |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 270 | <li>crypto/des: TODO 5x faster encoding/decoding (CL 11874043, 12072045). |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 271 | </li> |
| 272 | |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 273 | <li>encoding/json: TODO faster encoding (CL 9129044). |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 274 | </li> |
| 275 | |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 276 | <li>net: TODO improve windows performance by up to 30% (CL 8670044). |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 277 | </li> |
| 278 | |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 279 | <li>net: TODO improve performance on BSD by up to 30% (CL 8264043, 12927048, 13080043). |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 280 | </li> |
| 281 | </ul> |
| 282 | |
| 283 | <h2 id="library">Changes to the standard library</h2> |
| 284 | |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 285 | |
| 286 | <h3 id="archive_tar_zip">The archive/tar and archive/zip packages</h3> |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 287 | |
| 288 | <p> |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 289 | Breaking change: TODO |
| 290 | archive/tar,archive/zip: fix os.FileInfo implementation to provide base name only (CL 13118043). |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 291 | </p> |
| 292 | |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 293 | <h3 id="encoding">The new encoding package</h3> |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 294 | |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 295 | <p> |
| 296 | encoding: TODO new package defining generic encoding interfaces (CL 12541051). |
| 297 | </p> |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 298 | |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 299 | <h3 id="fmt_indexed_arguments">The fmt package</h3> |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 300 | |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 301 | <p> |
| 302 | The <a href="/pkg/fmt/"><code>fmt</code></a> package's formatted print |
| 303 | routines such as <a href="/pkg/fmt/#Printf"><code>Printf</code></a> |
| 304 | now allow the data items to be printed to be accessed in arbitrary order |
| 305 | by using an indexing operation in the formatting specifications. |
| 306 | Wherever an argument is to be fetched from the argument list for formatting, |
| 307 | either as the value to be formatted or as a width or specification integer, |
| 308 | a new optional indexing notation <code>[</code><em>n</em><code>]</code> |
| 309 | fetches argument <em>n</em> instead. |
| 310 | The value of <em>n</em> is 1-indexed. |
| 311 | After such an indexing operating, the next argument to be fetched by normal |
| 312 | processing will be <em>n</em>+1. |
| 313 | </p> |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 314 | |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 315 | <p> |
| 316 | For example, the normal <code>Printf</code> call |
| 317 | </p> |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 318 | |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 319 | <pre> |
| 320 | fmt.Sprintf("%c %c %c\n", 'a', 'b', 'c') |
| 321 | </pre> |
| 322 | |
| 323 | <p> |
| 324 | would create the string <code>"a b c"</code>, but with indexing operations like this, |
| 325 | </p> |
| 326 | |
| 327 | <pre> |
| 328 | fmt.Sprintf("%[3]c %[1]c %c\n", 'a', 'b', 'c') |
| 329 | </pre> |
| 330 | |
| 331 | <p> |
| 332 | the result is "<code>"c a b"</code>. The <code>[3]</code> index accesses the third formatting |
| 333 | argument, whch is <code>'c'</code>, <code>[1]</code> accesses the first, <code>'a'</code>, |
| 334 | and then the next fetch accesses the argument following that one, <code>'b'</code>. |
| 335 | </p> |
| 336 | |
| 337 | <p> |
| 338 | The motivation for this feature is programmable format statements to access |
| 339 | the arguments in different order for localization, but it has other uses: |
| 340 | </p> |
| 341 | |
| 342 | <pre> |
| 343 | log.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 |
| 348 | is 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> |
| 354 | The |
| 355 | <a href="/pkg/text/template/"><code>text/template</code></a> package |
| 356 | has 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> |
| 361 | First, there are new default functions for comparing basic types. |
| 362 | The functions are listed in this table, which shows their names and |
| 363 | the 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><</code></td> |
| 378 | </tr> |
| 379 | <tr> |
| 380 | <td></td><td><code>le</code></td> <td><code><=</code></td> |
| 381 | </tr> |
| 382 | <tr> |
| 383 | <td></td><td><code>gt</code></td> <td><code>></code></td> |
| 384 | </tr> |
| 385 | <tr> |
| 386 | <td></td><td><code>ge</code></td> <td><code>>=</code></td> |
| 387 | </tr> |
| 388 | </table> |
| 389 | |
| 390 | <p> |
| 391 | These functions behave slightly differently from the corresponding Go operators. |
| 392 | First, 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.) |
| 395 | Second, values can be compared as long as they are the same sort of value: |
| 396 | any signed integer value can be compared to any other signed integer value for example. (Go |
| 397 | does not permit comparing an <code>int8</code> and an <code>int16</code>). |
| 398 | Finally, the <code>eq</code> function (only) allows comparison of the first |
| 399 | argument 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> |
| 407 | reports "equal" if <code>.A</code> is equal to <em>any</em> of 1, 2, or 3. |
| 408 | </p> |
| 409 | |
| 410 | <p> |
| 411 | The second change is that a small addition to the grammar makes "if else if" chains easier to write. |
| 412 | Instead 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> |
| 420 | one 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> |
| 428 | The 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 |
| 433 | already define functions called <code>eq</code> and so on through a function |
| 434 | map are unaffected because the associated function map will override the new |
| 435 | default function definitions. |
| 436 | </p> |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 437 | |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 438 | <h3 id="minor_library_changes">Minor changes to the library</h3> |
| 439 | |
| 440 | <p> |
| 441 | The following list summarizes a number of minor changes to the library, mostly additions. |
| 442 | See the relevant package documentation for more information about each change. |
| 443 | </p> |
| 444 | |
| 445 | <ul> |
| 446 | |
| 447 | <li> |
| 448 | The <a href="/pkg/archive/zip/"><code>archive/zip</code></a> package |
| 449 | adds the |
| 450 | <a href="/pkg/archive/zip/#File.DataOffset"><code>DataOffset</code></a> accessor |
| 451 | to return the offset of a file's (possibly compressed) data within the archive. |
| 452 | </li> |
| 453 | |
| 454 | <li> |
| 455 | The <a href="/pkg/bufio/"><code>bufio</code></a> package |
| 456 | adds <a href="/pkg/bufio/#Reader.Reset"><code>Reset</code></a> |
| 457 | methods to <a href="/pkg/bufio/#Reader"><code>Reader</code></a> and |
| 458 | <a href="/pkg/bufio/#Writer"><code>Writer</code></a>. |
| 459 | These methods allow the <a href="/pkg/Reader/"><code>Readers</code></a> |
| 460 | and <a href="/pkg/Writer/"><code>Writers</code></a> |
| 461 | to be re-used on new input and output readers and writers, saving |
| 462 | allocation overhead. |
| 463 | </li> |
| 464 | |
| 465 | <li> |
| 466 | The <a href="/pkg/compress/bzip2/"><code>compress/bzip2</code></a> |
| 467 | can now decompress concatenated archives. |
| 468 | </li> |
| 469 | |
| 470 | <li> |
| 471 | The <a href="/pkg/compress/flate/"><code>compress/flate</code></a> |
| 472 | package adds a <a href="/pkg/compress/flate/#Reset"><code>Reset</code></a> |
| 473 | method on the <a href="/pkg/compress/flate/#Writer"><code>Writer</code></a>, |
| 474 | allowing compression of one file to start with another's dictionary. |
| 475 | </li> |
| 476 | |
| 477 | <li> |
| 478 | compress/gzip: add Reset method on Writer (CL 13435043). |
| 479 | </li> |
| 480 | |
| 481 | <li> |
| 482 | The <a href="/pkg/container/heap/"><code>container/heap</code></a> package |
| 483 | adds a <a href="/pkg/container/heap/#Fix"><code>Fix</code></a> |
| 484 | method to provide a more efficient way to update an item's position in the heap. |
| 485 | </li> |
| 486 | |
| 487 | <li> |
| 488 | The <a href="/pkg/container/list/"><code>container/list</code></a> package |
| 489 | adds the <a href="/pkg/container/list/#MoveBefore"><code>MoveBefore</code></a> |
| 490 | and |
| 491 | <a href="/pkg/container/list/#MoveAfter"><code>MoveAfter</code></a> |
| 492 | methods, which implement the obvious rearrangement. |
| 493 | </li> |
| 494 | |
| 495 | <li> |
| 496 | The <a href="/pkg/crypto/cipher/"><code>crypto/cipher</code></a> package |
| 497 | adds the a new GCM mode (Galois Counter Mode), which is almost always |
| 498 | used with AES encryption. |
| 499 | </li> |
| 500 | |
| 501 | <li> |
| 502 | The |
| 503 | <a href="/pkg/crypto/md5/"><code>crypto/md5</code></a> package |
| 504 | adds a new <a href="/pkg/crypto/md5/#Sum"><code>Sum</code></a> function |
| 505 | to simplify hashing without sacrificing performance. |
| 506 | </li> |
| 507 | |
| 508 | <li> |
| 509 | Similarly, the |
| 510 | <a href="/pkg/crypto/md5/"><code>crypto/sha1</code></a> package |
| 511 | adds a new <a href="/pkg/crypto/sha1/#Sum"><code>Sum</code></a> function. |
| 512 | </li> |
| 513 | |
| 514 | <li> |
| 515 | Also, the |
| 516 | <a href="/pkg/crypto/sha256/"><code>crypto/sha256</code></a> package |
| 517 | adds <a href="/pkg/crypto/sha256/#Sum256"><code>Sum256</code></a> |
| 518 | and <a href="/pkg/crypto/sha256/#Sum224"><code>Sum224</code></a> functions. |
| 519 | </li> |
| 520 | |
| 521 | <li> |
| 522 | Finally, the <a href="/pkg/crypto/sha512/"><code>crypto/sha512</code></a> package |
| 523 | adds <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> |
| 528 | The <a href="/pkg/crypto/x509/"><code>crypto/x509</code></a> package |
| 529 | adds support for reading and writing arbitrary extensions. |
| 530 | </li> |
| 531 | |
| 532 | <li> |
| 533 | The <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> package adds |
| 534 | support for TLS 1.1, 1.2 and AES-GCM. |
| 535 | </li> |
| 536 | |
| 537 | <li> |
| 538 | The <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> |
| 540 | method on <a href="/pkg/database/sql/#DB"><code>DB</code></a> to limit the |
| 541 | number of open connections to the database. |
| 542 | </li> |
| 543 | |
| 544 | <li> |
| 545 | The <a href="/pkg/encoding/csv/"><code>encoding/csv</code></a> package |
| 546 | now always allows trailing commas on fields. |
| 547 | </li> |
| 548 | |
| 549 | <li> |
| 550 | The <a href="/pkg/encoding/gob/"><code>encoding/gob</code></a> package |
| 551 | now supports the generic encoding interfaces of the |
| 552 | <a href="/pkg/encoding/"><code>encoding</code></a> package |
| 553 | described above. |
| 554 | </li> |
| 555 | |
| 556 | <li> |
| 557 | The <a href="/pkg/encoding/json/"><code>encoding/json</code></a> package |
Rob Pike | 6cbc538 | 2013-09-10 15:13:45 +1000 | [diff] [blame] | 558 | now will always escape ampersands as "\u0026" when printing strings. |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 559 | It 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). |
| 562 | Finally, it now supports the generic encoding interfaces of the |
| 563 | <a href="/pkg/encoding/"><code>encoding</code></a> package |
| 564 | described above. |
| 565 | </li> |
| 566 | |
| 567 | <li> |
| 568 | The <a href="/pkg/encoding/xml/"><code>encoding/xml</code></a> package |
| 569 | now allows attributes stored in pointers to be marshaled. |
| 570 | It also supports the generic encoding interfaces of the |
| 571 | <a href="/pkg/encoding/"><code>encoding</code></a> package |
| 572 | described above through the new |
| 573 | <a href="/pkg/encoding/xml/#Marshaler"><code>Marshaler</code></a>, |
Rob Pike | 6cbc538 | 2013-09-10 15:13:45 +1000 | [diff] [blame] | 574 | <a href="/pkg/encoding/xml/#Unmarshaler"><code>Unmarshaler</code></a>, |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 575 | and related |
| 576 | <a href="/pkg/encoding/xml/#MarshalerAttr"><code>MarshalerAttr</code></a> and |
| 577 | <a href="/pkg/encoding/xml/#UnmarshalerAttr"><code>UnmarshalerAttr</code></a> |
| 578 | interfaces. |
| 579 | </li> |
| 580 | |
| 581 | <li> |
| 582 | The <a href="/pkg/flag/"><code>flag</code></a> package now |
| 583 | has a <a href="/pkg/flag/#Getter"><code>Getter</code></a> interface |
| 584 | to allow the value of a flag to be retrieved. Due to the |
| 585 | Go 1 compatibility guidelines, this method cannot be added to the existing |
| 586 | <a href="/pkg/flag/#Value"><code>Value</code></a> |
| 587 | interface, but all the existing standard flag types implement it. |
| 588 | The package also now exports the <a href="/pkg/flag/#CommandLine"><code>CommandLine</code></a> |
| 589 | flag set, which holds the flags from the command line. |
| 590 | </li> |
| 591 | |
| 592 | <li> |
| 593 | The <a href="/pkg/go/build/"><code>go/build</code></a> package adds |
| 594 | the <a href="/pkg/go/build/#Package.AllTags"><code>AllTags</code></a> field |
| 595 | to the <a href="/pkg/go/build/#Package"><code>Package</code></a> type, |
| 596 | to make it easier to process build tags. |
| 597 | </li> |
| 598 | |
| 599 | <li> |
| 600 | The <a href="/pkg/image/draw/"><code>image/draw</code></a> package now |
| 601 | exports an interface, <a href="/pkg/image/draw/#Drawer"><code>Drawer</code></a>, |
| 602 | that wraps the standard <a href="/pkg/image/draw/#Draw"><code>Draw</code></a> method. |
| 603 | The Porter-Duff operators now implement this interface, in effect binding an operation to |
| 604 | the draw operator rather than providing it explicitly. |
| 605 | Given a paletted image as its destination, the new |
| 606 | <a href="/pkg/image/draw/#FloydSteinberg"><code>FloydSteinberg</code></a> |
| 607 | implementation of the |
| 608 | <a href="/pkg/image/draw/#Drawer"><code>Drawer</code></a> |
| 609 | interface will use the Floyd-Steinberg error diffusion algorithm to draw the image. |
| 610 | To create palettes suitable for such processing, the new |
| 611 | <a href="/pkg/image/draw/#Quantizer"><code>Quantizer</code></a> interface |
| 612 | represents implementations of quantization algorithms that choose a palette |
| 613 | given a full-color image. |
| 614 | There are no implementations of this interface in the library. |
| 615 | </li> |
| 616 | |
| 617 | <li> |
| 618 | The <a href="/pkg/image/gif/"><code>image/gif</code></a> package |
| 619 | can now create GIF files using the new |
| 620 | <a href="/pkg/image/gif/#Encode"><code>Encode</code></a> |
| 621 | and <a href="/pkg/image/gif/#EncodeAll"><code>EncodeAll</code></a> |
| 622 | functions. |
| 623 | Their options argument allows specification of an image |
| 624 | <a href="/pkg/image/draw/#Quantizer"><code>Quantizer</code></a> to use; |
| 625 | if it is <code>nil</code>, the generated GIF will use the |
| 626 | <a href="/pkg/image/color/palette/#Plan9"><code>Plan9</code></a> |
| 627 | color map (palette) defined in the new |
| 628 | <a href="/pkg/image/color/palette/"><code>image/color/palette</code></a> package. |
| 629 | The options also specify a |
| 630 | <a href="/pkg/image/draw/#Drawer"><code>Drawer</code></a> |
| 631 | to use to create the output image; |
| 632 | if it is <code>nil</code>, Floyd-Steinberg error diffusion is used. |
| 633 | </li> |
| 634 | |
| 635 | <li> |
Mikio Hara | 28a8e9b | 2013-09-12 15:12:40 +0900 | [diff] [blame^] | 636 | The <a href="/pkg/io/#Copy"><code>Copy</code></a> method of the |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 637 | <a href="/pkg/io/"><code>io</code></a> package now prioritizes its |
| 638 | arguments differently. |
| 639 | If one argument implements <a href="/pkg/io/#WriterTo"><code>WriterTo</code></a> |
Mikio Hara | 28a8e9b | 2013-09-12 15:12:40 +0900 | [diff] [blame^] | 640 | and the other implements <a href="/pkg/io/#ReaderFrom"><code>ReaderFrom</code></a>, |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 641 | <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, |
| 643 | so that less intermediate buffering is required in general. |
| 644 | </li> |
| 645 | |
| 646 | <li> |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 647 | net: TODO new build tag netgo for building a pure Go net package (CL 7100050). |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 648 | </li> |
| 649 | |
| 650 | <li> |
Mikio Hara | 28a8e9b | 2013-09-12 15:12:40 +0900 | [diff] [blame^] | 651 | The <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> |
| 653 | struct 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 Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 658 | net/http: TODO don't allow sending invalid cookie lines (CL 12204043). |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 659 | </li> |
| 660 | |
| 661 | <li> |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 662 | net/http: TODO allow ReadResponse with nil *Request parameter (CL 9821043). |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 663 | </li> |
| 664 | |
| 665 | <li> |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 666 | net/http: TODO allow responses to HEAD requests, detect type and length (CL 12583043). |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 667 | </li> |
| 668 | |
| 669 | <li> |
| 670 | The <a href="/pkg/runtime/"><code>runtime</code></a> package relaxes |
| 671 | the constraints on finalizer functions in |
| 672 | <a href="/pkg/runtime/#SetFinalizer"><code>SetFinalizer</code></a>: the |
| 673 | actual argument can now be any type that is assignable to the formal type of |
| 674 | the function, as is the case for any normal function call in Go. |
| 675 | </li> |
| 676 | |
| 677 | <li> |
| 678 | The <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 |
| 680 | stable sorting. It is less efficient than the normal sort algorithm, however. |
| 681 | </li> |
| 682 | |
| 683 | <li> |
| 684 | The <a href="/pkg/strings/"><code>strings</code></a> package adds |
| 685 | an <a href="/pkg/strings/#IndexByte"><code>IndexByte</code></a> |
| 686 | function for consistency with the <a href="/pkg/bytes/"><code>bytes</code></a> package. |
| 687 | </li> |
| 688 | |
| 689 | <li> |
Rob Pike | a97a7c5 | 2013-09-12 09:08:59 +1000 | [diff] [blame] | 690 | The <a href="/pkg/sync/atomic/"><code>sync/atomic</code></a> package |
| 691 | adds a new set of swap functions that atomically exchange the argument with the |
| 692 | value stored in the pointer, returning the old value. |
| 693 | The 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>, |
| 699 | and |
| 700 | <a href="/pkg/sync/atomic/#SwapPointer"><code>SwapPointer</code></a>, |
| 701 | which swaps an <code>unsafe.Pointer</code>. |
| 702 | </li> |
| 703 | |
| 704 | <li> |
Rob Pike | 5863b7d | 2013-09-09 13:29:08 +1000 | [diff] [blame] | 705 | syscall: implemented Sendfile for Darwin, added Syscall9 for Darwin/amd64 (CL 10980043). |
| 706 | </li> |
| 707 | |
| 708 | <li> |
| 709 | The <a href="/pkg/testing/"><code>testing</code></a> package |
| 710 | now exports the<a href="/pkg/testing/#TB"><code>TB</code></a> interface. |
| 711 | It records the methods in common with the |
| 712 | <a href="/pkg/testing/#T"><code>T</code></a> |
| 713 | and |
| 714 | <a href="/pkg/testing/#B"><code>B</code></a> types, |
| 715 | to make it easier to share code between tests and benchmarks. |
| 716 | Also, the |
| 717 | <a href="/pkg/testing/#AllocsPerRun"><code>AllocsPerRun</code></a> |
| 718 | function now quantizes the return value to an integer (although it |
| 719 | still has type <code>float64</code>), to round off any error caused by |
| 720 | initialization and make the result more repeatable. |
| 721 | </li> |
| 722 | |
| 723 | <li> |
| 724 | The <a href="/pkg/text/template/"><code>text/template</code></a> package |
| 725 | now automatically dereferences pointer values when evaluating the arguments |
| 726 | to "escape" functions such as "html", to bring the behavior of such functions |
| 727 | in agreement with that of other printing functions such as "printf". |
| 728 | </li> |
| 729 | |
| 730 | <li> |
| 731 | In the <a href="/pkg/time/"><code>time</code></a> package, the |
| 732 | <a href="/pkg/time/#Parse"><code>Parse</code></a> function |
| 733 | and |
| 734 | <a href="/pkg/time/#Format"><code>Format</code></a> |
| 735 | method |
| 736 | now handle time zone offsets with seconds, such as in the historical |
| 737 | date "1871-01-01T05:33:02+00:34:08". |
| 738 | Also, pattern matching in the formats for those routines is stricter: a non-lowercase letter |
| 739 | must now follow the standard words such as "Jan" and "Mon". |
| 740 | </li> |
| 741 | |
| 742 | <li> |
| 743 | The <a href="/pkg/unicode/"><code>unicode</code></a> package |
| 744 | adds <a href="/pkg/unicode/#In"><code>In</code></a>, |
| 745 | a nicer-to-use but equivalent version of the original |
| 746 | <a href="/pkg/unicode/#IsOneOf"><code>IsOneOf</code></a>, |
| 747 | to see whether a character is a member of a Unicode category. |
| 748 | </li> |
| 749 | |
| 750 | </ul> |