Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 1 | <!--{ |
| 2 | "Title": "Go 1.3 Release Notes", |
| 3 | "Path": "/doc/go1.3", |
| 4 | "Template": true |
| 5 | }--> |
| 6 | |
| 7 | <h2 id="introduction">Introduction to Go 1.3</h2> |
| 8 | |
| 9 | <p> |
| 10 | The latest Go release, version 1.3, arrives six months after 1.2, |
| 11 | and contains no language changes. |
Rob Pike | c5f14c5 | 2014-04-09 08:19:35 +1000 | [diff] [blame] | 12 | It focuses primarily on implementation work, providing |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 13 | precise garbage collection, |
Rob Pike | c5f14c5 | 2014-04-09 08:19:35 +1000 | [diff] [blame] | 14 | a major refactoring of the compiler tool chain that results in |
| 15 | faster builds, especially for large projects, |
Rob Pike | 78025fb | 2014-04-08 14:07:17 +1000 | [diff] [blame] | 16 | significant performance improvements across the board, |
Mikio Hara | 37323fe | 2014-05-17 06:54:05 +0900 | [diff] [blame] | 17 | and support for DragonFly BSD, Solaris, Plan 9 and Google's Native Client architecture (NaCl). |
Rob Pike | c5f14c5 | 2014-04-09 08:19:35 +1000 | [diff] [blame] | 18 | It also has an important refinement to the memory model regarding synchronization. |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 19 | As always, Go 1.3 keeps the <a href="/doc/go1compat.html">promise |
| 20 | of compatibility</a>, |
| 21 | and almost everything |
| 22 | will continue to compile and run without change when moved to 1.3. |
| 23 | </p> |
| 24 | |
| 25 | <h2 id="os">Changes to the supported operating systems and architectures</h2> |
| 26 | |
Rob Pike | c5f14c5 | 2014-04-09 08:19:35 +1000 | [diff] [blame] | 27 | <h3 id="win2000">Removal of support for Windows 2000</h3> |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 28 | |
| 29 | <p> |
Rob Pike | 78025fb | 2014-04-08 14:07:17 +1000 | [diff] [blame] | 30 | Microsoft stopped supporting Windows 2000 in 2010. |
| 31 | Since it has <a href="https://codereview.appspot.com/74790043">implementation difficulties</a> |
| 32 | regarding exception handling (signals in Unix terminology), |
| 33 | as of Go 1.3 it is not supported by Go either. |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 34 | </p> |
| 35 | |
Mikio Hara | 37323fe | 2014-05-17 06:54:05 +0900 | [diff] [blame] | 36 | <h3 id="dragonfly">Support for DragonFly BSD</h3> |
| 37 | |
| 38 | <p> |
Russ Cox | 7ef0eb1 | 2014-05-20 13:38:45 -0400 | [diff] [blame] | 39 | Go 1.3 now includes experimental support for DragonFly BSD on the <code>amd64</code> (64-bit x86) and <code>386</code> (32-bit x86) architectures. |
| 40 | It uses DragonFly BSD 3.6 or above. |
Mikio Hara | 37323fe | 2014-05-17 06:54:05 +0900 | [diff] [blame] | 41 | </p> |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 42 | |
Emil Hessman | 3af8d6f | 2014-04-16 12:15:39 -0700 | [diff] [blame] | 43 | <h3 id="freebsd">Support for FreeBSD</h3> |
Rob Pike | 59f6c81 | 2014-04-16 10:40:41 -0700 | [diff] [blame] | 44 | |
| 45 | <p> |
| 46 | It was not announced at the time, but since the release of Go 1.2, support for Go on FreeBSD |
| 47 | requires FreeBSD 8 or above. |
| 48 | </p> |
| 49 | |
| 50 | <p> |
| 51 | As of Go 1.3, support for Go on FreeBSD requires that the kernel be compiled with the |
| 52 | <code>COMPAT_FREEBSD32</code> flag configured. |
| 53 | </p> |
| 54 | |
Shenghou Ma | 74dccea | 2014-04-29 15:54:37 -0400 | [diff] [blame] | 55 | <p> |
Russ Cox | 7ef0eb1 | 2014-05-20 13:38:45 -0400 | [diff] [blame] | 56 | In concert with the switch to EABI syscalls for ARM platforms, Go 1.3 will run only on FreeBSD 10. |
| 57 | The x86 platforms, 386 and amd64, are unaffected. |
Shenghou Ma | 74dccea | 2014-04-29 15:54:37 -0400 | [diff] [blame] | 58 | </p> |
| 59 | |
Mikio Hara | 37323fe | 2014-05-17 06:54:05 +0900 | [diff] [blame] | 60 | <h3 id="nacl">Support for Native Client</h3> |
| 61 | |
| 62 | <p> |
| 63 | Support for the Native Client virtual machine architecture has returned to Go with the 1.3 release. |
| 64 | It runs on the 32-bit Intel architectures (<code>GOARCH=386</code>) and also on 64-bit Intel, but using |
| 65 | 32-bit pointers (<code>GOARCH=amd64p32</code>). |
| 66 | There is not yet support for Native Client on ARM. |
| 67 | Note that this is Native Client (NaCl), not Portable Native Client (PNaCl). |
| 68 | Details about Native Client are <a href="https://developers.google.com/native-client/dev/">here</a>; |
Andrew Gerrand | 43ad89d | 2014-07-25 10:28:39 +1000 | [diff] [blame] | 69 | how to set up the Go version is described <a href="//golang.org/wiki/NativeClient">here</a>. |
Mikio Hara | 37323fe | 2014-05-17 06:54:05 +0900 | [diff] [blame] | 70 | </p> |
| 71 | |
| 72 | <h3 id="netbsd">Support for NetBSD</h3> |
| 73 | |
| 74 | <p> |
| 75 | As of Go 1.3, support for Go on NetBSD requires NetBSD 6.0 or above. |
| 76 | </p> |
| 77 | |
| 78 | <h3 id="openbsd">Support for OpenBSD</h3> |
| 79 | |
| 80 | <p> |
Mikio Hara | 77dd411 | 2014-05-18 05:57:40 +0900 | [diff] [blame] | 81 | As of Go 1.3, support for Go on OpenBSD requires OpenBSD 5.5 or above. |
Mikio Hara | 37323fe | 2014-05-17 06:54:05 +0900 | [diff] [blame] | 82 | </p> |
| 83 | |
| 84 | <h3 id="plan9">Support for Plan 9</h3> |
| 85 | |
| 86 | <p> |
Russ Cox | 7ef0eb1 | 2014-05-20 13:38:45 -0400 | [diff] [blame] | 87 | Go 1.3 now includes experimental support for Plan 9 on the <code>386</code> (32-bit x86) architecture. |
| 88 | It requires the <code>Tsemacquire</code> syscall, which has been in Plan 9 since June, 2012. |
Mikio Hara | 37323fe | 2014-05-17 06:54:05 +0900 | [diff] [blame] | 89 | </p> |
| 90 | |
| 91 | <h3 id="solaris">Support for Solaris</h3> |
| 92 | |
| 93 | <p> |
Russ Cox | 7ef0eb1 | 2014-05-20 13:38:45 -0400 | [diff] [blame] | 94 | Go 1.3 now includes experimental support for Solaris on the <code>amd64</code> (64-bit x86) architecture. |
| 95 | It requires illumos, Solaris 11 or above. |
Mikio Hara | 37323fe | 2014-05-17 06:54:05 +0900 | [diff] [blame] | 96 | </p> |
| 97 | |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 98 | <h2 id="memory">Changes to the memory model</h2> |
| 99 | |
| 100 | <p> |
Rob Pike | a438092 | 2014-03-27 11:45:51 +1100 | [diff] [blame] | 101 | The Go 1.3 memory model <a href="https://codereview.appspot.com/75130045">adds a new rule</a> |
| 102 | concerning sending and receiving on buffered channels, |
| 103 | to make explicit that a buffered channel can be used as a simple |
| 104 | semaphore, using a send into the |
| 105 | channel to acquire and a receive from the channel to release. |
| 106 | This is not a language change, just a clarification about an expected property of communication. |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 107 | </p> |
| 108 | |
| 109 | <h2 id="impl">Changes to the implementations and tools</h2> |
| 110 | |
| 111 | <h3 id="stacks">Stack</h3> |
| 112 | |
| 113 | <p> |
Rob Pike | 610f395 | 2014-03-28 12:55:37 +1100 | [diff] [blame] | 114 | Go 1.3 has changed the implementation of goroutine stacks away from the old, |
| 115 | "segmented" model to a contiguous model. |
| 116 | When a goroutine needs more stack |
| 117 | than is available, its stack is transferred to a larger single block of memory. |
| 118 | The overhead of this transfer operation amortizes well and eliminates the old "hot spot" |
| 119 | problem when a calculation repeatedly steps across a segment boundary. |
| 120 | Details including performance numbers are in this |
Andrew Gerrand | 43ad89d | 2014-07-25 10:28:39 +1000 | [diff] [blame] | 121 | <a href="//golang.org/s/contigstacks">design document</a>. |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 122 | </p> |
| 123 | |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 124 | <h3 id="garbage_collector">Changes to the garbage collector</h3> |
| 125 | |
| 126 | <p> |
Rob Pike | b69238b | 2014-04-09 12:47:35 +1000 | [diff] [blame] | 127 | For a while now, the garbage collector has been <em>precise</em> when examining |
| 128 | values in the heap; the Go 1.3 release adds equivalent precision to values on the stack. |
| 129 | This means that a non-pointer Go value such as an integer will never be mistaken for a |
| 130 | pointer and prevent unused memory from being reclaimed. |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 131 | </p> |
| 132 | |
Russ Cox | 208a1ea | 2014-05-15 16:16:26 -0400 | [diff] [blame] | 133 | <p> |
| 134 | Starting with Go 1.3, the runtime assumes that values with pointer type |
| 135 | contain pointers and other values do not. |
| 136 | This assumption is fundamental to the precise behavior of both stack expansion |
| 137 | and garbage collection. |
| 138 | Programs that use <a href="/pkg/unsafe/">package unsafe</a> |
Russ Cox | 8d8dab3 | 2014-05-22 11:45:03 -0400 | [diff] [blame] | 139 | to store integers in pointer-typed values are illegal and will crash if the runtime detects the behavior. |
Russ Cox | 208a1ea | 2014-05-15 16:16:26 -0400 | [diff] [blame] | 140 | Programs that use <a href="/pkg/unsafe/">package unsafe</a> to store pointers |
Russ Cox | 8d8dab3 | 2014-05-22 11:45:03 -0400 | [diff] [blame] | 141 | in integer-typed values are also illegal but more difficult to diagnose during execution. |
Russ Cox | 208a1ea | 2014-05-15 16:16:26 -0400 | [diff] [blame] | 142 | Because the pointers are hidden from the runtime, a stack expansion or garbage collection |
| 143 | may reclaim the memory they point at, creating |
Andrew Gerrand | 43ad89d | 2014-07-25 10:28:39 +1000 | [diff] [blame] | 144 | <a href="//en.wikipedia.org/wiki/Dangling_pointer">dangling pointers</a>. |
Russ Cox | 208a1ea | 2014-05-15 16:16:26 -0400 | [diff] [blame] | 145 | </p> |
| 146 | |
| 147 | <p> |
Russ Cox | 8d8dab3 | 2014-05-22 11:45:03 -0400 | [diff] [blame] | 148 | <em>Updating</em>: Code that uses <code>unsafe.Pointer</code> to convert |
| 149 | an integer-typed value held in memory into a pointer is illegal and must be rewritten. |
Russ Cox | 208a1ea | 2014-05-15 16:16:26 -0400 | [diff] [blame] | 150 | Such code can be identified by <code>go vet</code>. |
| 151 | </p> |
| 152 | |
Russ Cox | d1f627f | 2014-05-16 12:15:21 -0400 | [diff] [blame] | 153 | <h3 id="map">Map iteration</h3> |
| 154 | |
| 155 | <p> |
| 156 | Iterations over small maps no longer happen in a consistent order. |
Andrew Gerrand | 43ad89d | 2014-07-25 10:28:39 +1000 | [diff] [blame] | 157 | Go 1 defines that “<a href="//golang.org/ref/spec#For_statements">The iteration order over maps |
Russ Cox | d1f627f | 2014-05-16 12:15:21 -0400 | [diff] [blame] | 158 | is not specified and is not guaranteed to be the same from one iteration to the next.</a>” |
| 159 | To keep code from depending on map iteration order, |
| 160 | Go 1.0 started each map iteration at a random index in the map. |
| 161 | A new map implementation introduced in Go 1.1 neglected to randomize |
| 162 | iteration for maps with eight or fewer entries, although the iteration order |
| 163 | can still vary from system to system. |
| 164 | This has allowed people to write Go 1.1 and Go 1.2 programs that |
| 165 | depend on small map iteration order and therefore only work reliably on certain systems. |
| 166 | Go 1.3 reintroduces random iteration for small maps in order to flush out these bugs. |
| 167 | </p> |
| 168 | |
| 169 | <p> |
| 170 | <em>Updating</em>: If code assumes a fixed iteration order for small maps, |
| 171 | it will break and must be rewritten not to make that assumption. |
| 172 | Because only small maps are affected, the problem arises most often in tests. |
| 173 | </p> |
| 174 | |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 175 | <h3 id="liblink">The linker</h3> |
| 176 | |
| 177 | <p> |
Andrew Gerrand | 43ad89d | 2014-07-25 10:28:39 +1000 | [diff] [blame] | 178 | As part of the general <a href="//golang.org/s/go13linker">overhaul</a> to |
Rob Pike | c5f14c5 | 2014-04-09 08:19:35 +1000 | [diff] [blame] | 179 | the Go linker, the compilers and linkers have been refactored. |
| 180 | The linker is still a C program, but now the instruction selection phase that |
| 181 | was part of the linker has been moved to the compiler through the creation of a new |
| 182 | library called <code>liblink</code>. |
| 183 | By doing instruction selection only once, when the package is first compiled, |
| 184 | this can speed up compilation of large projects significantly. |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 185 | </p> |
| 186 | |
| 187 | <p> |
Rob Pike | c5f14c5 | 2014-04-09 08:19:35 +1000 | [diff] [blame] | 188 | <em>Updating</em>: Although this is a major internal change, it should have no |
| 189 | effect on programs. |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 190 | </p> |
| 191 | |
| 192 | <h3 id="gccgo">Status of gccgo</h3> |
| 193 | |
| 194 | <p> |
Rob Pike | 96775a3 | 2014-04-09 09:45:39 +1000 | [diff] [blame] | 195 | GCC release 4.9 will contain the Go 1.2 (not 1.3) version of gccgo. |
| 196 | The release schedules for the GCC and Go projects do not coincide, |
| 197 | which means that 1.3 will be available in the development branch but |
| 198 | that the next GCC release, 4.10, will likely have the Go 1.4 version of gccgo. |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 199 | </p> |
| 200 | |
| 201 | <h3 id="gocmd">Changes to the go command</h3> |
| 202 | |
| 203 | <p> |
Rob Pike | 56294f4 | 2014-04-09 15:20:00 +1000 | [diff] [blame] | 204 | The <a href="/cmd/go/"><code>cmd/go</code></a> command has several new |
| 205 | features. |
| 206 | The <a href="/cmd/go/"><code>go run</code></a> and |
| 207 | <a href="/cmd/go/"><code>go test</code></a> subcommands |
| 208 | support a new <code>-exec</code> option to specify an alternate |
| 209 | way to run the resulting binary. |
| 210 | Its immediate purpose is to support NaCl. |
| 211 | </p> |
| 212 | |
| 213 | <p> |
| 214 | The test coverage support of the <a href="/cmd/go/"><code>go test</code></a> |
| 215 | subcommand now automatically sets the coverage mode to <code>-atomic</code> |
| 216 | when the race detector is enabled, to eliminate false reports about unsafe |
| 217 | access to coverage counters. |
| 218 | </p> |
| 219 | |
| 220 | <p> |
Rob Pike | 0d612a8 | 2014-04-18 11:00:38 -0700 | [diff] [blame] | 221 | The <a href="/cmd/go/"><code>go test</code></a> subcommand |
| 222 | now always builds the package, even if it has no test files. |
| 223 | Previously, it would do nothing if no test files were present. |
| 224 | </p> |
| 225 | |
| 226 | <p> |
David Crawshaw | 2702ad3 | 2014-05-06 21:10:36 -0400 | [diff] [blame] | 227 | The <a href="/cmd/go/"><code>go build</code></a> subcommand |
| 228 | supports a new <code>-i</code> option to install dependencies |
| 229 | of the specified target, but not the target itself. |
| 230 | </p> |
| 231 | |
| 232 | <p> |
Elias Naur | 88d07b2 | 2014-05-20 01:32:31 -0400 | [diff] [blame] | 233 | Cross compiling with <a href="/cmd/cgo/"><code>cgo</code></a> enabled |
Russ Cox | 7ef0eb1 | 2014-05-20 13:38:45 -0400 | [diff] [blame] | 234 | is now supported. |
| 235 | The CC_FOR_TARGET and CXX_FOR_TARGET environment |
Elias Naur | 88d07b2 | 2014-05-20 01:32:31 -0400 | [diff] [blame] | 236 | variables are used when running all.bash to specify the cross compilers |
| 237 | for C and C++ code, respectively. |
| 238 | </p> |
| 239 | |
| 240 | <p> |
Rob Pike | 56294f4 | 2014-04-09 15:20:00 +1000 | [diff] [blame] | 241 | Finally, the go command now supports packages that import Objective-C |
| 242 | files (suffixed <code>.m</code>) through cgo. |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 243 | </p> |
| 244 | |
Russ Cox | 7ef0eb1 | 2014-05-20 13:38:45 -0400 | [diff] [blame] | 245 | <h3 id="cgo">Changes to cgo</h3> |
| 246 | |
| 247 | <p> |
| 248 | The <a href="/cmd/cgo/"><code>cmd/cgo</code></a> command, |
| 249 | which processes <code>import "C"</code> declarations in Go packages, |
| 250 | has corrected a serious bug that may cause some packages to stop compiling. |
| 251 | Previously, all pointers to incomplete struct types translated to the Go type <code>*[0]byte</code>, |
| 252 | with the effect that the Go compiler could not diagnose passing one kind of struct pointer |
| 253 | to a function expecting another. |
| 254 | Go 1.3 corrects this mistake by translating each different |
| 255 | incomplete struct to a different named type. |
Russ Cox | 0782ee3 | 2014-05-28 14:04:31 -0400 | [diff] [blame] | 256 | </p> |
| 257 | |
| 258 | <p> |
| 259 | Given the C declaration <code>typedef struct S T</code> for an incomplete <code>struct S</code>, |
| 260 | some Go code used this bug to refer to the types <code>C.struct_S</code> and <code>C.T</code> interchangeably. |
| 261 | Cgo now explicitly allows this use, even for completed struct types. |
| 262 | However, some Go code also used this bug to pass (for example) a <code>*C.FILE</code> |
Russ Cox | 7ef0eb1 | 2014-05-20 13:38:45 -0400 | [diff] [blame] | 263 | from one package to another. |
| 264 | This is not legal and no longer works: in general Go packages |
| 265 | should avoid exposing C types and names in their APIs. |
| 266 | </p> |
| 267 | |
| 268 | <p> |
| 269 | <em>Updating</em>: Code confusing pointers to incomplete types or |
| 270 | passing them across package boundaries will no longer compile |
| 271 | and must be rewritten. |
| 272 | If the conversion is correct and must be preserved, |
| 273 | use an explicit conversion via <a href="/pkg/unsafe/#Pointer"><code>unsafe.Pointer</code></a>. |
| 274 | </p> |
| 275 | |
Ian Lance Taylor | 02cc45a | 2014-05-12 12:43:51 -0700 | [diff] [blame] | 276 | <h3 id="swig">SWIG 3.0 required for programs that use SWIG</h3> |
| 277 | |
| 278 | <p> |
Russ Cox | 7ef0eb1 | 2014-05-20 13:38:45 -0400 | [diff] [blame] | 279 | For Go programs that use SWIG, SWIG version 3.0 is now required. |
| 280 | The <a href="/cmd/go"><code>cmd/go</code></a> command will now link the |
Ian Lance Taylor | 02cc45a | 2014-05-12 12:43:51 -0700 | [diff] [blame] | 281 | SWIG generated object files directly into the binary, rather than |
| 282 | building and linking with a shared library. |
| 283 | </p> |
| 284 | |
Russ Cox | e97b3ab | 2014-04-15 20:46:46 -0400 | [diff] [blame] | 285 | <h3 id="gc_flag">Command-line flag parsing</h3> |
| 286 | |
| 287 | <p> |
| 288 | In the gc tool chain, the assemblers now use the |
| 289 | same command-line flag parsing rules as the Go flag package, a departure |
Russ Cox | 7ef0eb1 | 2014-05-20 13:38:45 -0400 | [diff] [blame] | 290 | from the traditional Unix flag parsing. |
| 291 | This may affect scripts that invoke the tool directly. |
Russ Cox | e97b3ab | 2014-04-15 20:46:46 -0400 | [diff] [blame] | 292 | For example, |
| 293 | <code>go tool 6a -SDfoo</code> must now be written |
| 294 | <code>go tool 6a -S -D foo</code>. |
| 295 | (The same change was made to the compilers and linkers in <a href="/doc/go1.1#gc_flag">Go 1.1</a>.) |
| 296 | </p> |
| 297 | |
Alan Donovan | 0476693 | 2014-06-12 10:08:54 -0400 | [diff] [blame] | 298 | <h3 id="godoc">Changes to godoc</h3> |
| 299 | <p> |
| 300 | When invoked with the <code>-analysis</code> flag, |
Andrew Gerrand | eb91b5f | 2014-12-10 11:01:55 +1100 | [diff] [blame] | 301 | <a href="//godoc.org/golang.org/x/tools/cmd/godoc">godoc</a> |
Alan Donovan | 0476693 | 2014-06-12 10:08:54 -0400 | [diff] [blame] | 302 | now performs sophisticated <a href="/lib/godoc/analysis/help.html">static |
| 303 | analysis</a> of the code it indexes. |
| 304 | The results of analysis are presented in both the source view and the |
| 305 | package documentation view, and include the call graph of each package |
| 306 | and the relationships between |
| 307 | definitions and references, |
| 308 | types and their methods, |
| 309 | interfaces and their implementations, |
| 310 | send and receive operations on channels, |
| 311 | functions and their callers, and |
| 312 | call sites and their callees. |
| 313 | </p> |
| 314 | |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 315 | <h3 id="misc">Miscellany</h3> |
| 316 | |
Rob Pike | c5f14c5 | 2014-04-09 08:19:35 +1000 | [diff] [blame] | 317 | <p> |
| 318 | The program <code>misc/benchcmp</code> that compares |
| 319 | performance across benchmarking runs has been rewritten. |
| 320 | Once a shell and awk script in the main repository, it is now a Go program in the <code>go.tools</code> repo. |
Andrew Gerrand | eb91b5f | 2014-12-10 11:01:55 +1100 | [diff] [blame] | 321 | Documentation is <a href="//godoc.org/golang.org/x/tools/cmd/benchcmp">here</a>. |
Rob Pike | c5f14c5 | 2014-04-09 08:19:35 +1000 | [diff] [blame] | 322 | </p> |
| 323 | |
Rob Pike | 56294f4 | 2014-04-09 15:20:00 +1000 | [diff] [blame] | 324 | <p> |
Rob Pike | c5f14c5 | 2014-04-09 08:19:35 +1000 | [diff] [blame] | 325 | For the few of us that build Go distributions, the tool <code>misc/dist</code> has been |
| 326 | moved and renamed; it now lives in <code>misc/makerelease</code>, still in the main repository. |
Rob Pike | 56294f4 | 2014-04-09 15:20:00 +1000 | [diff] [blame] | 327 | </p> |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 328 | |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 329 | <h2 id="performance">Performance</h2> |
| 330 | |
| 331 | <p> |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 332 | The performance of Go binaries for this release has improved in many cases due to changes |
| 333 | in the runtime and garbage collection, plus some changes to libraries. |
| 334 | Significant instances include: |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 335 | </p> |
| 336 | |
| 337 | <ul> |
| 338 | |
| 339 | <li> |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 340 | The runtime handles defers more efficiently, reducing the memory footprint by about two kilobytes |
| 341 | per goroutine that calls defer. |
| 342 | </li> |
| 343 | |
| 344 | <li> |
| 345 | The garbage collector has been sped up, using a concurrent sweep algorithm, |
| 346 | better parallelization, and larger pages. |
| 347 | The cumulative effect can be a 50-70% reduction in collector pause time. |
| 348 | </li> |
| 349 | |
| 350 | <li> |
Dmitriy Vyukov | 2e1ddeb | 2014-05-07 18:49:13 +0400 | [diff] [blame] | 351 | The race detector (see <a href="/doc/articles/race_detector.html">this guide</a>) |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 352 | is now about 40% faster. |
| 353 | </li> |
| 354 | |
| 355 | <li> |
| 356 | The regular expression package <a href="/pkg/regexp/"><code>regexp</code></a> |
Rob Pike | 1d879fe | 2014-04-11 08:52:16 +1000 | [diff] [blame] | 357 | is now significantly faster for certain simple expressions due to the implementation of |
Russ Cox | 7ef0eb1 | 2014-05-20 13:38:45 -0400 | [diff] [blame] | 358 | a second, one-pass execution engine. |
| 359 | The choice of which engine to use is automatic; |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 360 | the details are hidden from the user. |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 361 | </li> |
| 362 | |
| 363 | </ul> |
| 364 | |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 365 | <p> |
| 366 | Also, the runtime now includes in stack dumps how long a goroutine has been blocked, |
| 367 | which can be useful information when debugging deadlocks or performance issues. |
| 368 | </p> |
| 369 | |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 370 | <h2 id="library">Changes to the standard library</h2> |
| 371 | |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 372 | <h3 id="new_packages">New packages</h3> |
| 373 | |
| 374 | <p> |
David du Colombier | ba59375 | 2014-04-18 10:50:06 +0200 | [diff] [blame] | 375 | A new package <a href="/pkg/debug/plan9obj/"><code>debug/plan9obj</code></a> was added to the standard library. |
| 376 | It implements access to Plan 9 <a href="http://plan9.bell-labs.com/magic/man2html/6/a.out">a.out</a> object files. |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 377 | </p> |
| 378 | |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 379 | <h3 id="major_library_changes">Major changes to the library</h3> |
| 380 | |
| 381 | <p> |
Rob Pike | 56294f4 | 2014-04-09 15:20:00 +1000 | [diff] [blame] | 382 | A previous bug in <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> |
Rob Pike | 1d879fe | 2014-04-11 08:52:16 +1000 | [diff] [blame] | 383 | made it possible to skip verification in TLS inadvertently. |
Rob Pike | 56294f4 | 2014-04-09 15:20:00 +1000 | [diff] [blame] | 384 | In Go 1.3, the bug is fixed: one must specify either ServerName or |
| 385 | InsecureSkipVerify, and if ServerName is specified it is enforced. |
| 386 | This may break existing code that incorrectly depended on insecure |
| 387 | behavior. |
| 388 | </p> |
| 389 | |
| 390 | <p> |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 391 | There is an important new type added to the standard library: <a href="/pkg/sync/#Pool"><code>sync.Pool</code></a>. |
| 392 | It provides an efficient mechanism for implementing certain types of caches whose memory |
| 393 | can be reclaimed automatically by the system. |
| 394 | </p> |
| 395 | |
| 396 | <p> |
Rob Pike | 56294f4 | 2014-04-09 15:20:00 +1000 | [diff] [blame] | 397 | The <a href="/pkg/testing/"><code>testing</code></a> package's benchmarking helper, |
| 398 | <a href="/pkg/testing/#B"><code>B</code></a>, now has a |
| 399 | <a href="/pkg/testing/#B.RunParallel"><code>RunParallel</code></a> method |
| 400 | to make it easier to run benchmarks that exercise multiple CPUs. |
| 401 | </p> |
| 402 | |
| 403 | <p> |
| 404 | <em>Updating</em>: The crypto/tls fix may break existing code, but such |
| 405 | code was erroneous and should be updated. |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 406 | </p> |
| 407 | |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 408 | <h3 id="minor_library_changes">Minor changes to the library</h3> |
| 409 | |
| 410 | <p> |
| 411 | The following list summarizes a number of minor changes to the library, mostly additions. |
| 412 | See the relevant package documentation for more information about each change. |
| 413 | </p> |
| 414 | |
| 415 | <ul> |
| 416 | |
Rob Pike | b6684b3 | 2014-04-10 14:17:48 +1000 | [diff] [blame] | 417 | <li> In the <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> package, |
| 418 | a new <a href="/pkg/crypto/tls/#DialWithDialer"><code>DialWithDialer</code></a> |
| 419 | function lets one establish a TLS connection using an existing dialer, making it easier |
| 420 | to control dial options such as timeouts. |
| 421 | The package also now reports the TLS version used by the connection in the |
| 422 | <a href="/pkg/crypto/tls/#ConnectionState"><code>ConnectionState</code></a> |
| 423 | struct. |
| 424 | </li> |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 425 | |
Rob Pike | b6684b3 | 2014-04-10 14:17:48 +1000 | [diff] [blame] | 426 | <li> The <a href="/pkg/crypto/x509/#CreateCertificate"><code>CreateCertificate</code></a> |
| 427 | function of the <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> package |
| 428 | now supports parsing (and elsewhere, serialization) of PKCS #10 certificate |
| 429 | signature requests. |
| 430 | </li> |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 431 | |
| 432 | <li> |
| 433 | The formatted print functions of the <code>fmt</code> package now define <code>%F</code> |
| 434 | as a synonym for <code>%f</code> when printing floating-point values. |
| 435 | </li> |
| 436 | |
Brad Fitzpatrick | 4f193cd | 2014-04-08 19:46:33 -0700 | [diff] [blame] | 437 | <li> |
Russ Cox | c038c38 | 2014-05-28 15:48:35 -0400 | [diff] [blame] | 438 | The <a href="/pkg/math/big/"><code>math/big</code></a> package's |
| 439 | <a href="/pkg/math/big/#Int"><code>Int</code></a> and |
| 440 | <a href="/pkg/math/big/#Rat"><code>Rat</code></a> types |
| 441 | now implement |
| 442 | <a href="/pkg/encoding/#TextMarshaler"><code>encoding.TextMarshaler</code></a> and |
| 443 | <a href="/pkg/encoding/#TextUnmarshaler"><code>encoding.TextUnmarshaler</code></a>. |
| 444 | </li> |
| 445 | |
| 446 | <li> |
| 447 | The complex power function, <a href="/pkg/math/cmplx/#Pow"><code>Pow</code></a>, |
| 448 | now specifies the behavior when the first argument is zero. |
| 449 | It was undefined before. |
| 450 | The details are in the <a href="/pkg/math/cmplx/#Pow">documentation for the function</a>. |
| 451 | </li> |
| 452 | |
| 453 | <li> |
Brad Fitzpatrick | 4f193cd | 2014-04-08 19:46:33 -0700 | [diff] [blame] | 454 | The <a href="/pkg/net/http/"><code>net/http</code></a> package now exposes the |
Brad Fitzpatrick | 1e68e6a | 2014-04-10 15:09:59 -0700 | [diff] [blame] | 455 | properties of a TLS connection used to make a client request in the new |
Brad Fitzpatrick | 4f193cd | 2014-04-08 19:46:33 -0700 | [diff] [blame] | 456 | <a href="/pkg/net/http/#Response"><code>Response.TLS</code></a> field. |
| 457 | </li> |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 458 | |
Brad Fitzpatrick | 4f193cd | 2014-04-08 19:46:33 -0700 | [diff] [blame] | 459 | <li> |
| 460 | The <a href="/pkg/net/http/"><code>net/http</code></a> package now |
| 461 | allows setting an optional server error logger |
| 462 | with <a href="/pkg/net/http/#Server"><code>Server.ErrorLog</code></a>. |
| 463 | The default is still that all errors go to stderr. |
| 464 | </li> |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 465 | |
Brad Fitzpatrick | 1e68e6a | 2014-04-10 15:09:59 -0700 | [diff] [blame] | 466 | <li> |
| 467 | The <a href="/pkg/net/http/"><code>net/http</code></a> package now |
| 468 | supports disabling HTTP keep-alive connections on the server |
| 469 | with <a href="/pkg/net/http/#Server.SetKeepAlivesEnabled"><code>Server.SetKeepAlivesEnabled</code></a>. |
| 470 | The default continues to be that the server does keep-alive (reuses |
Russ Cox | 7ef0eb1 | 2014-05-20 13:38:45 -0400 | [diff] [blame] | 471 | connections for multiple requests) by default. |
| 472 | Only resource-constrained servers or those in the process of graceful |
Brad Fitzpatrick | 1e68e6a | 2014-04-10 15:09:59 -0700 | [diff] [blame] | 473 | shutdown will want to disable them. |
| 474 | </li> |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 475 | |
Brad Fitzpatrick | 1e68e6a | 2014-04-10 15:09:59 -0700 | [diff] [blame] | 476 | <li> |
| 477 | The <a href="/pkg/net/http/"><code>net/http</code></a> package adds an optional |
| 478 | <a href="/pkg/net/http/#Transport"><code>Transport.TLSHandshakeTimeout</code></a> |
| 479 | setting to cap the amount of time HTTP client requests will wait for |
Russ Cox | 7ef0eb1 | 2014-05-20 13:38:45 -0400 | [diff] [blame] | 480 | TLS handshakes to complete. |
| 481 | It's now also set by default |
Brad Fitzpatrick | 1e68e6a | 2014-04-10 15:09:59 -0700 | [diff] [blame] | 482 | on <a href="/pkg/net/http#DefaultTransport"><code>DefaultTransport</code></a>. |
| 483 | </li> |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 484 | |
Brad Fitzpatrick | 1e68e6a | 2014-04-10 15:09:59 -0700 | [diff] [blame] | 485 | <li> |
| 486 | The <a href="/pkg/net/http/"><code>net/http</code></a> package's |
| 487 | <a href="/pkg/net/http/#DefaultTransport"><code>DefaultTransport</code></a>, |
| 488 | used by the HTTP client code, now |
| 489 | enables <a href="http://en.wikipedia.org/wiki/Keepalive#TCP_keepalive">TCP |
Russ Cox | 7ef0eb1 | 2014-05-20 13:38:45 -0400 | [diff] [blame] | 490 | keep-alives</a> by default. |
| 491 | Other <a href="/pkg/net/http/#Transport"><code>Transport</code></a> |
Brad Fitzpatrick | 1e68e6a | 2014-04-10 15:09:59 -0700 | [diff] [blame] | 492 | values with a nil <code>Dial</code> field continue to function the same |
| 493 | as before: no TCP keep-alives are used. |
| 494 | </li> |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 495 | |
Brad Fitzpatrick | 1e68e6a | 2014-04-10 15:09:59 -0700 | [diff] [blame] | 496 | <li> |
| 497 | The <a href="/pkg/net/http/"><code>net/http</code></a> package |
| 498 | now enables <a href="http://en.wikipedia.org/wiki/Keepalive#TCP_keepalive">TCP |
| 499 | keep-alives</a> for incoming server requests when |
| 500 | <a href="/pkg/net/http/#ListenAndServe"><code>ListenAndServe</code></a> |
| 501 | or |
| 502 | <a href="/pkg/net/http/#ListenAndServeTLS"><code>ListenAndServeTLS</code></a> |
Russ Cox | 7ef0eb1 | 2014-05-20 13:38:45 -0400 | [diff] [blame] | 503 | are used. |
| 504 | When a server is started otherwise, TCP keep-alives are not enabled. |
Brad Fitzpatrick | 1e68e6a | 2014-04-10 15:09:59 -0700 | [diff] [blame] | 505 | </li> |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 506 | |
Brad Fitzpatrick | 1e68e6a | 2014-04-10 15:09:59 -0700 | [diff] [blame] | 507 | <li> |
| 508 | The <a href="/pkg/net/http/"><code>net/http</code></a> package now |
| 509 | provides an |
| 510 | optional <a href="/pkg/net/http/#Server"><code>Server.ConnState</code></a> |
| 511 | callback to hook various phases of a server connection's lifecycle |
Russ Cox | 7ef0eb1 | 2014-05-20 13:38:45 -0400 | [diff] [blame] | 512 | (see <a href="/pkg/net/http/#ConnState"><code>ConnState</code></a>). |
| 513 | This can be used to implement rate limiting or graceful shutdown. |
Brad Fitzpatrick | 1e68e6a | 2014-04-10 15:09:59 -0700 | [diff] [blame] | 514 | </li> |
| 515 | |
| 516 | <li> |
| 517 | The <a href="/pkg/net/http/"><code>net/http</code></a> package's HTTP |
| 518 | client now has an |
| 519 | optional <a href="/pkg/net/http/#Client"><code>Client.Timeout</code></a> |
| 520 | field to specify an end-to-end timeout on requests made using the |
| 521 | client. |
| 522 | </li> |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 523 | |
Andrew Gerrand | af403c0 | 2014-08-07 15:42:06 +1000 | [diff] [blame] | 524 | <li> |
| 525 | The <a href="/pkg/net/http/"><code>net/http</code></a> package's |
| 526 | <a href="/pkg/net/http/#Request.ParseMultipartForm"><code>Request.ParseMultipartForm</code></a> |
| 527 | method will now return an error if the body's <code>Content-Type</code> |
| 528 | is not <code>mutipart/form-data</code>. |
| 529 | Prior to Go 1.3 it would silently fail and return <code>nil</code>. |
| 530 | Code that relies on the previous behavior should be updated. |
| 531 | </li> |
| 532 | |
Rob Pike | b6684b3 | 2014-04-10 14:17:48 +1000 | [diff] [blame] | 533 | <li> In the <a href="/pkg/net/"><code>net</code></a> package, |
| 534 | the <a href="/pkg/net/#Dialer"><code>Dialer</code></a> struct now |
| 535 | has a <code>KeepAlive</code> option to specify a keep-alive period for the connection. |
| 536 | </li> |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 537 | |
Brad Fitzpatrick | 071a0f4 | 2014-04-14 10:19:10 -0700 | [diff] [blame] | 538 | <li> |
| 539 | The <a href="/pkg/net/http/"><code>net/http</code></a> package's |
| 540 | <a href="/pkg/net/http/#Transport"><code>Transport</code></a> |
| 541 | now closes <a href="/pkg/net/http/#Request"><code>Request.Body</code></a> |
Brad Fitzpatrick | 632e641 | 2014-04-14 16:28:52 -0700 | [diff] [blame] | 542 | consistently, even on error. |
Brad Fitzpatrick | 071a0f4 | 2014-04-14 10:19:10 -0700 | [diff] [blame] | 543 | </li> |
| 544 | |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 545 | <li> |
| 546 | The <a href="/pkg/os/exec/"><code>os/exec</code></a> package now implements |
| 547 | what the documentation has always said with regard to relative paths for the binary. |
| 548 | In particular, it only calls <a href="/pkg/os/exec/#LookPath"><code>LookPath</code></a> |
| 549 | when the binary's file name contains no path separators. |
| 550 | </li> |
| 551 | |
| 552 | <li> |
Keith Randall | 4b3019b | 2014-05-23 17:39:58 -0700 | [diff] [blame] | 553 | The <a href="/pkg/reflect/#Value.SetMapIndex"><code>SetMapIndex</code></a> |
| 554 | function in the <a href="/pkg/reflect/"><code>reflect</code></a> package |
| 555 | no longer panics when deleting from a <code>nil</code> map. |
| 556 | </li> |
| 557 | |
| 558 | <li> |
Russ Cox | ade6bc6 | 2014-04-16 13:12:18 -0400 | [diff] [blame] | 559 | If the main goroutine calls |
David du Colombier | f187675 | 2014-04-20 20:29:17 +0200 | [diff] [blame] | 560 | <a href="/pkg/runtime/#Goexit"><code>runtime.Goexit</code></a> |
Russ Cox | ade6bc6 | 2014-04-16 13:12:18 -0400 | [diff] [blame] | 561 | and all other goroutines finish execution, the program now always crashes, |
| 562 | reporting a detected deadlock. |
| 563 | Earlier versions of Go handled this situation inconsistently: most instances |
| 564 | were reported as deadlocks, but some trivial cases exited cleanly instead. |
| 565 | </li> |
| 566 | |
| 567 | <li> |
Ian Lance Taylor | 06b67f3 | 2014-06-02 11:05:46 -0700 | [diff] [blame] | 568 | The runtime/debug package now has a new function |
| 569 | <a href="/pkg/runtime/debug/#WriteHeapDump"><code>debug.WriteHeapDump</code></a> |
| 570 | that writes out a description of the heap. |
| 571 | </li> |
| 572 | |
| 573 | <li> |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 574 | The <a href="/pkg/strconv/#CanBackquote"><code>CanBackquote</code></a> |
| 575 | function in the <a href="/pkg/strconv/"><code>strconv</code></a> package |
| 576 | now considers the <code>DEL</code> character, <code>U+007F</code>, to be |
| 577 | non-printing. |
| 578 | </li> |
| 579 | |
Rob Pike | e9ad3bf | 2014-04-12 14:56:17 +1000 | [diff] [blame] | 580 | <li> |
Mikio Hara | 1704368 | 2014-05-16 13:18:14 +0900 | [diff] [blame] | 581 | The <a href="/pkg/syscall/"><code>syscall</code></a> package now provides |
| 582 | <a href="/pkg/syscall/#SendmsgN"><code>SendmsgN</code></a> |
| 583 | as an alternate version of |
| 584 | <a href="/pkg/syscall/#Sendmsg"><code>Sendmsg</code></a> |
| 585 | that returns the number of bytes written. |
| 586 | </li> |
| 587 | |
| 588 | <li> |
Rob Pike | e9ad3bf | 2014-04-12 14:56:17 +1000 | [diff] [blame] | 589 | On Windows, the <a href="/pkg/syscall/"><code>syscall</code></a> package now |
| 590 | supports the cdecl calling convention through the addition of a new function |
| 591 | <a href="/pkg/syscall/#NewCallbackCDecl"><code>NewCallbackCDecl</code></a> |
| 592 | alongside the existing function |
| 593 | <a href="/pkg/syscall/#NewCallback"><code>NewCallback</code></a>. |
| 594 | </li> |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 595 | |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 596 | <li> |
| 597 | The <a href="/pkg/testing/"><code>testing</code></a> package now |
Rob Pike | c5f14c5 | 2014-04-09 08:19:35 +1000 | [diff] [blame] | 598 | diagnoses tests that call <code>panic(nil)</code>, which are almost always erroneous. |
Russ Cox | 21e75b3 | 2014-05-09 12:18:50 -0400 | [diff] [blame] | 599 | Also, tests now write profiles (if invoked with profiling flags) even on failure. |
Rob Pike | 969dc76 | 2014-04-09 07:12:20 +1000 | [diff] [blame] | 600 | </li> |
| 601 | |
| 602 | <li> |
| 603 | The <a href="/pkg/unicode/"><code>unicode</code></a> package and associated |
| 604 | support throughout the system has been upgraded from |
| 605 | Unicode 6.2.0 to <a href="http://www.unicode.org/versions/Unicode6.3.0/">Unicode 6.3.0</a>. |
| 606 | </li> |
| 607 | |
Rob Pike | 09e1da3 | 2014-03-26 13:56:16 +1100 | [diff] [blame] | 608 | </ul> |