Russ Cox | 04c64e9 | 2021-02-12 16:18:26 -0500 | [diff] [blame] | 1 | <!--{ |
Russ Cox | 4c9e549 | 2021-02-25 20:49:34 -0500 | [diff] [blame] | 2 | "Title": "Go 1.8 Release Notes" |
Russ Cox | 04c64e9 | 2021-02-12 16:18:26 -0500 | [diff] [blame] | 3 | }--> |
| 4 | |
| 5 | <!-- |
| 6 | NOTE: In this document and others in this directory, the convention is to |
| 7 | set fixed-width phrases with non-fixed-width spaces, as in |
| 8 | <code>hello</code> <code>world</code>. |
| 9 | Do not send CLs removing the interior tags from such phrases. |
| 10 | --> |
| 11 | |
| 12 | <style> |
| 13 | main ul li { margin: 0.5em 0; } |
| 14 | </style> |
| 15 | |
| 16 | <h2 id="introduction">Introduction to Go 1.8</h2> |
| 17 | |
| 18 | <p> |
| 19 | The latest Go release, version 1.8, arrives six months after <a href="go1.7">Go 1.7</a>. |
| 20 | Most of its changes are in the implementation of the toolchain, runtime, and libraries. |
| 21 | There are <a href="#language">two minor changes</a> to the language specification. |
| 22 | As always, the release maintains the Go 1 <a href="/doc/go1compat.html">promise of compatibility</a>. |
| 23 | We expect almost all Go programs to continue to compile and run as before. |
| 24 | </p> |
| 25 | |
| 26 | <p> |
| 27 | The release <a href="#ports">adds support for 32-bit MIPS</a>, |
| 28 | <a href="#compiler">updates the compiler back end</a> to generate more efficient code, |
| 29 | <a href="#gc">reduces GC pauses</a> by eliminating stop-the-world stack rescanning, |
| 30 | <a href="#h2push">adds HTTP/2 Push support</a>, |
| 31 | <a href="#http_shutdown">adds HTTP graceful shutdown</a>, |
| 32 | <a href="#more_context">adds more context support</a>, |
| 33 | <a href="#mutex_prof">enables profiling mutexes</a>, |
| 34 | and <a href="#sort_slice">simplifies sorting slices</a>. |
| 35 | </p> |
| 36 | |
| 37 | <h2 id="language">Changes to the language</h2> |
| 38 | |
| 39 | <p> |
| 40 | When explicitly converting a value from one struct type to another, |
| 41 | as of Go 1.8 the tags are ignored. Thus two structs that differ |
| 42 | only in their tags may be converted from one to the other: |
| 43 | </p> |
| 44 | |
| 45 | <pre> |
| 46 | func example() { |
| 47 | type T1 struct { |
| 48 | X int `json:"foo"` |
| 49 | } |
| 50 | type T2 struct { |
| 51 | X int `json:"bar"` |
| 52 | } |
| 53 | var v1 T1 |
| 54 | var v2 T2 |
| 55 | v1 = T1(v2) // now legal |
| 56 | } |
| 57 | </pre> |
| 58 | |
| 59 | |
| 60 | <p> <!-- CL 17711 --> |
| 61 | The language specification now only requires that implementations |
| 62 | support up to 16-bit exponents in floating-point constants. This does not affect |
| 63 | either the “<a href="/cmd/compile/"><code>gc</code></a>” or |
| 64 | <code>gccgo</code> compilers, both of |
| 65 | which still support 32-bit exponents. |
| 66 | </p> |
| 67 | |
| 68 | <h2 id="ports">Ports</h2> |
| 69 | |
| 70 | <p> |
| 71 | Go now supports 32-bit MIPS on Linux for both big-endian |
| 72 | (<code>linux/mips</code>) and little-endian machines |
| 73 | (<code>linux/mipsle</code>) that implement the MIPS32r1 instruction set with FPU |
| 74 | or kernel FPU emulation. Note that many common MIPS-based routers lack an FPU and |
| 75 | have firmware that doesn't enable kernel FPU emulation; Go won't run on such machines. |
| 76 | </p> |
| 77 | |
| 78 | <p> |
| 79 | On DragonFly BSD, Go now requires DragonFly 4.4.4 or later. <!-- CL 29491, CL 29971 --> |
| 80 | </p> |
| 81 | |
| 82 | <p> |
| 83 | On OpenBSD, Go now requires OpenBSD 5.9 or later. <!-- CL 34093 --> |
| 84 | </p> |
| 85 | |
| 86 | <p> |
| 87 | The Plan 9 port's networking support is now much more complete |
| 88 | and matches the behavior of Unix and Windows with respect to deadlines |
Russ Cox | c471313 | 2021-12-06 12:32:45 -0500 | [diff] [blame] | 89 | and cancellation. For Plan 9 kernel requirements, see the |
Russ Cox | ab4f479 | 2021-11-17 22:34:23 -0500 | [diff] [blame] | 90 | <a href="/wiki/Plan9">Plan 9 wiki page</a>. |
Russ Cox | 04c64e9 | 2021-02-12 16:18:26 -0500 | [diff] [blame] | 91 | </p> |
| 92 | |
| 93 | <p> |
| 94 | Go 1.8 now only supports OS X 10.8 or later. This is likely the last |
| 95 | Go release to support 10.8. Compiling Go or running |
| 96 | binaries on older OS X versions is untested. |
| 97 | </p> |
| 98 | |
| 99 | <p> |
| 100 | Go 1.8 will be the last release to support Linux on ARMv5E and ARMv6 processors: |
| 101 | Go 1.9 will likely require the ARMv6K (as found in the Raspberry Pi 1) or later. |
| 102 | To identify whether a Linux system is ARMv6K or later, run |
| 103 | “<code>go</code> <code>tool</code> <code>dist</code> <code>-check-armv6k</code>” |
| 104 | (to facilitate testing, it is also possible to just copy the <code>dist</code> command to the |
| 105 | system without installing a full copy of Go 1.8) |
| 106 | and if the program terminates with output "ARMv6K supported." then the system |
| 107 | implements ARMv6K or later. |
| 108 | Go on non-Linux ARM systems already requires ARMv6K or later. |
| 109 | </p> |
| 110 | |
| 111 | |
| 112 | <h3 id="known_issues">Known Issues</h3> |
| 113 | |
| 114 | <p> |
| 115 | There are some instabilities on FreeBSD and NetBSD that are known but not understood. |
| 116 | These can lead to program crashes in rare cases. |
| 117 | See |
Russ Cox | ab4f479 | 2021-11-17 22:34:23 -0500 | [diff] [blame] | 118 | <a href="/issue/15658">issue 15658</a> and |
| 119 | <a href="/issue/16511">issue 16511</a>. |
Russ Cox | 04c64e9 | 2021-02-12 16:18:26 -0500 | [diff] [blame] | 120 | Any help in solving these issues would be appreciated. |
| 121 | </p> |
| 122 | |
| 123 | <h2 id="tools">Tools</h2> |
| 124 | |
| 125 | <h3 id="cmd_asm">Assembler</h3> |
| 126 | |
| 127 | <p> |
| 128 | For 64-bit x86 systems, the following instructions have been added: |
| 129 | <code>VBROADCASTSD</code>, |
| 130 | <code>BROADCASTSS</code>, |
| 131 | <code>MOVDDUP</code>, |
| 132 | <code>MOVSHDUP</code>, |
| 133 | <code>MOVSLDUP</code>, |
| 134 | <code>VMOVDDUP</code>, |
| 135 | <code>VMOVSHDUP</code>, and |
| 136 | <code>VMOVSLDUP</code>. |
| 137 | </p> |
| 138 | |
| 139 | <p> |
| 140 | For 64-bit PPC systems, the common vector scalar instructions have been |
| 141 | added: |
| 142 | <code>LXS</code>, |
| 143 | <code>LXSDX</code>, |
| 144 | <code>LXSI</code>, |
| 145 | <code>LXSIWAX</code>, |
| 146 | <code>LXSIWZX</code>, |
| 147 | <code>LXV</code>, |
| 148 | <code>LXVD2X</code>, |
| 149 | <code>LXVDSX</code>, |
| 150 | <code>LXVW4X</code>, |
| 151 | <code>MFVSR</code>, |
| 152 | <code>MFVSRD</code>, |
| 153 | <code>MFVSRWZ</code>, |
| 154 | <code>MTVSR</code>, |
| 155 | <code>MTVSRD</code>, |
| 156 | <code>MTVSRWA</code>, |
| 157 | <code>MTVSRWZ</code>, |
| 158 | <code>STXS</code>, |
| 159 | <code>STXSDX</code>, |
| 160 | <code>STXSI</code>, |
| 161 | <code>STXSIWX</code>, |
| 162 | <code>STXV</code>, |
| 163 | <code>STXVD2X</code>, |
| 164 | <code>STXVW4X</code>, |
| 165 | <code>XSCV</code>, |
| 166 | <code>XSCVDPSP</code>, |
| 167 | <code>XSCVDPSPN</code>, |
| 168 | <code>XSCVDPSXDS</code>, |
| 169 | <code>XSCVDPSXWS</code>, |
| 170 | <code>XSCVDPUXDS</code>, |
| 171 | <code>XSCVDPUXWS</code>, |
| 172 | <code>XSCVSPDP</code>, |
| 173 | <code>XSCVSPDPN</code>, |
| 174 | <code>XSCVSXDDP</code>, |
| 175 | <code>XSCVSXDSP</code>, |
| 176 | <code>XSCVUXDDP</code>, |
| 177 | <code>XSCVUXDSP</code>, |
| 178 | <code>XSCVX</code>, |
| 179 | <code>XSCVXP</code>, |
| 180 | <code>XVCV</code>, |
| 181 | <code>XVCVDPSP</code>, |
| 182 | <code>XVCVDPSXDS</code>, |
| 183 | <code>XVCVDPSXWS</code>, |
| 184 | <code>XVCVDPUXDS</code>, |
| 185 | <code>XVCVDPUXWS</code>, |
| 186 | <code>XVCVSPDP</code>, |
| 187 | <code>XVCVSPSXDS</code>, |
| 188 | <code>XVCVSPSXWS</code>, |
| 189 | <code>XVCVSPUXDS</code>, |
| 190 | <code>XVCVSPUXWS</code>, |
| 191 | <code>XVCVSXDDP</code>, |
| 192 | <code>XVCVSXDSP</code>, |
| 193 | <code>XVCVSXWDP</code>, |
| 194 | <code>XVCVSXWSP</code>, |
| 195 | <code>XVCVUXDDP</code>, |
| 196 | <code>XVCVUXDSP</code>, |
| 197 | <code>XVCVUXWDP</code>, |
| 198 | <code>XVCVUXWSP</code>, |
| 199 | <code>XVCVX</code>, |
| 200 | <code>XVCVXP</code>, |
| 201 | <code>XXLAND</code>, |
| 202 | <code>XXLANDC</code>, |
| 203 | <code>XXLANDQ</code>, |
| 204 | <code>XXLEQV</code>, |
| 205 | <code>XXLNAND</code>, |
| 206 | <code>XXLNOR</code>, |
| 207 | <code>XXLOR</code>, |
| 208 | <code>XXLORC</code>, |
| 209 | <code>XXLORQ</code>, |
| 210 | <code>XXLXOR</code>, |
| 211 | <code>XXMRG</code>, |
| 212 | <code>XXMRGHW</code>, |
| 213 | <code>XXMRGLW</code>, |
| 214 | <code>XXPERM</code>, |
| 215 | <code>XXPERMDI</code>, |
| 216 | <code>XXSEL</code>, |
| 217 | <code>XXSI</code>, |
| 218 | <code>XXSLDWI</code>, |
| 219 | <code>XXSPLT</code>, and |
| 220 | <code>XXSPLTW</code>. |
| 221 | </p> |
| 222 | |
| 223 | <h3 id="tool_yacc">Yacc</h3> |
| 224 | |
| 225 | <p> <!-- CL 27324, CL 27325 --> |
| 226 | The <code>yacc</code> tool (previously available by running |
| 227 | “<code>go</code> <code>tool</code> <code>yacc</code>”) has been removed. |
| 228 | As of Go 1.7 it was no longer used by the Go compiler. |
| 229 | It has moved to the “tools” repository and is now available at |
| 230 | <code><a href="https://godoc.org/golang.org/x/tools/cmd/goyacc">golang.org/x/tools/cmd/goyacc</a></code>. |
| 231 | </p> |
| 232 | |
| 233 | <h3 id="tool_fix">Fix</h3> |
| 234 | |
| 235 | <p> <!-- CL 28872 --> |
| 236 | The <code>fix</code> tool has a new “<code>context</code>” |
| 237 | fix to change imports from “<code>golang.org/x/net/context</code>” |
| 238 | to “<a href="/pkg/context/"><code>context</code></a>”. |
| 239 | </p> |
| 240 | |
| 241 | <h3 id="tool_pprof">Pprof</h3> |
| 242 | |
| 243 | <p> <!-- CL 33157 --> |
| 244 | The <code>pprof</code> tool can now profile TLS servers |
| 245 | and skip certificate validation by using the “<code>https+insecure</code>” |
| 246 | URL scheme. |
| 247 | </p> |
| 248 | |
| 249 | <p> <!-- CL 23781 --> |
| 250 | The callgrind output now has instruction-level granularity. |
| 251 | </p> |
| 252 | |
| 253 | <h3 id="tool_trace">Trace</h3> |
| 254 | |
| 255 | <p> <!-- CL 23324 --> |
| 256 | The <code>trace</code> tool has a new <code>-pprof</code> flag for |
| 257 | producing pprof-compatible blocking and latency profiles from an |
| 258 | execution trace. |
| 259 | </p> |
| 260 | |
| 261 | <p> <!-- CL 30017, CL 30702 --> |
| 262 | Garbage collection events are now shown more clearly in the |
| 263 | execution trace viewer. Garbage collection activity is shown on its |
| 264 | own row and GC helper goroutines are annotated with their roles. |
| 265 | </p> |
| 266 | |
| 267 | <h3 id="tool_vet">Vet</h3> |
| 268 | |
| 269 | <p>Vet is stricter in some ways and looser where it |
| 270 | previously caused false positives.</p> |
| 271 | |
| 272 | <p>Vet now checks for copying an array of locks, |
| 273 | duplicate JSON and XML struct field tags, |
| 274 | non-space-separated struct tags, |
| 275 | deferred calls to HTTP <code>Response.Body.Close</code> |
| 276 | before checking errors, and |
| 277 | indexed arguments in <code>Printf</code>. |
| 278 | It also improves existing checks.</p> |
| 279 | </p> |
| 280 | |
| 281 | <h3 id="compiler">Compiler Toolchain</h3> |
| 282 | |
| 283 | <p> |
| 284 | Go 1.7 introduced a new compiler back end for 64-bit x86 systems. |
| 285 | In Go 1.8, that back end has been developed further and is now used for |
| 286 | all architectures. |
| 287 | </p> |
| 288 | |
| 289 | <p> |
| 290 | The new back end, based on |
| 291 | <a href="https://en.wikipedia.org/wiki/Static_single_assignment_form">static single assignment form</a> (SSA), |
| 292 | generates more compact, more efficient code |
| 293 | and provides a better platform for optimizations |
| 294 | such as bounds check elimination. |
| 295 | The new back end reduces the CPU time required by |
Russ Cox | ab4f479 | 2021-11-17 22:34:23 -0500 | [diff] [blame] | 296 | <a href="/test/bench/go1/">our benchmark programs</a> by 20-30% |
Russ Cox | 04c64e9 | 2021-02-12 16:18:26 -0500 | [diff] [blame] | 297 | on 32-bit ARM systems. For 64-bit x86 systems, which already used the SSA back end in |
| 298 | Go 1.7, the gains are a more modest 0-10%. Other architectures will likely |
| 299 | see improvements closer to the 32-bit ARM numbers. |
| 300 | </p> |
| 301 | |
| 302 | <p> |
| 303 | The temporary <code>-ssa=0</code> compiler flag introduced in Go 1.7 |
| 304 | to disable the new back end has been removed in Go 1.8. |
| 305 | </p> |
| 306 | |
| 307 | <p> |
| 308 | In addition to enabling the new compiler back end for all systems, |
| 309 | Go 1.8 also introduces a new compiler front end. The new compiler |
| 310 | front end should not be noticeable to users but is the foundation for |
| 311 | future performance work. |
| 312 | </p> |
| 313 | |
| 314 | <p> |
| 315 | The compiler and linker have been optimized and run faster in this |
| 316 | release than in Go 1.7, although they are still slower than we would |
| 317 | like and will continue to be optimized in future releases. |
| 318 | Compared to the previous release, Go 1.8 is |
| 319 | <a href="https://dave.cheney.net/2016/11/19/go-1-8-toolchain-improvements">about 15% faster</a>. |
| 320 | </p> |
| 321 | |
| 322 | <h3 id="cmd_cgo">Cgo</h3> |
| 323 | |
| 324 | <p> <!-- CL 31141 --> |
| 325 | The Go tool now remembers the value of the <code>CGO_ENABLED</code> environment |
| 326 | variable set during <code>make.bash</code> and applies it to all future compilations |
Russ Cox | ab4f479 | 2021-11-17 22:34:23 -0500 | [diff] [blame] | 327 | by default to fix issue <a href="/issue/12808">#12808</a>. |
Russ Cox | 04c64e9 | 2021-02-12 16:18:26 -0500 | [diff] [blame] | 328 | When doing native compilation, it is rarely necessary to explicitly set |
| 329 | the <code>CGO_ENABLED</code> environment variable as <code>make.bash</code> |
| 330 | will detect the correct setting automatically. The main reason to explicitly |
| 331 | set the <code>CGO_ENABLED</code> environment variable is when your environment |
| 332 | supports cgo, but you explicitly do not want cgo support, in which case, set |
| 333 | <code>CGO_ENABLED=0</code> during <code>make.bash</code> or <code>all.bash</code>. |
| 334 | </p> |
| 335 | |
| 336 | <p> <!-- CL 29991 --> |
| 337 | The environment variable <code>PKG_CONFIG</code> may now be used to |
| 338 | set the program to run to handle <code>#cgo</code> <code>pkg-config</code> |
| 339 | directives. The default is <code>pkg-config</code>, the program |
| 340 | always used by earlier releases. This is intended to make it easier |
| 341 | to cross-compile |
| 342 | <a href="/cmd/cgo/">cgo</a> code. |
| 343 | </p> |
| 344 | |
| 345 | <p> <!-- CL 32354 --> |
| 346 | The <a href="/cmd/cgo/">cgo</a> tool now supports a <code>-srcdir</code> |
| 347 | option, which is used by the <a href="/cmd/go/">go</a> command. |
| 348 | </p> |
| 349 | |
| 350 | <p> <!-- CL 31768, 31811 --> |
| 351 | If <a href="/cmd/cgo/">cgo</a> code calls <code>C.malloc</code>, and |
| 352 | <code>malloc</code> returns <code>NULL</code>, the program will now |
| 353 | crash with an out of memory error. |
| 354 | <code>C.malloc</code> will never return <code>nil</code>. |
| 355 | Unlike most C functions, <code>C.malloc</code> may not be used in a |
| 356 | two-result form returning an errno value. |
| 357 | </p> |
| 358 | |
| 359 | <p> <!-- CL 33237 --> |
| 360 | If <a href="/cmd/cgo/">cgo</a> is used to call a C function passing a |
| 361 | pointer to a C union, and if the C union can contain any pointer |
| 362 | values, and if <a href="/cmd/cgo/#hdr-Passing_pointers">cgo pointer |
| 363 | checking</a> is enabled (as it is by default), the union value is now |
| 364 | checked for Go pointers. |
| 365 | </p> |
| 366 | |
| 367 | <h3 id="gccgo">Gccgo</h3> |
| 368 | |
| 369 | <p> |
| 370 | Due to the alignment of Go's semiannual release schedule with GCC's |
| 371 | annual release schedule, |
| 372 | GCC release 6 contains the Go 1.6.1 version of gccgo. |
| 373 | We expect that the next release, GCC 7, will contain the Go 1.8 |
| 374 | version of gccgo. |
| 375 | </p> |
| 376 | |
| 377 | <h3 id="gopath">Default GOPATH</h3> |
| 378 | |
| 379 | <p> |
| 380 | The |
| 381 | <a href="/cmd/go/#hdr-GOPATH_environment_variable"><code>GOPATH</code> |
| 382 | environment variable</a> now has a default value if it |
| 383 | is unset. It defaults to |
| 384 | <code>$HOME/go</code> on Unix and |
| 385 | <code>%USERPROFILE%/go</code> on Windows. |
| 386 | </p> |
| 387 | |
| 388 | <h3 id="go_get">Go get</h3> |
| 389 | |
| 390 | <p> <!-- CL 34818 --> |
| 391 | The “<code>go</code> <code>get</code>” command now always respects |
| 392 | HTTP proxy environment variables, regardless of whether |
| 393 | the <code style='white-space:nowrap'>-insecure</code> flag is used. In previous releases, the |
| 394 | <code style='white-space:nowrap'>-insecure</code> flag had the side effect of not using proxies. |
| 395 | </p> |
| 396 | |
| 397 | <h3 id="go_bug">Go bug</h3> |
| 398 | |
| 399 | <p> |
| 400 | The new |
| 401 | “<a href="/cmd/go/#hdr-Print_information_for_bug_reports"><code>go</code> <code>bug</code></a>” |
| 402 | command starts a bug report on GitHub, prefilled |
| 403 | with information about the current system. |
| 404 | </p> |
| 405 | |
| 406 | <h3 id="cmd_doc">Go doc</h3> |
| 407 | |
| 408 | <p> <!-- CL 25419 --> |
| 409 | The |
| 410 | “<a href="/cmd/go/#hdr-Show_documentation_for_package_or_symbol"><code>go</code> <code>doc</code></a>” |
| 411 | command now groups constants and variables with their type, |
| 412 | following the behavior of |
| 413 | <a href="/cmd/godoc/"><code>godoc</code></a>. |
| 414 | </p> |
| 415 | |
| 416 | <p> <!-- CL 25420 --> |
| 417 | In order to improve the readability of <code>doc</code>'s |
| 418 | output, each summary of the first-level items is guaranteed to |
| 419 | occupy a single line. |
| 420 | </p> |
| 421 | |
| 422 | <p> <!-- CL 31852 --> |
| 423 | Documentation for a specific method in an interface definition can |
| 424 | now be requested, as in |
| 425 | “<code>go</code> <code>doc</code> <code>net.Conn.SetDeadline</code>”. |
| 426 | </p> |
| 427 | |
| 428 | <h3 id="plugin">Plugins</h3> |
| 429 | |
| 430 | <p> |
| 431 | Go now provides early support for plugins with a “<code>plugin</code>” |
| 432 | build mode for generating plugins written in Go, and a |
| 433 | new <a href="/pkg/plugin/"><code>plugin</code></a> package for |
| 434 | loading such plugins at run time. Plugin support is currently only |
| 435 | available on Linux. Please report any issues. |
| 436 | </p> |
| 437 | |
| 438 | <h2 id="runtime">Runtime</h2> |
| 439 | |
| 440 | <h3 id="liveness">Argument Liveness</h3> |
| 441 | |
| 442 | <p> |
| 443 | <!-- Issue 15843 --> The garbage collector no longer considers |
| 444 | arguments live throughout the entirety of a function. For more |
| 445 | information, and for how to force a variable to remain live, see |
| 446 | the <a href="/pkg/runtime/#KeepAlive"><code>runtime.KeepAlive</code></a> |
| 447 | function added in Go 1.7. |
| 448 | </p> |
| 449 | |
| 450 | <p> |
| 451 | <i>Updating:</i> |
| 452 | Code that sets a finalizer on an allocated object may need to add |
| 453 | calls to <code>runtime.KeepAlive</code> in functions or methods |
| 454 | using that object. |
| 455 | Read the |
| 456 | <a href="/pkg/runtime/#KeepAlive"><code>KeepAlive</code> |
| 457 | documentation</a> and its example for more details. |
| 458 | </p> |
| 459 | |
| 460 | <h3 id="mapiter">Concurrent Map Misuse</h3> |
| 461 | |
| 462 | <p> |
| 463 | In Go 1.6, the runtime |
| 464 | <a href="/doc/go1.6#runtime">added lightweight, |
| 465 | best-effort detection of concurrent misuse of maps</a>. This release |
| 466 | improves that detector with support for detecting programs that |
| 467 | concurrently write to and iterate over a map. |
| 468 | </p> |
| 469 | <p> |
| 470 | As always, if one goroutine is writing to a map, no other goroutine should be |
| 471 | reading (which includes iterating) or writing the map concurrently. |
| 472 | If the runtime detects this condition, it prints a diagnosis and crashes the program. |
| 473 | The best way to find out more about the problem is to run the program |
| 474 | under the |
| 475 | <a href="https://blog.golang.org/race-detector">race detector</a>, |
| 476 | which will more reliably identify the race |
| 477 | and give more detail. |
| 478 | </p> |
| 479 | |
| 480 | <h3 id="memstats">MemStats Documentation</h3> |
| 481 | |
| 482 | <p> <!-- CL 28972 --> |
| 483 | The <a href="/pkg/runtime/#MemStats"><code>runtime.MemStats</code></a> |
| 484 | type has been more thoroughly documented. |
| 485 | </p> |
| 486 | |
| 487 | <h2 id="performance">Performance</h2> |
| 488 | |
| 489 | <p> |
| 490 | As always, the changes are so general and varied that precise statements |
| 491 | about performance are difficult to make. |
| 492 | Most programs should run a bit faster, |
| 493 | due to speedups in the garbage collector and |
| 494 | optimizations in the standard library. |
| 495 | </p> |
| 496 | |
| 497 | <p> |
| 498 | There have been optimizations to implementations in the |
| 499 | <a href="/pkg/bytes/"><code>bytes</code></a>, |
| 500 | <a href="/pkg/crypto/aes/"><code>crypto/aes</code></a>, |
| 501 | <a href="/pkg/crypto/cipher/"><code>crypto/cipher</code></a>, |
| 502 | <a href="/pkg/crypto/elliptic/"><code>crypto/elliptic</code></a>, |
| 503 | <a href="/pkg/crypto/sha256/"><code>crypto/sha256</code></a>, |
| 504 | <a href="/pkg/crypto/sha512/"><code>crypto/sha512</code></a>, |
| 505 | <a href="/pkg/encoding/asn1/"><code>encoding/asn1</code></a>, |
| 506 | <a href="/pkg/encoding/csv/"><code>encoding/csv</code></a>, |
| 507 | <a href="/pkg/encoding/hex/"><code>encoding/hex</code></a>, |
| 508 | <a href="/pkg/encoding/json/"><code>encoding/json</code></a>, |
| 509 | <a href="/pkg/hash/crc32/"><code>hash/crc32</code></a>, |
| 510 | <a href="/pkg/image/color/"><code>image/color</code></a>, |
| 511 | <a href="/pkg/image/draw/"><code>image/draw</code></a>, |
| 512 | <a href="/pkg/math/"><code>math</code></a>, |
| 513 | <a href="/pkg/math/big/"><code>math/big</code></a>, |
| 514 | <a href="/pkg/reflect/"><code>reflect</code></a>, |
| 515 | <a href="/pkg/regexp/"><code>regexp</code></a>, |
| 516 | <a href="/pkg/runtime/"><code>runtime</code></a>, |
| 517 | <a href="/pkg/strconv/"><code>strconv</code></a>, |
| 518 | <a href="/pkg/strings/"><code>strings</code></a>, |
| 519 | <a href="/pkg/syscall/"><code>syscall</code></a>, |
| 520 | <a href="/pkg/text/template/"><code>text/template</code></a>, and |
| 521 | <a href="/pkg/unicode/utf8/"><code>unicode/utf8</code></a> |
| 522 | packages. |
| 523 | </p> |
| 524 | |
| 525 | <h3 id="gc">Garbage Collector</h3> |
| 526 | |
| 527 | <p> |
| 528 | Garbage collection pauses should be significantly shorter than they |
| 529 | were in Go 1.7, usually under 100 microseconds and often as low as |
| 530 | 10 microseconds. |
| 531 | See the |
| 532 | <a href="https://github.com/golang/proposal/blob/master/design/17503-eliminate-rescan.md" |
| 533 | >document on eliminating stop-the-world stack re-scanning</a> |
| 534 | for details. More work remains for Go 1.9. |
| 535 | </p> |
| 536 | |
| 537 | <h3 id="defer">Defer</h3> |
| 538 | |
| 539 | <!-- CL 29656, CL 29656 --> |
| 540 | <p> |
| 541 | The overhead of <a href="/ref/spec/#Defer_statements">deferred |
| 542 | function calls</a> has been reduced by about half. |
| 543 | </p> |
| 544 | |
| 545 | <h3 id="cgoperf">Cgo</h3> |
| 546 | |
| 547 | <p>The overhead of calls from Go into C has been reduced by about half.</p> |
| 548 | |
| 549 | <h2 id="library">Standard library</h2> |
| 550 | |
| 551 | <h3 id="examples">Examples</h3> |
| 552 | |
| 553 | <p> |
| 554 | Examples have been added to the documentation across many packages. |
| 555 | </p> |
| 556 | |
| 557 | <h3 id="sort_slice">Sort</h3> |
| 558 | |
| 559 | <p> |
| 560 | The <a href="/pkg/sort/">sort</a> package |
| 561 | now includes a convenience function |
| 562 | <a href="/pkg/sort/#Slice"><code>Slice</code></a> to sort a |
| 563 | slice given a <em>less</em> function. |
| 564 | |
| 565 | In many cases this means that writing a new sorter type is not |
| 566 | necessary. |
| 567 | </p> |
| 568 | |
| 569 | <p> |
| 570 | Also new are |
| 571 | <a href="/pkg/sort/#SliceStable"><code>SliceStable</code></a> and |
| 572 | <a href="/pkg/sort/#SliceIsSorted"><code>SliceIsSorted</code></a>. |
| 573 | </p> |
| 574 | |
| 575 | <h3 id="h2push">HTTP/2 Push</h3> |
| 576 | |
| 577 | <p> |
| 578 | The <a href="/pkg/net/http/">net/http</a> package now includes a |
| 579 | mechanism to |
| 580 | send HTTP/2 server pushes from a |
| 581 | <a href="/pkg/net/http/#Handler"><code>Handler</code></a>. |
| 582 | Similar to the existing <code>Flusher</code> and <code>Hijacker</code> |
| 583 | interfaces, an HTTP/2 |
| 584 | <a href="/pkg/net/http/#ResponseWriter"><code>ResponseWriter</code></a> |
| 585 | now implements the new |
| 586 | <a href="/pkg/net/http/#Pusher"><code>Pusher</code></a> interface. |
| 587 | </p> |
| 588 | |
| 589 | <h3 id="http_shutdown">HTTP Server Graceful Shutdown</h3> |
| 590 | |
| 591 | <p> <!-- CL 32329 --> |
| 592 | The HTTP Server now has support for graceful shutdown using the new |
| 593 | <a href="/pkg/net/http/#Server.Shutdown"><code>Server.Shutdown</code></a> |
| 594 | method and abrupt shutdown using the new |
| 595 | <a href="/pkg/net/http/#Server.Close"><code>Server.Close</code></a> |
| 596 | method. |
| 597 | </p> |
| 598 | |
| 599 | <h3 id="more_context">More Context Support</h3> |
| 600 | |
| 601 | <p> |
| 602 | Continuing <a href="/doc/go1.7#context">Go 1.7's adoption</a> |
| 603 | of <a href="/pkg/context/#Context"><code>context.Context</code></a> |
| 604 | into the standard library, Go 1.8 adds more context support |
| 605 | to existing packages: |
| 606 | </p> |
| 607 | |
| 608 | <ul> |
| 609 | <li>The new <a href="/pkg/net/http/#Server.Shutdown"><code>Server.Shutdown</code></a> |
| 610 | takes a context argument.</li> |
| 611 | <li>There have been <a href="#database_sql">significant additions</a> to the |
| 612 | <a href="/pkg/database/sql/">database/sql</a> package with context support.</li> |
| 613 | <li>All nine of the new <code>Lookup</code> methods on the new |
| 614 | <a href="/pkg/net/#Resolver"><code>net.Resolver</code></a> now |
| 615 | take a context.</li> |
| 616 | </ul> |
| 617 | |
| 618 | <h3 id="mutex_prof">Mutex Contention Profiling</h3> |
| 619 | |
| 620 | <p> |
| 621 | The runtime and tools now support profiling contended mutexes. |
| 622 | </p> |
| 623 | |
| 624 | <p> |
| 625 | Most users will want to use the new <code>-mutexprofile</code> |
| 626 | flag with “<a href="/cmd/go/#hdr-Description_of_testing_flags"><code>go</code> <code>test</code></a>”, |
| 627 | and then use <a href="/cmd/pprof/">pprof</a> on the resultant file. |
| 628 | </p> |
| 629 | |
| 630 | <p> |
| 631 | Lower-level support is also available via the new |
| 632 | <a href="/pkg/runtime/#MutexProfile"><code>MutexProfile</code></a> |
| 633 | and |
| 634 | <a href="/pkg/runtime/#SetMutexProfileFraction"><code>SetMutexProfileFraction</code></a>. |
| 635 | </p> |
| 636 | |
| 637 | <p> |
| 638 | A known limitation for Go 1.8 is that the profile only reports contention for |
| 639 | <a href="/pkg/sync/#Mutex"><code>sync.Mutex</code></a>, |
Russ Cox | da157ef | 2021-02-25 06:19:38 -0500 | [diff] [blame] | 640 | not |
Russ Cox | 04c64e9 | 2021-02-12 16:18:26 -0500 | [diff] [blame] | 641 | <a href="/pkg/sync/#RWMutex"><code>sync.RWMutex</code></a>. |
| 642 | </p> |
| 643 | |
| 644 | <h3 id="minor_library_changes">Minor changes to the library</h3> |
| 645 | |
| 646 | <p> |
| 647 | As always, there are various minor changes and updates to the library, |
| 648 | made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a> |
| 649 | in mind. The following sections list the user visible changes and additions. |
| 650 | Optimizations and minor bug fixes are not listed. |
| 651 | </p> |
| 652 | |
| 653 | <dl id="archive_tar"><dt><a href="/pkg/archive/tar/">archive/tar</a></dt> |
| 654 | <dd> |
| 655 | |
| 656 | <p> <!-- CL 28471, CL 31440, CL 31441, CL 31444, CL 28418, CL 31439 --> |
| 657 | The tar implementation corrects many bugs in corner cases of the file format. |
| 658 | The <a href="/pkg/archive/tar/#Reader"><code>Reader</code></a> |
| 659 | is now able to process tar files in the PAX format with entries larger than 8GB. |
| 660 | The <a href="/pkg/archive/tar/#Writer"><code>Writer</code></a> |
| 661 | no longer produces invalid tar files in some situations involving long pathnames. |
| 662 | </p> |
| 663 | |
| 664 | </dd> |
| 665 | </dl> |
| 666 | |
| 667 | <dl id="compress_flate"><dt><a href="/pkg/compress/flate/">compress/flate</a></dt> |
| 668 | <dd> |
| 669 | |
| 670 | <p> <!-- CL 31640, CL 31174, CL 32149 --> |
| 671 | There have been some minor fixes to the encoder to improve the |
| 672 | compression ratio in certain situations. As a result, the exact |
| 673 | encoded output of <code>DEFLATE</code> may be different from Go 1.7. Since |
| 674 | <code>DEFLATE</code> is the underlying compression of gzip, png, zlib, and zip, |
| 675 | those formats may have changed outputs. |
| 676 | </p> |
| 677 | |
| 678 | <p> <!-- CL 31174 --> |
| 679 | The encoder, when operating in |
| 680 | <a href="/pkg/compress/flate/#NoCompression"><code>NoCompression</code></a> |
| 681 | mode, now produces a consistent output that is not dependent on |
| 682 | the size of the slices passed to the |
| 683 | <a href="/pkg/compress/flate/#Writer.Write"><code>Write</code></a> |
| 684 | method. |
| 685 | </p> |
| 686 | |
| 687 | <p> <!-- CL 28216 --> |
| 688 | The decoder, upon encountering an error, now returns any |
| 689 | buffered data it had uncompressed along with the error. |
| 690 | </p> |
| 691 | |
| 692 | </dd> |
| 693 | </dl> |
| 694 | |
| 695 | |
| 696 | <dl id="compress_gzip"><dt><a href="/pkg/compress/gzip/">compress/gzip</a></dt> |
| 697 | <dd> |
| 698 | |
| 699 | <p> |
| 700 | The <a href="/pkg/compress/gzip/#Writer"><code>Writer</code></a> |
| 701 | now encodes a zero <code>MTIME</code> field when |
| 702 | the <a href="/pkg/compress/gzip/#Header"><code>Header.ModTime</code></a> |
| 703 | field is the zero value. |
| 704 | |
| 705 | In previous releases of Go, the <code>Writer</code> would encode |
| 706 | a nonsensical value. |
| 707 | |
| 708 | Similarly, |
| 709 | the <a href="/pkg/compress/gzip/#Reader"><code>Reader</code></a> |
| 710 | now reports a zero encoded <code>MTIME</code> field as a zero |
| 711 | <code>Header.ModTime</code>. |
| 712 | </p> |
| 713 | |
| 714 | </dd> |
| 715 | </dl> |
| 716 | |
| 717 | <dl id="context"><dt><a href="/pkg/context/">context</a></dt> |
| 718 | <dd> |
| 719 | <p> <!-- CL 30370 --> |
| 720 | The <a href="/pkg/context#DeadlineExceeded"><code>DeadlineExceeded</code></a> |
| 721 | error now implements |
| 722 | <a href="/pkg/net/#Error"><code>net.Error</code></a> |
| 723 | and reports true for both the <code>Timeout</code> and |
| 724 | <code>Temporary</code> methods. |
| 725 | </p> |
| 726 | </dd> |
| 727 | </dl> |
| 728 | |
| 729 | <dl id="crypto_tls"><dt><a href="/pkg/crypto/tls/">crypto/tls</a></dt> |
| 730 | <dd> |
| 731 | <p> <!-- CL 25159, CL 31318 --> |
| 732 | The new method |
| 733 | <a href="/pkg/crypto/tls/#Conn.CloseWrite"><code>Conn.CloseWrite</code></a> |
| 734 | allows TLS connections to be half closed. |
| 735 | </p> |
| 736 | |
| 737 | <p> <!-- CL 28075 --> |
| 738 | The new method |
| 739 | <a href="/pkg/crypto/tls/#Config.Clone"><code>Config.Clone</code></a> |
| 740 | clones a TLS configuration. |
| 741 | </p> |
| 742 | |
| 743 | <p> |
| 744 | <!-- CL 30790 --> |
| 745 | The new <a href="/pkg/crypto/tls/#Config.GetConfigForClient"><code>Config.GetConfigForClient</code></a> |
| 746 | callback allows selecting a configuration for a client dynamically, based |
| 747 | on the client's |
| 748 | <a href="/pkg/crypto/tls/#ClientHelloInfo"><code>ClientHelloInfo</code></a>. |
| 749 | |
| 750 | <!-- CL 31391, CL 32119 --> |
| 751 | The <a href="/pkg/crypto/tls/#ClientHelloInfo"><code>ClientHelloInfo</code></a> |
| 752 | struct now has new |
| 753 | fields <code>Conn</code>, <code>SignatureSchemes</code> (using |
| 754 | the new |
| 755 | type <a href="/kg/crypto/tls/#SignatureScheme"><code>SignatureScheme</code></a>), |
| 756 | <code>SupportedProtos</code>, and <code>SupportedVersions</code>. |
| 757 | </p> |
| 758 | |
| 759 | <p> <!-- CL 32115 --> |
| 760 | The new <a href="/pkg/crypto/tls/#Config.GetClientCertificate"><code>Config.GetClientCertificate</code></a> |
| 761 | callback allows selecting a client certificate based on the server's |
| 762 | TLS <code>CertificateRequest</code> message, represented by the new |
| 763 | <a href="/pkg/crypto/tls/#CertificateRequestInfo"><code>CertificateRequestInfo</code></a>. |
| 764 | </p> |
| 765 | |
| 766 | <p> <!-- CL 27434 --> |
| 767 | The new |
| 768 | <a href="/pkg/crypto/tls/#Config.KeyLogWriter"><code>Config.KeyLogWriter</code></a> |
| 769 | allows debugging TLS connections |
| 770 | in <a href="https://www.wireshark.org/">WireShark</a> and |
| 771 | similar tools. |
| 772 | </p> |
| 773 | |
| 774 | <p> <!-- CL 32115 --> |
| 775 | The new |
| 776 | <a href="/pkg/crypto/tls/#Config.VerifyPeerCertificate"><code>Config.VerifyPeerCertificate</code></a> |
| 777 | callback allows additional validation of a peer's presented certificate. |
| 778 | </p> |
| 779 | |
| 780 | <p> <!-- CL 18130 --> |
| 781 | The <code>crypto/tls</code> package now implements basic |
| 782 | countermeasures against CBC padding oracles. There should be |
| 783 | no explicit secret-dependent timings, but it does not attempt to |
| 784 | normalize memory accesses to prevent cache timing leaks. |
| 785 | </p> |
| 786 | |
| 787 | <p> |
| 788 | The <code>crypto/tls</code> package now supports |
| 789 | X25519 and <!-- CL 30824, CL 30825 --> |
| 790 | ChaCha20-Poly1305. <!-- CL 30957, CL 30958 --> |
| 791 | ChaCha20-Poly1305 is now prioritized unless <!-- CL 32871 --> |
| 792 | hardware support for AES-GCM is present. |
| 793 | </p> |
| 794 | |
| 795 | <p> <!-- CL 27315, CL 35290 --> |
| 796 | AES-128-CBC cipher suites with SHA-256 are also |
| 797 | now supported, but disabled by default. |
| 798 | </p> |
| 799 | |
| 800 | </dd> |
| 801 | </dl> |
| 802 | |
| 803 | <dl id="crypto_x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt> |
| 804 | <dd> |
| 805 | <p> <!-- CL 24743 --> |
| 806 | PSS signatures are now supported. |
| 807 | </p> |
| 808 | |
| 809 | <p> <!-- CL 32644 --> |
| 810 | <a href="/pkg/crypto/x509/#UnknownAuthorityError"><code>UnknownAuthorityError</code></a> |
| 811 | now has a <code>Cert</code> field, reporting the untrusted |
| 812 | certificate. |
| 813 | </p> |
| 814 | |
| 815 | <p> |
| 816 | Certificate validation is more permissive in a few cases and |
| 817 | stricter in a few other cases. |
| 818 | <!-- |
| 819 | crypto/x509: allow a leaf certificate to be specified directly as root (CL 27393) |
| 820 | crypto/x509: check that the issuer name matches the issuer's subject name (CL 23571) |
| 821 | crypto/x509: don't accept a root that already appears in a chain. (CL 32121) |
| 822 | crypto/x509: fix name constraints handling (CL 30155) |
| 823 | crypto/x509: parse all names in an RDN (CL 30810) |
| 824 | crypto/x509: recognise ISO OID for RSA+SHA1 (CL 27394) |
| 825 | crypto/x509: require a NULL parameters for RSA public keys (CL 16166, CL 27312) |
| 826 | crypto/x509: return error for missing SerialNumber (CL 27238) |
| 827 | --> |
| 828 | </p> |
| 829 | |
| 830 | <p><!-- CL 30375 --> |
| 831 | Root certificates will now also be looked for |
| 832 | at <code>/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem</code> |
| 833 | on Linux, to support RHEL and CentOS. |
| 834 | </p> |
| 835 | |
| 836 | </dd> |
| 837 | </dl> |
| 838 | |
| 839 | <dl id="database_sql"><dt><a href="/pkg/database/sql/">database/sql</a></dt> |
| 840 | <dd> |
| 841 | <p> |
| 842 | The package now supports <code>context.Context</code>. There are new methods |
| 843 | ending in <code>Context</code> such as |
| 844 | <a href="/pkg/database/sql/#DB.QueryContext"><code>DB.QueryContext</code></a> and |
| 845 | <a href="/pkg/database/sql/#DB.PrepareContext"><code>DB.PrepareContext</code></a> |
| 846 | that take context arguments. Using the new <code>Context</code> methods ensures that |
| 847 | connections are closed and returned to the connection pool when the |
| 848 | request is done; enables canceling in-progress queries |
| 849 | should the driver support that; and allows the database |
| 850 | pool to cancel waiting for the next available connection. |
| 851 | </p> |
| 852 | <p> |
| 853 | The <a href="/pkg/database/sql#IsolationLevel"><code>IsolationLevel</code></a> |
| 854 | can now be set when starting a transaction by setting the isolation level |
| 855 | on <a href="/pkg/database/sql#TxOptions.Isolation"><code>TxOptions.Isolation</code></a> and passing |
| 856 | it to <a href="/pkg/database/sql#DB.BeginTx"><code>DB.BeginTx</code></a>. |
| 857 | An error will be returned if an isolation level is selected that the driver |
| 858 | does not support. A read-only attribute may also be set on the transaction |
| 859 | by setting <a href="/pkg/database/sql/#TxOptions.ReadOnly"><code>TxOptions.ReadOnly</code></a> |
| 860 | to true. |
| 861 | </p> |
| 862 | <p> |
| 863 | Queries now expose the SQL column type information for drivers that support it. |
| 864 | Rows can return <a href="/pkg/database/sql#Rows.ColumnTypes"><code>ColumnTypes</code></a> |
| 865 | which can include SQL type information, column type lengths, and the Go type. |
| 866 | </p> |
| 867 | <p> |
| 868 | A <a href="/pkg/database/sql/#Rows"><code>Rows</code></a> |
| 869 | can now represent multiple result sets. After |
| 870 | <a href="/pkg/database/sql/#Rows.Next"><code>Rows.Next</code></a> returns false, |
| 871 | <a href="/pkg/database/sql/#Rows.NextResultSet"><code>Rows.NextResultSet</code></a> |
| 872 | may be called to advance to the next result set. The existing <code>Rows</code> |
| 873 | should continue to be used after it advances to the next result set. |
| 874 | </p> |
| 875 | <p> |
| 876 | <a href="/pkg/database/sql/#NamedArg"><code>NamedArg</code></a> may be used |
| 877 | as query arguments. The new function <a href="/pkg/database/sql/#Named"><code>Named</code></a> |
| 878 | helps create a <a href="/pkg/database/sql/#NamedArg"><code>NamedArg</code></a> |
| 879 | more succinctly. |
| 880 | <p> |
| 881 | If a driver supports the new |
| 882 | <a href="/pkg/database/sql/driver/#Pinger"><code>Pinger</code></a> |
| 883 | interface, the |
| 884 | <a href="/pkg/database/sql/#DB.Ping"><code>DB.Ping</code></a> |
| 885 | and |
| 886 | <a href="/pkg/database/sql/#DB.PingContext"><code>DB.PingContext</code></a> |
| 887 | methods will use that interface to check whether a |
| 888 | database connection is still valid. |
| 889 | </p> |
| 890 | <p> |
| 891 | The new <code>Context</code> query methods work for all drivers, but |
Russ Cox | c471313 | 2021-12-06 12:32:45 -0500 | [diff] [blame] | 892 | <code>Context</code> cancellation is not responsive unless the driver has been |
Russ Cox | 04c64e9 | 2021-02-12 16:18:26 -0500 | [diff] [blame] | 893 | updated to use them. The other features require driver support in |
| 894 | <a href="/pkg/database/sql/driver"><code>database/sql/driver</code></a>. |
| 895 | Driver authors should review the new interfaces. Users of existing |
| 896 | driver should review the driver documentation to see what |
| 897 | it supports and any system specific documentation on each feature. |
| 898 | </p> |
| 899 | </dd> |
| 900 | </dl> |
| 901 | |
| 902 | <dl id="debug_pe"><dt><a href="/pkg/debug/pe/">debug/pe</a></dt> |
| 903 | <dd> |
| 904 | <p> <!-- CL 22720, CL 27212, CL 22181, CL 22332, CL 22336, Issue 15345 --> |
| 905 | The package has been extended and is now used by |
| 906 | <a href="/cmd/link/">the Go linker</a> to read <code>gcc</code>-generated object files. |
| 907 | The new |
| 908 | <a href="/pkg/debug/pe/#File.StringTable"><code>File.StringTable</code></a> |
| 909 | and |
| 910 | <a href="/pkg/debug/pe/#Section.Relocs"><code>Section.Relocs</code></a> |
| 911 | fields provide access to the COFF string table and COFF relocations. |
| 912 | The new |
| 913 | <a href="/pkg/debug/pe/#File.COFFSymbols"><code>File.COFFSymbols</code></a> |
| 914 | allows low-level access to the COFF symbol table. |
| 915 | </p> |
| 916 | </dd> |
| 917 | </dl> |
| 918 | |
| 919 | <dl id="encoding_base64"><dt><a href="/pkg/encoding/base64/">encoding/base64</a></dt> |
| 920 | <dd> |
| 921 | <p> <!-- CL 24964 --> |
| 922 | The new |
| 923 | <a href="/pkg/encoding/base64/#Encoding.Strict"><code>Encoding.Strict</code></a> |
| 924 | method returns an <code>Encoding</code> that causes the decoder |
| 925 | to return an error when the trailing padding bits are not zero. |
| 926 | </p> |
| 927 | </dd> |
| 928 | </dl> |
| 929 | |
| 930 | <dl id="encoding_binary"><dt><a href="/pkg/encoding/binary/">encoding/binary</a></dt> |
| 931 | <dd> |
| 932 | <p> <!-- CL 28514 --> |
| 933 | <a href="/pkg/encoding/binary/#Read"><code>Read</code></a> |
| 934 | and |
| 935 | <a href="/pkg/encoding/binary/#Write"><code>Write</code></a> |
| 936 | now support booleans. |
| 937 | </p> |
| 938 | </dd> |
| 939 | </dl> |
| 940 | |
| 941 | <dl id="encoding_json"><dt><a href="/pkg/encoding/json/">encoding/json</a></dt> |
| 942 | <dd> |
| 943 | |
| 944 | <p> <!-- CL 18692 --> |
| 945 | <a href="/pkg/encoding/json/#UnmarshalTypeError"><code>UnmarshalTypeError</code></a> |
| 946 | now includes the struct and field name. |
| 947 | </p> |
| 948 | |
| 949 | <p> <!-- CL 31932 --> |
| 950 | A nil <a href="/pkg/encoding/json/#Marshaler"><code>Marshaler</code></a> |
| 951 | now marshals as a JSON <code>null</code> value. |
| 952 | </p> |
| 953 | |
| 954 | <p> <!-- CL 21811 --> |
| 955 | A <a href="/pkg/encoding/json/#RawMessage"><code>RawMessage</code></a> value now |
| 956 | marshals the same as its pointer type. |
| 957 | </p> |
| 958 | |
| 959 | <p> <!-- CL 30371 --> |
| 960 | <a href="/pkg/encoding/json/#Marshal"><code>Marshal</code></a> |
| 961 | encodes floating-point numbers using the same format as in ES6, |
| 962 | preferring decimal (not exponential) notation for a wider range of values. |
| 963 | In particular, all floating-point integers up to 2<sup>64</sup> format the |
| 964 | same as the equivalent <code>int64</code> representation. |
| 965 | </p> |
| 966 | |
| 967 | <p> <!-- CL 30944 --> |
| 968 | In previous versions of Go, unmarshaling a JSON <code>null</code> into an |
| 969 | <a href="/pkg/encoding/json/#Unmarshaler"><code>Unmarshaler</code></a> |
| 970 | was considered a no-op; now the <code>Unmarshaler</code>'s |
| 971 | <code>UnmarshalJSON</code> method is called with the JSON literal |
| 972 | <code>null</code> and can define the semantics of that case. |
| 973 | </p> |
| 974 | |
| 975 | </dd> |
| 976 | </dl> |
| 977 | |
| 978 | <dl id="encoding_pem"><dt><a href="/pkg/encoding/pem/">encoding/pem</a></dt> |
| 979 | <dd> |
| 980 | <p> <!-- CL 27391 --> |
| 981 | <a href="/pkg/encoding/pem/#Decode"><code>Decode</code></a> |
| 982 | is now strict about the format of the ending line. |
| 983 | </p> |
| 984 | </dd> |
| 985 | </dl> |
| 986 | |
| 987 | <dl id="encoding_xml"><dt><a href="/pkg/encoding/xml/">encoding/xml</a></dt> |
| 988 | <dd> |
| 989 | <p> <!-- CL 30946 --> |
| 990 | <a href="/pkg/encoding/xml/#Unmarshal"><code>Unmarshal</code></a> |
| 991 | now has wildcard support for collecting all attributes using |
| 992 | the new <code>",any,attr"</code> struct tag. |
| 993 | </p> |
| 994 | </dd> |
| 995 | </dl> |
| 996 | |
| 997 | <dl id="expvar"><dt><a href="/pkg/expvar/">expvar</a></dt> |
| 998 | <dd> |
| 999 | <p> <!-- CL 30917 --> |
| 1000 | The new methods |
| 1001 | <a href="/pkg/expvar/#Int.Value"><code>Int.Value</code></a>, |
| 1002 | <a href="/pkg/expvar/#String.Value"><code>String.Value</code></a>, |
| 1003 | <a href="/pkg/expvar/#Float.Value"><code>Float.Value</code></a>, and |
| 1004 | <a href="/pkg/expvar/#Func.Value"><code>Func.Value</code></a> |
| 1005 | report the current value of an exported variable. |
| 1006 | </p> |
| 1007 | |
| 1008 | <p> <!-- CL 24722 --> |
| 1009 | The new |
| 1010 | function <a href="/pkg/expvar/#Handler"><code>Handler</code></a> |
| 1011 | returns the package's HTTP handler, to enable installing it in |
| 1012 | non-standard locations. |
| 1013 | </p> |
| 1014 | </dd> |
| 1015 | </dl> |
| 1016 | |
| 1017 | <dl id="fmt"><dt><a href="/pkg/fmt/">fmt</a></dt> |
| 1018 | <dd> |
| 1019 | <p><!-- CL 30611 --> |
| 1020 | <a href="/pkg/fmt/#Scanf"><code>Scanf</code></a>, |
| 1021 | <a href="/pkg/fmt/#Fscanf"><code>Fscanf</code></a>, and |
| 1022 | <a href="/pkg/fmt/#Sscanf"><code>Sscanf</code></a> now |
| 1023 | handle spaces differently and more consistently than |
| 1024 | previous releases. See the |
| 1025 | <a href="/pkg/fmt/#hdr-Scanning">scanning documentation</a> |
| 1026 | for details. |
| 1027 | </p> |
| 1028 | </dd> |
| 1029 | </dl> |
| 1030 | |
| 1031 | <dl id="go_doc"><dt><a href="/pkg/go/doc/">go/doc</a></dt> |
| 1032 | <dd> |
| 1033 | <p><!-- CL 29870 --> |
| 1034 | The new <a href="/pkg/go/doc/#IsPredeclared"><code>IsPredeclared</code></a> |
| 1035 | function reports whether a string is a predeclared identifier. |
| 1036 | </p> |
| 1037 | </dd> |
| 1038 | </dl> |
| 1039 | |
| 1040 | <dl id="go_types"><dt><a href="/pkg/go/types/">go/types</a></dt> |
| 1041 | <dd> |
| 1042 | <p><!-- CL 30715 --> |
| 1043 | The new function |
| 1044 | <a href="/pkg/go/types/#Default"><code>Default</code></a> |
| 1045 | returns the default "typed" type for an "untyped" type. |
| 1046 | </p> |
| 1047 | |
| 1048 | <p><!-- CL 31939 --> |
| 1049 | The alignment of <code>complex64</code> now matches |
| 1050 | the <a href="/cmd/compile/">Go compiler</a>. |
| 1051 | </p> |
| 1052 | </dd> |
| 1053 | </dl> |
| 1054 | |
| 1055 | <dl id="html_template"><dt><a href="/pkg/html/template/">html/template</a></dt> |
| 1056 | <dd> |
| 1057 | <p><!-- CL 14336 --> |
| 1058 | The package now validates |
| 1059 | the <code>"type"</code> attribute on |
| 1060 | a <code><script></code> tag. |
| 1061 | </p> |
| 1062 | </dd> |
| 1063 | </dl> |
| 1064 | |
| 1065 | <dl id="image_png"><dt><a href="/pkg/image/png/">image/png</a></dt> |
| 1066 | <dd> |
| 1067 | <p> <!-- CL 32143, CL 32140 --> |
| 1068 | <a href="/pkg/image/png/#Decode"><code>Decode</code></a> |
| 1069 | (and <code>DecodeConfig</code>) |
| 1070 | now supports True Color and grayscale transparency. |
| 1071 | </p> |
| 1072 | <p> <!-- CL 29872 --> |
| 1073 | <a href="/pkg/image/png/#Encoder"><code>Encoder</code></a> |
| 1074 | is now faster and creates smaller output |
| 1075 | when encoding paletted images. |
| 1076 | </p> |
| 1077 | </dd> |
| 1078 | </dl> |
| 1079 | |
| 1080 | <dl id="math_big"><dt><a href="/pkg/math/big/">math/big</a></dt> |
| 1081 | <dd> |
| 1082 | <p><!-- CL 30706 --> |
| 1083 | The new method |
| 1084 | <a href="/pkg/math/big/#Int.Sqrt"><code>Int.Sqrt</code></a> |
| 1085 | calculates ⌊√x⌋. |
| 1086 | </p> |
| 1087 | |
| 1088 | <p> |
| 1089 | The new method |
| 1090 | <a href="/pkg/math/big/#Float.Scan"><code>Float.Scan</code></a> |
| 1091 | is a support routine for |
| 1092 | <a href="/pkg/fmt/#Scanner"><code>fmt.Scanner</code></a>. |
| 1093 | </p> |
| 1094 | |
| 1095 | <p> |
| 1096 | <a href="/pkg/math/big/#Int.ModInverse"><code>Int.ModInverse</code></a> |
| 1097 | now supports negative numbers. |
| 1098 | </p> |
| 1099 | |
| 1100 | </dd> |
| 1101 | </dl> |
| 1102 | |
| 1103 | <dl id="math_rand"><dt><a href="/pkg/math/rand/">math/rand</a></dt> |
| 1104 | <dd> |
| 1105 | |
| 1106 | <p><!-- CL 27253, CL 33456 --> |
| 1107 | The new <a href="/pkg/math/rand/#Rand.Uint64"><code>Rand.Uint64</code></a> |
| 1108 | method returns <code>uint64</code> values. The |
| 1109 | new <a href="/pkg/math/rand/#Source64"><code>Source64</code></a> |
| 1110 | interface describes sources capable of generating such values |
| 1111 | directly; otherwise the <code>Rand.Uint64</code> method |
| 1112 | constructs a <code>uint64</code> from two calls |
| 1113 | to <a href="/pkg/math/rand/#Source"><code>Source</code></a>'s |
| 1114 | <code>Int63</code> method. |
| 1115 | </p> |
| 1116 | |
| 1117 | </dd> |
| 1118 | </dl> |
| 1119 | |
| 1120 | <dl id="mime"><dt><a href="/pkg/mime/">mime</a></dt> |
| 1121 | <dd> |
| 1122 | <p> <!-- CL 32175 --> |
| 1123 | <a href="/pkg/mime/#ParseMediaType"><code>ParseMediaType</code></a> |
| 1124 | now preserves unnecessary backslash escapes as literals, |
| 1125 | in order to support MSIE. |
| 1126 | When MSIE sends a full file path (in “intranet mode”), it does not |
| 1127 | escape backslashes: “<code>C:\dev\go\foo.txt</code>”, not |
| 1128 | “<code>C:\\dev\\go\\foo.txt</code>”. |
| 1129 | If we see an unnecessary backslash escape, we now assume it is from MSIE |
| 1130 | and intended as a literal backslash. |
| 1131 | No known MIME generators emit unnecessary backslash escapes |
| 1132 | for simple token characters like numbers and letters. |
| 1133 | </p> |
| 1134 | </dd> |
| 1135 | </dl> |
| 1136 | |
| 1137 | <dl id="mime_quotedprintable"><dt><a href="/pkg/mime/quotedprintable/">mime/quotedprintable</a></dt> |
| 1138 | <dd> |
| 1139 | |
| 1140 | <p> |
| 1141 | The |
| 1142 | <a href="/pkg/mime/quotedprintable/#Reader"><code>Reader</code></a>'s |
| 1143 | parsing has been relaxed in two ways to accept |
| 1144 | more input seen in the wild. |
| 1145 | |
| 1146 | <!-- CL 32174 --> |
| 1147 | First, it accepts an equals sign (<code>=</code>) not followed |
| 1148 | by two hex digits as a literal equal sign. |
| 1149 | |
| 1150 | <!-- CL 27530 --> |
| 1151 | Second, it silently ignores a trailing equals sign at the end of |
| 1152 | an encoded input. |
| 1153 | </p> |
| 1154 | |
| 1155 | </dd> |
| 1156 | </dl> |
| 1157 | |
| 1158 | <dl id="net"><dt><a href="/pkg/net/">net</a></dt> |
| 1159 | <dd> |
| 1160 | |
| 1161 | <p><!-- CL 30164, CL 33473 --> |
| 1162 | The <a href="/pkg/net/#Conn"><code>Conn</code></a> documentation |
| 1163 | has been updated to clarify expectations of an interface |
| 1164 | implementation. Updates in the <code>net/http</code> packages |
| 1165 | depend on implementations obeying the documentation. |
| 1166 | </p> |
| 1167 | <p><i>Updating:</i> implementations of the <code>Conn</code> interface should verify |
| 1168 | they implement the documented semantics. The |
| 1169 | <a href="https://godoc.org/golang.org/x/net/nettest">golang.org/x/net/nettest</a> |
| 1170 | package will exercise a <code>Conn</code> and validate it behaves properly. |
| 1171 | </p> |
| 1172 | |
| 1173 | <p><!-- CL 32099 --> |
| 1174 | The new method |
| 1175 | <a href="/pkg/net/#UnixListener.SetUnlinkOnClose"><code>UnixListener.SetUnlinkOnClose</code></a> |
| 1176 | sets whether the underlying socket file should be removed from the file system when |
| 1177 | the listener is closed. |
| 1178 | </p> |
| 1179 | |
| 1180 | <p><!-- CL 29951 --> |
| 1181 | The new <a href="/pkg/net/#Buffers"><code>Buffers</code></a> type permits |
| 1182 | writing to the network more efficiently from multiple discontiguous buffers |
| 1183 | in memory. On certain machines, for certain types of connections, |
| 1184 | this is optimized into an OS-specific batch write operation (such as <code>writev</code>). |
| 1185 | </p> |
| 1186 | |
| 1187 | <p><!-- CL 29440 --> |
| 1188 | The new <a href="/pkg/net/#Resolver"><code>Resolver</code></a> looks up names and numbers |
| 1189 | and supports <a href="/pkg/context/#Context"><code>context.Context</code></a>. |
| 1190 | The <a href="/pkg/net/#Dialer"><code>Dialer</code></a> now has an optional |
| 1191 | <a href="/pkg/net/#Dialer.Resolver"><code>Resolver</code> field</a>. |
| 1192 | </p> |
| 1193 | |
| 1194 | <p><!-- CL 29892 --> |
| 1195 | <a href="/pkg/net/#Interfaces"><code>Interfaces</code></a> is now supported on Solaris. |
| 1196 | </p> |
| 1197 | |
| 1198 | <p><!-- CL 29233, CL 24901 --> |
| 1199 | The Go DNS resolver now supports <code>resolv.conf</code>'s “<code>rotate</code>” |
| 1200 | and “<code>option</code> <code>ndots:0</code>” options. The “<code>ndots</code>” option is |
| 1201 | now respected in the same way as <code>libresolve</code>. |
| 1202 | </p> |
| 1203 | |
| 1204 | </dd> |
| 1205 | </dl> |
| 1206 | |
| 1207 | <dl id="net_http"><dt><a href="/pkg/net/http/">net/http</a></dt> |
| 1208 | <dd> |
| 1209 | |
| 1210 | <p>Server changes:</p> |
| 1211 | <ul> |
| 1212 | <li>The server now supports graceful shutdown support, <a href="#http_shutdown">mentioned above</a>.</li> |
| 1213 | |
| 1214 | <li> <!-- CL 32024 --> |
| 1215 | The <a href="/pkg/net/http/#Server"><code>Server</code></a> |
| 1216 | adds configuration options |
| 1217 | <code>ReadHeaderTimeout</code> and <code>IdleTimeout</code> |
| 1218 | and documents <code>WriteTimeout</code>. |
| 1219 | </li> |
| 1220 | |
| 1221 | <li> <!-- CL 32014 --> |
| 1222 | <a href="/pkg/net/http/#FileServer"><code>FileServer</code></a> |
| 1223 | and |
| 1224 | <a href="/pkg/net/http/#ServeContent"><code>ServeContent</code></a> |
| 1225 | now support HTTP <code>If-Match</code> conditional requests, |
| 1226 | in addition to the previous <code>If-None-Match</code> |
| 1227 | support for ETags properly formatted according to RFC 7232, section 2.3. |
| 1228 | </li> |
| 1229 | </ul> |
| 1230 | |
| 1231 | <p> |
| 1232 | There are several additions to what a server's <code>Handler</code> can do: |
| 1233 | </p> |
| 1234 | |
| 1235 | <ul> |
| 1236 | <li><!-- CL 31173 --> |
| 1237 | The <a href="/pkg/context/#Context"><code>Context</code></a> |
| 1238 | returned |
| 1239 | by <a href="/pkg/net/http/#Request.Context"><code>Request.Context</code></a> |
| 1240 | is canceled if the underlying <code>net.Conn</code> |
| 1241 | closes. For instance, if the user closes their browser in the |
| 1242 | middle of a slow request, the <code>Handler</code> can now |
| 1243 | detect that the user is gone. This complements the |
| 1244 | existing <a href="/pkg/net/http/#CloseNotifier"><code>CloseNotifier</code></a> |
| 1245 | support. This functionality requires that the underlying |
| 1246 | <a href="/pkg/net/#Conn"><code>net.Conn</code></a> implements |
| 1247 | <a href="#net">recently clarified interface documentation</a>. |
| 1248 | </li> |
| 1249 | |
| 1250 | <li><!-- CL 32479 --> |
| 1251 | To serve trailers produced after the header has already been written, |
| 1252 | see the new |
| 1253 | <a href="/pkg/net/http/#TrailerPrefix"><code>TrailerPrefix</code></a> |
| 1254 | mechanism. |
| 1255 | </li> |
| 1256 | |
| 1257 | <li><!-- CL 33099 --> |
| 1258 | A <code>Handler</code> can now abort a response by panicking |
| 1259 | with the error |
| 1260 | <a href="/pkg/net/http/#ErrAbortHandler"><code>ErrAbortHandler</code></a>. |
| 1261 | </li> |
| 1262 | |
| 1263 | <li><!-- CL 30812 --> |
| 1264 | A <code>Write</code> of zero bytes to a |
| 1265 | <a href="/pkg/net/http/#ResponseWriter"><code>ResponseWriter</code></a> |
| 1266 | is now defined as a |
| 1267 | way to test whether a <code>ResponseWriter</code> has been hijacked: |
| 1268 | if so, the <code>Write</code> returns |
| 1269 | <a href="/pkg/net/http/#ErrHijacked"><code>ErrHijacked</code></a> |
| 1270 | without printing an error |
| 1271 | to the server's error log. |
| 1272 | </li> |
| 1273 | |
| 1274 | </ul> |
| 1275 | |
| 1276 | <p>Client & Transport changes:</p> |
| 1277 | <ul> |
| 1278 | <li><!-- CL 28930, CL 31435 --> |
| 1279 | The <a href="/pkg/net/http/#Client"><code>Client</code></a> |
| 1280 | now copies most request headers on redirect. See |
| 1281 | <a href="/pkg/net/http/#Client">the documentation</a> |
| 1282 | on the <code>Client</code> type for details. |
| 1283 | </li> |
| 1284 | |
| 1285 | <li><!-- CL 29072 --> |
| 1286 | The <a href="/pkg/net/http/#Transport"><code>Transport</code></a> |
| 1287 | now supports international domain names. Consequently, so do |
| 1288 | <a href="/pkg/net/http/#Get">Get</a> and other helpers. |
| 1289 | </li> |
| 1290 | |
| 1291 | <li><!-- CL 31733, CL 29852 --> |
| 1292 | The <code>Client</code> now supports 301, 307, and 308 redirects. |
| 1293 | |
| 1294 | For example, <code>Client.Post</code> now follows 301 |
| 1295 | redirects, converting them to <code>GET</code> requests |
| 1296 | without bodies, like it did for 302 and 303 redirect responses |
| 1297 | previously. |
| 1298 | |
| 1299 | The <code>Client</code> now also follows 307 and 308 |
| 1300 | redirects, preserving the original request method and body, if |
| 1301 | any. If the redirect requires resending the request body, the |
| 1302 | request must have the new |
| 1303 | <a href="/pkg/net/http/#Request"><code>Request.GetBody</code></a> |
| 1304 | field defined. |
| 1305 | <a href="/pkg/net/http/#NewRequest"><code>NewRequest</code></a> |
| 1306 | sets <code>Request.GetBody</code> automatically for common |
| 1307 | body types. |
| 1308 | </li> |
| 1309 | |
| 1310 | <li><!-- CL 32482 --> |
| 1311 | The <code>Transport</code> now rejects requests for URLs with |
| 1312 | ports containing non-digit characters. |
| 1313 | </li> |
| 1314 | |
| 1315 | <li><!-- CL 27117 --> |
| 1316 | The <code>Transport</code> will now retry non-idempotent |
| 1317 | requests if no bytes were written before a network failure |
| 1318 | and the request has no body. |
| 1319 | </li> |
| 1320 | |
| 1321 | <li><!-- CL 32481 --> |
| 1322 | The |
| 1323 | new <a href="/pkg/net/http/#Transport"><code>Transport.ProxyConnectHeader</code></a> |
| 1324 | allows configuration of header values to send to a proxy |
| 1325 | during a <code>CONNECT</code> request. |
| 1326 | </li> |
| 1327 | |
| 1328 | <li> <!-- CL 28077 --> |
| 1329 | The <a href="/pkg/net/http/#DefaultTransport"><code>DefaultTransport.Dialer</code></a> |
| 1330 | now enables <code>DualStack</code> ("<a href="https://tools.ietf.org/html/rfc6555">Happy Eyeballs</a>") support, |
| 1331 | allowing the use of IPv4 as a backup if it looks like IPv6 might be |
| 1332 | failing. |
| 1333 | </li> |
| 1334 | |
| 1335 | <li> <!-- CL 31726 --> |
| 1336 | The <a href="/pkg/net/http/#Transport"><code>Transport</code></a> |
| 1337 | no longer reads a byte of a non-nil |
| 1338 | <a href="/pkg/net/http/#Request.Body"><code>Request.Body</code></a> |
| 1339 | when the |
| 1340 | <a href="/pkg/net/http/#Request.ContentLength"><code>Request.ContentLength</code></a> |
| 1341 | is zero to determine whether the <code>ContentLength</code> |
| 1342 | is actually zero or just undefined. |
| 1343 | To explicitly signal that a body has zero length, |
| 1344 | either set it to <code>nil</code>, or set it to the new value |
| 1345 | <a href="/pkg/net/http/#NoBody"><code>NoBody</code></a>. |
| 1346 | The new <code>NoBody</code> value is intended for use by <code>Request</code> |
| 1347 | constructor functions; it is used by |
| 1348 | <a href="/pkg/net/http/#NewRequest"><code>NewRequest</code></a>. |
| 1349 | </li> |
| 1350 | </ul> |
| 1351 | |
| 1352 | </dd> |
| 1353 | </dl> |
| 1354 | |
| 1355 | <dl id="net_http_httptrace"><dt><a href="/pkg/net/http/httptrace/">net/http/httptrace</a></dt> |
| 1356 | <dd> |
| 1357 | <p> <!-- CL 30359 --> |
| 1358 | There is now support for tracing a client request's TLS handshakes with |
| 1359 | the new |
| 1360 | <a href="/pkg/net/http/httptrace/#ClientTrace.TLSHandshakeStart"><code>ClientTrace.TLSHandshakeStart</code></a> |
| 1361 | and |
| 1362 | <a href="/pkg/net/http/httptrace/#ClientTrace.TLSHandshakeDone"><code>ClientTrace.TLSHandshakeDone</code></a>. |
| 1363 | </p> |
| 1364 | </dd> |
| 1365 | </dl> |
| 1366 | |
| 1367 | <dl id="net_http_httputil"><dt><a href="/pkg/net/http/httputil/">net/http/httputil</a></dt> |
| 1368 | <dd> |
| 1369 | <p> <!-- CL 32356 --> |
| 1370 | The <a href="/pkg/net/http/httputil/#ReverseProxy"><code>ReverseProxy</code></a> |
| 1371 | has a new optional hook, |
| 1372 | <a href="/pkg/net/http/httputil/#ReverseProxy.ModifyResponse"><code>ModifyResponse</code></a>, |
| 1373 | for modifying the response from the back end before proxying it to the client. |
| 1374 | </p> |
| 1375 | |
| 1376 | </dd> |
| 1377 | </dl> |
| 1378 | |
| 1379 | <dl id="net_mail"><dt><a href="/pkg/net/mail/">net/mail</a></dt> |
| 1380 | <dd> |
| 1381 | |
| 1382 | <p> <!-- CL 32176 --> |
| 1383 | Empty quoted strings are once again allowed in the name part of |
| 1384 | an address. That is, Go 1.4 and earlier accepted |
| 1385 | <code>""</code> <code><gopher@example.com></code>, |
| 1386 | but Go 1.5 introduced a bug that rejected this address. |
| 1387 | The address is recognized again. |
| 1388 | </p> |
| 1389 | |
| 1390 | <p> <!-- CL 31581 --> |
| 1391 | The |
| 1392 | <a href="/pkg/net/mail/#Header.Date"><code>Header.Date</code></a> |
| 1393 | method has always provided a way to parse |
| 1394 | the <code>Date:</code> header. |
| 1395 | A new function |
| 1396 | <a href="/pkg/net/mail/#ParseDate"><code>ParseDate</code></a> |
| 1397 | allows parsing dates found in other |
| 1398 | header lines, such as the <code>Resent-Date:</code> header. |
| 1399 | </p> |
| 1400 | |
| 1401 | </dd> |
| 1402 | </dl> |
| 1403 | |
| 1404 | <dl id="net_smtp"><dt><a href="/pkg/net/smtp/">net/smtp</a></dt> |
| 1405 | <dd> |
| 1406 | |
| 1407 | <p> <!-- CL 33143 --> |
| 1408 | If an implementation of the |
| 1409 | <a href="/pkg/net/smtp/#Auth"><code>Auth.Start</code></a> |
| 1410 | method returns an empty <code>toServer</code> value, |
| 1411 | the package no longer sends |
| 1412 | trailing whitespace in the SMTP <code>AUTH</code> command, |
| 1413 | which some servers rejected. |
| 1414 | </p> |
| 1415 | |
| 1416 | </dd> |
| 1417 | </dl> |
| 1418 | |
| 1419 | <dl id="net_url"><dt><a href="/pkg/net/url/">net/url</a></dt> |
| 1420 | <dd> |
| 1421 | |
| 1422 | <p> <!-- CL 31322 --> |
| 1423 | The new functions |
| 1424 | <a href="/pkg/net/url/#PathEscape"><code>PathEscape</code></a> |
| 1425 | and |
| 1426 | <a href="/pkg/net/url/#PathUnescape"><code>PathUnescape</code></a> |
| 1427 | are similar to the query escaping and unescaping functions but |
| 1428 | for path elements. |
| 1429 | </p> |
| 1430 | |
| 1431 | <p> <!-- CL 28933 --> |
| 1432 | The new methods |
| 1433 | <a href="/pkg/net/url/#URL.Hostname"><code>URL.Hostname</code></a> |
| 1434 | and |
| 1435 | <a href="/pkg/net/url/#URL.Port"><code>URL.Port</code></a> |
| 1436 | return the hostname and port fields of a URL, |
| 1437 | correctly handling the case where the port may not be present. |
| 1438 | </p> |
| 1439 | |
| 1440 | <p> <!-- CL 28343 --> |
| 1441 | The existing method |
| 1442 | <a href="/pkg/net/url/#URL.ResolveReference"><code>URL.ResolveReference</code></a> |
| 1443 | now properly handles paths with escaped bytes without losing |
| 1444 | the escaping. |
| 1445 | </p> |
| 1446 | |
| 1447 | <p> <!-- CL 31467 --> |
| 1448 | The <code>URL</code> type now implements |
| 1449 | <a href="/pkg/encoding/#BinaryMarshaler"><code>encoding.BinaryMarshaler</code></a> and |
| 1450 | <a href="/pkg/encoding/#BinaryUnmarshaler"><code>encoding.BinaryUnmarshaler</code></a>, |
| 1451 | making it possible to process URLs in <a href="/pkg/encoding/gob/">gob data</a>. |
| 1452 | </p> |
| 1453 | |
| 1454 | <p> <!-- CL 29610, CL 31582 --> |
| 1455 | Following RFC 3986, |
| 1456 | <a href="/pkg/net/url/#Parse"><code>Parse</code></a> |
| 1457 | now rejects URLs like <code>this_that:other/thing</code> instead of |
| 1458 | interpreting them as relative paths (<code>this_that</code> is not a valid scheme). |
| 1459 | To force interpretation as a relative path, |
| 1460 | such URLs should be prefixed with “<code>./</code>”. |
| 1461 | The <code>URL.String</code> method now inserts this prefix as needed. |
| 1462 | </p> |
| 1463 | |
| 1464 | </dd> |
| 1465 | </dl> |
| 1466 | |
| 1467 | <dl id="os"><dt><a href="/pkg/os/">os</a></dt> |
| 1468 | <dd> |
| 1469 | <p> <!-- CL 16551 --> |
| 1470 | The new function |
| 1471 | <a href="/pkg/os/#Executable"><code>Executable</code></a> returns |
| 1472 | the path name of the running executable. |
| 1473 | </p> |
| 1474 | |
| 1475 | <p> <!-- CL 30614 --> |
| 1476 | An attempt to call a method on |
| 1477 | an <a href="/pkg/os/#File"><code>os.File</code></a> that has |
| 1478 | already been closed will now return the new error |
| 1479 | value <a href="/pkg/os/#ErrClosed"><code>os.ErrClosed</code></a>. |
| 1480 | Previously it returned a system-specific error such |
| 1481 | as <code>syscall.EBADF</code>. |
| 1482 | </p> |
| 1483 | |
| 1484 | <p> <!-- CL 31358 --> |
| 1485 | On Unix systems, <a href="/pkg/os/#Rename"><code>os.Rename</code></a> |
| 1486 | will now return an error when used to rename a directory to an |
| 1487 | existing empty directory. |
| 1488 | Previously it would fail when renaming to a non-empty directory |
| 1489 | but succeed when renaming to an empty directory. |
| 1490 | This makes the behavior on Unix correspond to that of other systems. |
| 1491 | </p> |
| 1492 | |
| 1493 | <p> <!-- CL 32451 --> |
| 1494 | On Windows, long absolute paths are now transparently converted to |
| 1495 | extended-length paths (paths that start with “<code>\\?\</code>”). |
| 1496 | This permits the package to work with files whose path names are |
| 1497 | longer than 260 characters. |
| 1498 | </p> |
| 1499 | |
| 1500 | <p> <!-- CL 29753 --> |
| 1501 | On Windows, <a href="/pkg/os/#IsExist"><code>os.IsExist</code></a> |
| 1502 | will now return <code>true</code> for the system |
| 1503 | error <code>ERROR_DIR_NOT_EMPTY</code>. |
| 1504 | This roughly corresponds to the existing handling of the Unix |
| 1505 | error <code>ENOTEMPTY</code>. |
| 1506 | </p> |
| 1507 | |
| 1508 | <p> <!-- CL 32152 --> |
| 1509 | On Plan 9, files that are not served by <code>#M</code> will now |
| 1510 | have <a href="/pkg/os/#ModeDevice"><code>ModeDevice</code></a> set in |
| 1511 | the value returned |
| 1512 | by <a href="/pkg/os/#FileInfo"><code>FileInfo.Mode</code></a>. |
| 1513 | </p> |
| 1514 | </dd> |
| 1515 | </dl> |
| 1516 | |
| 1517 | <dl id="path_filepath"><dt><a href="/pkg/path/filepath/">path/filepath</a></dt> |
| 1518 | <dd> |
| 1519 | <p> |
| 1520 | A number of bugs and corner cases on Windows were fixed: |
| 1521 | <a href="/pkg/path/filepath/#Abs"><code>Abs</code></a> now calls <code>Clean</code> as documented, |
| 1522 | <a href="/pkg/path/filepath/#Glob"><code>Glob</code></a> now matches |
| 1523 | “<code>\\?\c:\*</code>”, |
| 1524 | <a href="/pkg/path/filepath/#EvalSymlinks"><code>EvalSymlinks</code></a> now |
| 1525 | correctly handles “<code>C:.</code>”, and |
| 1526 | <a href="/pkg/path/filepath/#Clean"><code>Clean</code></a> now properly |
| 1527 | handles a leading “<code>..</code>” in the path. |
| 1528 | </p> |
| 1529 | </dd> |
| 1530 | </dl> |
| 1531 | |
| 1532 | <dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt> |
| 1533 | <dd> |
| 1534 | <p> <!-- CL 30088 --> |
| 1535 | The new function |
| 1536 | <a href="/pkg/reflect/#Swapper"><code>Swapper</code></a> was |
| 1537 | added to support <a href="#sortslice"><code>sort.Slice</code></a>. |
| 1538 | </p> |
| 1539 | </dd> |
| 1540 | </dl> |
| 1541 | |
| 1542 | <dl id="strconv"><dt><a href="/pkg/strconv/">strconv</a></dt> |
| 1543 | <dd> |
| 1544 | <p> <!-- CL 31210 --> |
| 1545 | The <a href="/pkg/strconv/#Unquote"><code>Unquote</code></a> |
| 1546 | function now strips carriage returns (<code>\r</code>) in |
| 1547 | backquoted raw strings, following the |
| 1548 | <a href="/ref/spec#String_literals">Go language semantics</a>. |
| 1549 | </p> |
| 1550 | </dd> |
| 1551 | </dl> |
| 1552 | |
| 1553 | <dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt> |
| 1554 | <dd> |
| 1555 | <p> <!-- CL 25050, CL 25022 --> |
| 1556 | The <a href="/pkg/syscall/#Getpagesize"><code>Getpagesize</code></a> |
| 1557 | now returns the system's size, rather than a constant value. |
| 1558 | Previously it always returned 4KB. |
| 1559 | </p> |
| 1560 | |
| 1561 | <p> <!-- CL 31446 --> |
| 1562 | The signature |
| 1563 | of <a href="/pkg/syscall/#Utimes"><code>Utimes</code></a> has |
| 1564 | changed on Solaris to match all the other Unix systems' |
| 1565 | signature. Portable code should continue to use |
| 1566 | <a href="/pkg/os/#Chtimes"><code>os.Chtimes</code></a> instead. |
| 1567 | </p> |
| 1568 | |
| 1569 | <p> <!-- CL 32319 --> |
| 1570 | The <code>X__cmsg_data</code> field has been removed from |
| 1571 | <a href="/pkg/syscall/#Cmsghdr"><code>Cmsghdr</code></a>. |
| 1572 | </p> |
| 1573 | </dd> |
| 1574 | </dl> |
| 1575 | |
| 1576 | <dl id="text_template"><dt><a href="/pkg/text/template/">text/template</a></dt> |
| 1577 | <dd> |
| 1578 | <p> <!-- CL 31462 --> |
| 1579 | <a href="/pkg/text/template/#Template.Execute"><code>Template.Execute</code></a> |
| 1580 | can now take a |
| 1581 | <a href="/pkg/reflect/#Value"><code>reflect.Value</code></a> as its data |
| 1582 | argument, and |
| 1583 | <a href="/pkg/text/template/#FuncMap"><code>FuncMap</code></a> |
| 1584 | functions can also accept and return <code>reflect.Value</code>. |
| 1585 | </p> |
| 1586 | |
| 1587 | </dd> |
| 1588 | </dl> |
| 1589 | |
| 1590 | <dl id="time"><dt><a href="/pkg/time/">time</a></dt> |
| 1591 | <dd> |
| 1592 | |
| 1593 | <p> <!-- CL 20118 --> The new function |
| 1594 | <a href="/pkg/time/#Until"><code>Until</code></a> complements |
| 1595 | the analogous <code>Since</code> function. |
| 1596 | </p> |
| 1597 | |
| 1598 | <p> <!-- CL 29338 --> |
| 1599 | <a href="/pkg/time/#ParseDuration"><code>ParseDuration</code></a> |
| 1600 | now accepts long fractional parts. |
| 1601 | </p> |
| 1602 | |
| 1603 | <p> <!-- CL 33429 --> |
| 1604 | <a href="/pkg/time/#Parse"><code>Parse</code></a> |
| 1605 | now rejects dates before the start of a month, such as June 0; |
| 1606 | it already rejected dates beyond the end of the month, such as |
| 1607 | June 31 and July 32. |
| 1608 | </p> |
| 1609 | |
| 1610 | <p> <!-- CL 33029 --> <!-- CL 34816 --> |
| 1611 | The <code>tzdata</code> database has been updated to version |
| 1612 | 2016j for systems that don't already have a local time zone |
| 1613 | database. |
| 1614 | </p> |
| 1615 | |
| 1616 | <p> |
| 1617 | </dd> |
| 1618 | </dl> |
| 1619 | |
| 1620 | <dl id="testing"><dt><a href="/pkg/testing/">testing</a></dt> |
| 1621 | <dd> |
| 1622 | <p><!-- CL 29970 --> |
| 1623 | The new method |
| 1624 | <a href="/pkg/testing/#T.Name"><code>T.Name</code></a> |
| 1625 | (and <code>B.Name</code>) returns the name of the current |
| 1626 | test or benchmark. |
| 1627 | </p> |
| 1628 | |
| 1629 | <p><!-- CL 32483 --> |
| 1630 | The new function |
| 1631 | <a href="/pkg/testing/#CoverMode"><code>CoverMode</code></a> |
| 1632 | reports the test coverage mode. |
| 1633 | </p> |
| 1634 | |
| 1635 | <p><!-- CL 32615 --> |
| 1636 | Tests and benchmarks are now marked as failed if the race |
| 1637 | detector is enabled and a data race occurs during execution. |
| 1638 | Previously, individual test cases would appear to pass, |
| 1639 | and only the overall execution of the test binary would fail. |
| 1640 | </p> |
| 1641 | |
| 1642 | <p><!-- CL 32455 --> |
| 1643 | The signature of the |
| 1644 | <a href="/pkg/testing/#MainStart"><code>MainStart</code></a> |
| 1645 | function has changed, as allowed by the documentation. It is an |
| 1646 | internal detail and not part of the Go 1 compatibility promise. |
| 1647 | If you're not calling <code>MainStart</code> directly but see |
| 1648 | errors, that likely means you set the |
| 1649 | normally-empty <code>GOROOT</code> environment variable and it |
| 1650 | doesn't match the version of your <code>go</code> command's binary. |
| 1651 | </p> |
| 1652 | |
| 1653 | </dd> |
| 1654 | </dl> |
| 1655 | |
| 1656 | <dl id="unicode"><dt><a href="/pkg/unicode/">unicode</a></dt> |
| 1657 | <dd> |
| 1658 | <p><!-- CL 30935 --> |
| 1659 | <a href="/pkg/unicode/#SimpleFold"><code>SimpleFold</code></a> |
| 1660 | now returns its argument unchanged if the provided input was an invalid rune. |
| 1661 | Previously, the implementation failed with an index bounds check panic. |
| 1662 | </p> |
| 1663 | </dd> |
| 1664 | </dl> |