go1.7.html 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281
  1. <!--{
  2. "Title": "Go 1.7 Release Notes",
  3. "Path": "/doc/go1.7",
  4. "Template": true
  5. }-->
  6. <!--
  7. for acme:
  8. Edit .,s;^PKG:([a-z][A-Za-z0-9_/]+);<a href="/pkg/\1/"><code>\1</code></a>;g
  9. Edit .,s;^([a-z][A-Za-z0-9_/]+)\.([A-Z][A-Za-z0-9_]+\.)?([A-Z][A-Za-z0-9_]+)([ .',)]|$);<a href="/pkg/\1/#\2\3"><code>\3</code></a>\4;g
  10. Edit .,s;^FULL:([a-z][A-Za-z0-9_/]+)\.([A-Z][A-Za-z0-9_]+\.)?([A-Z][A-Za-z0-9_]+)([ .',)]|$);<a href="/pkg/\1/#\2\3"><code>\1.\2\3</code></a>\4;g
  11. Edit .,s;^DPKG:([a-z][A-Za-z0-9_/]+);<dl id="\1"><a href="/pkg/\1/">\1</a></dl>;g
  12. rsc last updated through 6729576
  13. -->
  14. <!--
  15. NOTE: In this document and others in this directory, the convention is to
  16. set fixed-width phrases with non-fixed-width spaces, as in
  17. <code>hello</code> <code>world</code>.
  18. Do not send CLs removing the interior tags from such phrases.
  19. -->
  20. <style>
  21. ul li { margin: 0.5em 0; }
  22. </style>
  23. <h2 id="introduction">Introduction to Go 1.7</h2>
  24. <p>
  25. The latest Go release, version 1.7, arrives six months after 1.6.
  26. Most of its changes are in the implementation of the toolchain, runtime, and libraries.
  27. There is one minor change to the language specification.
  28. As always, the release maintains the Go 1 <a href="/doc/go1compat.html">promise of compatibility</a>.
  29. We expect almost all Go programs to continue to compile and run as before.
  30. </p>
  31. <p>
  32. The release <a href="#ports">adds a port to IBM LinuxOne</a>;
  33. <a href="#compiler">updates the x86-64 compiler back end</a> to generate more efficient code;
  34. includes the <a href="#context">context package</a>, promoted from the
  35. <a href="https://golang.org/x/net/context">x/net subrepository</a>
  36. and now used in the standard library;
  37. and <a href="#testing">adds support in the testing package</a> for
  38. creating hierarchies of tests and benchmarks.
  39. The release also <a href="#cmd_go">finalizes the vendoring support</a>
  40. started in Go 1.5, making it a standard feature.
  41. </p>
  42. <h2 id="language">Changes to the language</h2>
  43. <p>
  44. There is one tiny language change in this release.
  45. The section on <a href="/ref/spec#Terminating_statements">terminating statements</a>
  46. clarifies that to determine whether a statement list ends in a terminating statement,
  47. the “final non-empty statement” is considered the end,
  48. matching the existing behavior of the gc and gccgo compiler toolchains.
  49. In earlier releases the definition referred only to the “final statement,”
  50. leaving the effect of trailing empty statements at the least unclear.
  51. The <a href="/pkg/go/types/"><code>go/types</code></a>
  52. package has been updated to match the gc and gccgo compiler toolchains
  53. in this respect.
  54. This change has no effect on the correctness of existing programs.
  55. </p>
  56. <h2 id="ports">Ports</h2>
  57. <p>
  58. Go 1.7 adds support for macOS 10.12 Sierra.
  59. Binaries built with versions of Go before 1.7 will not work
  60. correctly on Sierra.
  61. </p>
  62. <p>
  63. Go 1.7 adds an experimental port to <a href="https://en.wikipedia.org/wiki/Linux_on_z_Systems">Linux on z Systems</a> (<code>linux/s390x</code>)
  64. and the beginning of a port to Plan 9 on ARM (<code>plan9/arm</code>).
  65. </p>
  66. <p>
  67. The experimental ports to Linux on 64-bit MIPS (<code>linux/mips64</code> and <code>linux/mips64le</code>)
  68. added in Go 1.6 now have full support for cgo and external linking.
  69. </p>
  70. <p>
  71. The experimental port to Linux on little-endian 64-bit PowerPC (<code>linux/ppc64le</code>)
  72. now requires the POWER8 architecture or later.
  73. Big-endian 64-bit PowerPC (<code>linux/ppc64</code>) only requires the
  74. POWER5 architecture.
  75. </p>
  76. <p>
  77. The OpenBSD port now requires OpenBSD 5.6 or later, for access to the <a href="http://man.openbsd.org/getentropy.2"><i>getentropy</i>(2)</a> system call.
  78. </p>
  79. <h3 id="known_issues">Known Issues</h3>
  80. <p>
  81. There are some instabilities on FreeBSD that are known but not understood.
  82. These can lead to program crashes in rare cases.
  83. See <a href="https://golang.org/issue/16136">issue 16136</a>,
  84. <a href="https://golang.org/issue/15658">issue 15658</a>,
  85. and <a href="https://golang.org/issue/16396">issue 16396</a>.
  86. Any help in solving these FreeBSD-specific issues would be appreciated.
  87. </p>
  88. <h2 id="tools">Tools</h2>
  89. <h3 id="cmd_asm">Assembler</h3>
  90. <p>
  91. For 64-bit ARM systems, the vector register names have been
  92. corrected to <code>V0</code> through <code>V31</code>;
  93. previous releases incorrectly referred to them as <code>V32</code> through <code>V63</code>.
  94. </p>
  95. <p>
  96. For 64-bit x86 systems, the following instructions have been added:
  97. <code>PCMPESTRI</code>,
  98. <code>RORXL</code>,
  99. <code>RORXQ</code>,
  100. <code>VINSERTI128</code>,
  101. <code>VPADDD</code>,
  102. <code>VPADDQ</code>,
  103. <code>VPALIGNR</code>,
  104. <code>VPBLENDD</code>,
  105. <code>VPERM2F128</code>,
  106. <code>VPERM2I128</code>,
  107. <code>VPOR</code>,
  108. <code>VPSHUFB</code>,
  109. <code>VPSHUFD</code>,
  110. <code>VPSLLD</code>,
  111. <code>VPSLLDQ</code>,
  112. <code>VPSLLQ</code>,
  113. <code>VPSRLD</code>,
  114. <code>VPSRLDQ</code>,
  115. and
  116. <code>VPSRLQ</code>.
  117. </p>
  118. <h3 id="compiler">Compiler Toolchain</h3>
  119. <p>
  120. This release includes a new code generation back end for 64-bit x86 systems,
  121. following a <a href="https://golang.org/s/go17ssa">proposal from 2015</a>
  122. that has been under development since then.
  123. The new back end, based on
  124. <a href="https://en.wikipedia.org/wiki/Static_single_assignment_form">SSA</a>,
  125. generates more compact, more efficient code
  126. and provides a better platform for optimizations
  127. such as bounds check elimination.
  128. The new back end reduces the CPU time required by
  129. <a href="https://golang.org/test/bench/go1/">our benchmark programs</a> by 5-35%.
  130. </p>
  131. <p>
  132. For this release, the new back end can be disabled by passing
  133. <code>-ssa=0</code> to the compiler.
  134. If you find that your program compiles or runs successfully
  135. only with the new back end disabled, please
  136. <a href="https://golang.org/issue/new">file a bug report</a>.
  137. </p>
  138. <p>
  139. The format of exported metadata written by the compiler in package archives has changed:
  140. the old textual format has been replaced by a more compact binary format.
  141. This results in somewhat smaller package archives and fixes a few
  142. long-standing corner case bugs.
  143. </p>
  144. <p>
  145. For this release, the new export format can be disabled by passing
  146. <code>-newexport=0</code> to the compiler.
  147. If you find that your program compiles or runs successfully
  148. only with the new export format disabled, please
  149. <a href="https://golang.org/issue/new">file a bug report</a>.
  150. </p>
  151. <p>
  152. The linker's <code>-X</code> option no longer supports the unusual two-argument form
  153. <code>-X</code> <code>name</code> <code>value</code>,
  154. as <a href="/doc/go1.6#compiler">announced</a> in the Go 1.6 release
  155. and in warnings printed by the linker.
  156. Use <code>-X</code> <code>name=value</code> instead.
  157. </p>
  158. <p>
  159. The compiler and linker have been optimized and run significantly faster in this release than in Go 1.6,
  160. although they are still slower than we would like and will continue to be optimized in future releases.
  161. </p>
  162. <p>
  163. Due to changes across the compiler toolchain and standard library,
  164. binaries built with this release should typically be smaller than binaries
  165. built with Go 1.6,
  166. sometimes by as much as 20-30%.
  167. </p>
  168. <p>
  169. On x86-64 systems, Go programs now maintain stack frame pointers
  170. as expected by profiling tools like Linux's perf and Intel's VTune,
  171. making it easier to analyze and optimize Go programs using these tools.
  172. The frame pointer maintenance has a small run-time overhead that varies
  173. but averages around 2%. We hope to reduce this cost in future releases.
  174. To build a toolchain that does not use frame pointers, set
  175. <code>GOEXPERIMENT=noframepointer</code> when running
  176. <code>make.bash</code>, <code>make.bat</code>, or <code>make.rc</code>.
  177. </p>
  178. <h3 id="cmd_cgo">Cgo</h3>
  179. <p>
  180. Packages using <a href="/cmd/cgo/">cgo</a> may now include
  181. Fortran source files (in addition to C, C++, Objective C, and SWIG),
  182. although the Go bindings must still use C language APIs.
  183. </p>
  184. <p>
  185. Go bindings may now use a new helper function <code>C.CBytes</code>.
  186. In contrast to <code>C.CString</code>, which takes a Go <code>string</code>
  187. and returns a <code>*C.byte</code> (a C <code>char*</code>),
  188. <code>C.CBytes</code> takes a Go <code>[]byte</code>
  189. and returns an <code>unsafe.Pointer</code> (a C <code>void*</code>).
  190. </p>
  191. <p>
  192. Packages and binaries built using <code>cgo</code> have in past releases
  193. produced different output on each build,
  194. due to the embedding of temporary directory names.
  195. When using this release with
  196. new enough versions of GCC or Clang
  197. (those that support the <code>-fdebug-prefix-map</code> option),
  198. those builds should finally be deterministic.
  199. </p>
  200. <h3 id="gccgo">Gccgo</h3>
  201. <p>
  202. Due to the alignment of Go's semiannual release schedule with GCC's annual release schedule,
  203. GCC release 6 contains the Go 1.6.1 version of gccgo.
  204. The next release, GCC 7, will likely have the Go 1.8 version of gccgo.
  205. </p>
  206. <h3 id="cmd_go">Go command</h3>
  207. <p>
  208. The <a href="/cmd/go/"><code>go</code></a> command's basic operation
  209. is unchanged, but there are a number of changes worth noting.
  210. </p>
  211. <p>
  212. This release removes support for the <code>GO15VENDOREXPERIMENT</code> environment variable,
  213. as <a href="/doc/go1.6#go_command">announced</a> in the Go 1.6 release.
  214. <a href="https://golang.org/s/go15vendor">Vendoring support</a>
  215. is now a standard feature of the <code>go</code> command and toolchain.
  216. </p>
  217. <p>
  218. The <code>Package</code> data structure made available to
  219. “<code>go</code> <code>list</code>” now includes a
  220. <code>StaleReason</code> field explaining why a particular package
  221. is or is not considered stale (in need of rebuilding).
  222. This field is available to the <code>-f</code> or <code>-json</code>
  223. options and is useful for understanding why a target is being rebuilt.
  224. </p>
  225. <p>
  226. The “<code>go</code> <code>get</code>” command now supports
  227. import paths referring to <code>git.openstack.org</code>.
  228. </p>
  229. <p>
  230. This release adds experimental, minimal support for building programs using
  231. <a href="/pkg/go/build#hdr-Binary_Only_Packages">binary-only packages</a>,
  232. packages distributed in binary form
  233. without the corresponding source code.
  234. This feature is needed in some commercial settings
  235. but is not intended to be fully integrated into the rest of the toolchain.
  236. For example, tools that assume access to complete source code
  237. will not work with such packages, and there are no plans to support
  238. such packages in the “<code>go</code> <code>get</code>” command.
  239. </p>
  240. <h3 id="cmd_doc">Go doc</h3>
  241. <p>
  242. The “<code>go</code> <code>doc</code>” command
  243. now groups constructors with the type they construct,
  244. following <a href="/cmd/godoc/"><code>godoc</code></a>.
  245. </p>
  246. <h3 id="cmd_vet">Go vet</h3>
  247. <p>
  248. The “<code>go</code> <code>vet</code>” command
  249. has more accurate analysis in its <code>-copylock</code> and <code>-printf</code> checks,
  250. and a new <code>-tests</code> check that checks the name and signature of likely test functions.
  251. To avoid confusion with the new <code>-tests</code> check, the old, unadvertised
  252. <code>-test</code> option has been removed; it was equivalent to <code>-all</code> <code>-shadow</code>.
  253. </p>
  254. <p id="vet_lostcancel">
  255. The <code>vet</code> command also has a new check,
  256. <code>-lostcancel</code>, which detects failure to call the
  257. cancelation function returned by the <code>WithCancel</code>,
  258. <code>WithTimeout</code>, and <code>WithDeadline</code> functions in
  259. Go 1.7's new <code>context</code> package (see <a
  260. href='#context'>below</a>).
  261. Failure to call the function prevents the new <code>Context</code>
  262. from being reclaimed until its parent is cancelled.
  263. (The background context is never cancelled.)
  264. </p>
  265. <h3 id="cmd_dist">Go tool dist</h3>
  266. <p>
  267. The new subcommand “<code>go</code> <code>tool</code> <code>dist</code> <code>list</code>”
  268. prints all supported operating system/architecture pairs.
  269. </p>
  270. <h3 id="cmd_trace">Go tool trace</h3>
  271. <p>
  272. The “<code>go</code> <code>tool</code> <code>trace</code>” command,
  273. <a href="/doc/go1.5#trace_command">introduced in Go 1.5</a>,
  274. has been refined in various ways.
  275. </p>
  276. <p>
  277. First, collecting traces is significantly more efficient than in past releases.
  278. In this release, the typical execution-time overhead of collecting a trace is about 25%;
  279. in past releases it was at least 400%.
  280. Second, trace files now include file and line number information,
  281. making them more self-contained and making the
  282. original executable optional when running the trace tool.
  283. Third, the trace tool now breaks up large traces to avoid limits
  284. in the browser-based viewer.
  285. </p>
  286. <p>
  287. Although the trace file format has changed in this release,
  288. the Go 1.7 tools can still read traces from earlier releases.
  289. </p>
  290. <h2 id="performance">Performance</h2>
  291. <p>
  292. As always, the changes are so general and varied that precise statements
  293. about performance are difficult to make.
  294. Most programs should run a bit faster,
  295. due to speedups in the garbage collector and
  296. optimizations in the core library.
  297. On x86-64 systems, many programs will run significantly faster,
  298. due to improvements in generated code brought by the
  299. new compiler back end.
  300. As noted above, in our own benchmarks,
  301. the code generation changes alone typically reduce program CPU time by 5-35%.
  302. </p>
  303. <p>
  304. <!-- git log -''-grep '-[0-9][0-9]\.[0-9][0-9]%' go1.6.. -->
  305. There have been significant optimizations bringing more than 10% improvements
  306. to implementations in the
  307. <a href="/pkg/crypto/sha1/"><code>crypto/sha1</code></a>,
  308. <a href="/pkg/crypto/sha256/"><code>crypto/sha256</code></a>,
  309. <a href="/pkg/encoding/binary/"><code>encoding/binary</code></a>,
  310. <a href="/pkg/fmt/"><code>fmt</code></a>,
  311. <a href="/pkg/hash/adler32/"><code>hash/adler32</code></a>,
  312. <a href="/pkg/hash/crc32/"><code>hash/crc32</code></a>,
  313. <a href="/pkg/hash/crc64/"><code>hash/crc64</code></a>,
  314. <a href="/pkg/image/color/"><code>image/color</code></a>,
  315. <a href="/pkg/math/big/"><code>math/big</code></a>,
  316. <a href="/pkg/strconv/"><code>strconv</code></a>,
  317. <a href="/pkg/strings/"><code>strings</code></a>,
  318. <a href="/pkg/unicode/"><code>unicode</code></a>,
  319. and
  320. <a href="/pkg/unicode/utf16/"><code>unicode/utf16</code></a>
  321. packages.
  322. </p>
  323. <p>
  324. Garbage collection pauses should be significantly shorter than they
  325. were in Go 1.6 for programs with large numbers of idle goroutines,
  326. substantial stack size fluctuation, or large package-level variables.
  327. </p>
  328. <h2 id="library">Core library</h2>
  329. <h3 id="context">Context</h3>
  330. <p>
  331. Go 1.7 moves the <code>golang.org/x/net/context</code> package
  332. into the standard library as <a href="/pkg/context/"><code>context</code></a>.
  333. This allows the use of contexts for cancelation, timeouts, and passing
  334. request-scoped data in other standard library packages,
  335. including
  336. <a href="#net">net</a>,
  337. <a href="#net_http">net/http</a>,
  338. and
  339. <a href="#os_exec">os/exec</a>,
  340. as noted below.
  341. </p>
  342. <p>
  343. For more information about contexts, see the
  344. <a href="/pkg/context/">package documentation</a>
  345. and the Go blog post
  346. “<a href="https://blog.golang.org/context">Go Concurrent Patterns: Context</a>.”
  347. </p>
  348. <h3 id="httptrace">HTTP Tracing</h3>
  349. <p>
  350. Go 1.7 introduces <a href="/pkg/net/http/httptrace/"><code>net/http/httptrace</code></a>,
  351. a package that provides mechanisms for tracing events within HTTP requests.
  352. </p>
  353. <h3 id="testing">Testing</h3>
  354. <p>
  355. The <code>testing</code> package now supports the definition
  356. of tests with subtests and benchmarks with sub-benchmarks.
  357. This support makes it easy to write table-driven benchmarks
  358. and to create hierarchical tests.
  359. It also provides a way to share common setup and tear-down code.
  360. See the <a href="/pkg/testing/#hdr-Subtests_and_Sub_benchmarks">package documentation</a> for details.
  361. </p>
  362. <h3 id="runtime">Runtime</h3>
  363. <p>
  364. All panics started by the runtime now use panic values
  365. that implement both the
  366. builtin <a href="/ref/spec#Errors"><code>error</code></a>,
  367. and
  368. <a href="/pkg/runtime/#Error"><code>runtime.Error</code></a>,
  369. as
  370. <a href="/ref/spec#Run_time_panics">required by the language specification</a>.
  371. </p>
  372. <p>
  373. During panics, if a signal's name is known, it will be printed in the stack trace.
  374. Otherwise, the signal's number will be used, as it was before Go1.7.
  375. </p>
  376. <p>
  377. The new function
  378. <a href="/pkg/runtime/#KeepAlive"><code>KeepAlive</code></a>
  379. provides an explicit mechanism for declaring
  380. that an allocated object must be considered reachable
  381. at a particular point in a program,
  382. typically to delay the execution of an associated finalizer.
  383. </p>
  384. <p>
  385. The new function
  386. <a href="/pkg/runtime/#CallersFrames"><code>CallersFrames</code></a>
  387. translates a PC slice obtained from
  388. <a href="/pkg/runtime/#Callers"><code>Callers</code></a>
  389. into a sequence of frames corresponding to the call stack.
  390. This new API should be preferred instead of direct use of
  391. <a href="/pkg/runtime/#FuncForPC"><code>FuncForPC</code></a>,
  392. because the frame sequence can more accurately describe
  393. call stacks with inlined function calls.
  394. </p>
  395. <p>
  396. The new function
  397. <a href="/pkg/runtime/#SetCgoTraceback"><code>SetCgoTraceback</code></a>
  398. facilitates tighter integration between Go and C code executing
  399. in the same process called using cgo.
  400. </p>
  401. <p>
  402. On 32-bit systems, the runtime can now use memory allocated
  403. by the operating system anywhere in the address space,
  404. eliminating the
  405. “memory allocated by OS not in usable range” failure
  406. common in some environments.
  407. </p>
  408. <p>
  409. The runtime can now return unused memory to the operating system on
  410. all architectures.
  411. In Go 1.6 and earlier, the runtime could not
  412. release memory on ARM64, 64-bit PowerPC, or MIPS.
  413. </p>
  414. <p>
  415. On Windows, Go programs in Go 1.5 and earlier forced
  416. the global Windows timer resolution to 1ms at startup
  417. by calling <code>timeBeginPeriod(1)</code>.
  418. Changing the global timer resolution caused problems on some systems,
  419. and testing suggested that the call was not needed for good scheduler performance,
  420. so Go 1.6 removed the call.
  421. Go 1.7 brings the call back: under some workloads the call
  422. is still needed for good scheduler performance.
  423. </p>
  424. <h3 id="minor_library_changes">Minor changes to the library</h3>
  425. <p>
  426. As always, there are various minor changes and updates to the library,
  427. made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a>
  428. in mind.
  429. </p>
  430. <dl id="bufio"><dt><a href="/pkg/bufio/">bufio</a></dt>
  431. <dd>
  432. <p>
  433. In previous releases of Go, if
  434. <a href="/pkg/bufio/#Reader"><code>Reader</code></a>'s
  435. <a href="/pkg/bufio/#Reader.Peek"><code>Peek</code></a> method
  436. were asked for more bytes than fit in the underlying buffer,
  437. it would return an empty slice and the error <code>ErrBufferFull</code>.
  438. Now it returns the entire underlying buffer, still accompanied by the error <code>ErrBufferFull</code>.
  439. </p>
  440. </dd>
  441. </dl>
  442. <dl id="bytes"><dt><a href="/pkg/bytes/">bytes</a></dt>
  443. <dd>
  444. <p>
  445. The new functions
  446. <a href="/pkg/bytes/#ContainsAny"><code>ContainsAny</code></a> and
  447. <a href="/pkg/bytes/#ContainsRune"><code>ContainsRune</code></a>
  448. have been added for symmetry with
  449. the <a href="/pkg/strings/"><code>strings</code></a> package.
  450. </p>
  451. <p>
  452. In previous releases of Go, if
  453. <a href="/pkg/bytes/#Reader"><code>Reader</code></a>'s
  454. <a href="/pkg/bytes/#Reader.Read"><code>Read</code></a> method
  455. were asked for zero bytes with no data remaining, it would
  456. return a count of 0 and no error.
  457. Now it returns a count of 0 and the error
  458. <a href="/pkg/io/#EOF"><code>io.EOF</code></a>.
  459. </p>
  460. <p>
  461. The
  462. <a href="/pkg/bytes/#Reader"><code>Reader</code></a> type has a new method
  463. <a href="/pkg/bytes/#Reader.Reset"><code>Reset</code></a> to allow reuse of a <code>Reader</code>.
  464. </p>
  465. </dd>
  466. </dl>
  467. <dl id="compress_flate"><dt><a href="/pkg/compress/flate/">compress/flate</a></dt>
  468. <dd>
  469. <p>
  470. There are many performance optimizations throughout the package.
  471. Decompression speed is improved by about 10%,
  472. while compression for <code>DefaultCompression</code> is twice as fast.
  473. </p>
  474. <p>
  475. In addition to those general improvements,
  476. the
  477. <code>BestSpeed</code>
  478. compressor has been replaced entirely and uses an
  479. algorithm similar to <a href="https://github.com/google/snappy">Snappy</a>,
  480. resulting in about a 2.5X speed increase,
  481. although the output can be 5-10% larger than with the previous algorithm.
  482. </p>
  483. <p>
  484. There is also a new compression level
  485. <code>HuffmanOnly</code>
  486. that applies Huffman but not Lempel-Ziv encoding.
  487. <a href="https://blog.klauspost.com/constant-time-gzipzip-compression/">Forgoing Lempel-Ziv encoding</a> means that
  488. <code>HuffmanOnly</code> runs about 3X faster than the new <code>BestSpeed</code>
  489. but at the cost of producing compressed outputs that are 20-40% larger than those
  490. generated by the new <code>BestSpeed</code>.
  491. </p>
  492. <p>
  493. It is important to note that both
  494. <code>BestSpeed</code> and <code>HuffmanOnly</code> produce a compressed output that is
  495. <a href="https://tools.ietf.org/html/rfc1951">RFC 1951</a> compliant.
  496. In other words, any valid DEFLATE decompressor will continue to be able to decompress these outputs.
  497. </p>
  498. <p>
  499. Lastly, there is a minor change to the decompressor's implementation of
  500. <a href="/pkg/io/#Reader"><code>io.Reader</code></a>. In previous versions,
  501. the decompressor deferred reporting
  502. <a href="/pkg/io/#EOF"><code>io.EOF</code></a> until exactly no more bytes could be read.
  503. Now, it reports
  504. <a href="/pkg/io/#EOF"><code>io.EOF</code></a> more eagerly when reading the last set of bytes.
  505. </p>
  506. </dd>
  507. </dl>
  508. <dl id="crypto_tls"><dt><a href="/pkg/crypto/tls/">crypto/tls</a></dt>
  509. <dd>
  510. <p>
  511. The TLS implementation sends the first few data packets on each connection
  512. using small record sizes, gradually increasing to the TLS maximum record size.
  513. This heuristic reduces the amount of data that must be received before
  514. the first packet can be decrypted, improving communication latency over
  515. low-bandwidth networks.
  516. Setting
  517. <a href="/pkg/crypto/tls/#Config"><code>Config</code></a>'s
  518. <code>DynamicRecordSizingDisabled</code> field to true
  519. forces the behavior of Go 1.6 and earlier, where packets are
  520. as large as possible from the start of the connection.
  521. </p>
  522. <p>
  523. The TLS client now has optional, limited support for server-initiated renegotiation,
  524. enabled by setting the
  525. <a href="/pkg/crypto/tls/#Config"><code>Config</code></a>'s
  526. <code>Renegotiation</code> field.
  527. This is needed for connecting to many Microsoft Azure servers.
  528. </p>
  529. <p>
  530. The errors returned by the package now consistently begin with a
  531. <code>tls:</code> prefix.
  532. In past releases, some errors used a <code>crypto/tls:</code> prefix,
  533. some used a <code>tls:</code> prefix, and some had no prefix at all.
  534. </p>
  535. <p>
  536. When generating self-signed certificates, the package no longer sets the
  537. “Authority Key Identifier” field by default.
  538. </p>
  539. </dd>
  540. </dl>
  541. <dl id="crypto_x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt>
  542. <dd>
  543. <p>
  544. The new function
  545. <a href="/pkg/crypto/x509/#SystemCertPool"><code>SystemCertPool</code></a>
  546. provides access to the entire system certificate pool if available.
  547. There is also a new associated error type
  548. <a href="/pkg/crypto/x509/#SystemRootsError"><code>SystemRootsError</code></a>.
  549. </p>
  550. </dd>
  551. </dl>
  552. <dl id="debug_dwarf"><dt><a href="/pkg/debug/dwarf/">debug/dwarf</a></dt>
  553. <dd>
  554. <p>
  555. The
  556. <a href="/pkg/debug/dwarf/#Reader"><code>Reader</code></a> type's new
  557. <a href="/pkg/debug/dwarf/#Reader.SeekPC"><code>SeekPC</code></a> method and the
  558. <a href="/pkg/debug/dwarf/#Data"><code>Data</code></a> type's new
  559. <a href="/pkg/debug/dwarf/#Ranges"><code>Ranges</code></a> method
  560. help to find the compilation unit to pass to a
  561. <a href="/pkg/debug/dwarf/#LineReader"><code>LineReader</code></a>
  562. and to identify the specific function for a given program counter.
  563. </p>
  564. </dd>
  565. </dl>
  566. <dl id="debug_elf"><dt><a href="/pkg/debug/elf/">debug/elf</a></dt>
  567. <dd>
  568. <p>
  569. The new
  570. <a href="/pkg/debug/elf/#R_390"><code>R_390</code></a> relocation type
  571. and its many predefined constants
  572. support the S390 port.
  573. </p>
  574. </dd>
  575. </dl>
  576. <dl id="encoding_asn1"><dt><a href="/pkg/encoding/asn1/">encoding/asn1</a></dt>
  577. <dd>
  578. <p>
  579. The ASN.1 decoder now rejects non-minimal integer encodings.
  580. This may cause the package to reject some invalid but formerly accepted ASN.1 data.
  581. </p>
  582. </dd>
  583. </dl>
  584. <dl id="encoding_json"><dt><a href="/pkg/encoding/json/">encoding/json</a></dt>
  585. <dd>
  586. <p>
  587. The
  588. <a href="/pkg/encoding/json/#Encoder"><code>Encoder</code></a>'s new
  589. <a href="/pkg/encoding/json/#Encoder.SetIndent"><code>SetIndent</code></a> method
  590. sets the indentation parameters for JSON encoding,
  591. like in the top-level
  592. <a href="/pkg/encoding/json/#Indent"><code>Indent</code></a> function.
  593. </p>
  594. <p>
  595. The
  596. <a href="/pkg/encoding/json/#Encoder"><code>Encoder</code></a>'s new
  597. <a href="/pkg/encoding/json/#Encoder.SetEscapeHTML"><code>SetEscapeHTML</code></a> method
  598. controls whether the
  599. <code>&#x26;</code>, <code>&#x3c;</code>, and <code>&#x3e;</code>
  600. characters in quoted strings should be escaped as
  601. <code>\u0026</code>, <code>\u003c</code>, and <code>\u003e</code>,
  602. respectively.
  603. As in previous releases, the encoder defaults to applying this escaping,
  604. to avoid certain problems that can arise when embedding JSON in HTML.
  605. </p>
  606. <p>
  607. In earlier versions of Go, this package only supported encoding and decoding
  608. maps using keys with string types.
  609. Go 1.7 adds support for maps using keys with integer types:
  610. the encoding uses a quoted decimal representation as the JSON key.
  611. Go 1.7 also adds support for encoding maps using non-string keys that implement
  612. the <code>MarshalText</code>
  613. (see
  614. <a href="/pkg/encoding/#TextMarshaler"><code>encoding.TextMarshaler</code></a>)
  615. method,
  616. as well as support for decoding maps using non-string keys that implement
  617. the <code>UnmarshalText</code>
  618. (see
  619. <a href="/pkg/encoding/#TextUnmarshaler"><code>encoding.TextUnmarshaler</code></a>)
  620. method.
  621. These methods are ignored for keys with string types in order to preserve
  622. the encoding and decoding used in earlier versions of Go.
  623. </p>
  624. <p>
  625. When encoding a slice of typed bytes,
  626. <a href="/pkg/encoding/json/#Marshal"><code>Marshal</code></a>
  627. now generates an array of elements encoded using
  628. that byte type's
  629. <code>MarshalJSON</code>
  630. or
  631. <code>MarshalText</code>
  632. method if present,
  633. only falling back to the default base64-encoded string data if neither method is available.
  634. Earlier versions of Go accept both the original base64-encoded string encoding
  635. and the array encoding (assuming the byte type also implements
  636. <code>UnmarshalJSON</code>
  637. or
  638. <code>UnmarshalText</code>
  639. as appropriate),
  640. so this change should be semantically backwards compatible with earlier versions of Go,
  641. even though it does change the chosen encoding.
  642. </p>
  643. </dd>
  644. </dl>
  645. <dl id="go_build"><dt><a href="/pkg/go/build/">go/build</a></dt>
  646. <dd>
  647. <p>
  648. To implement the go command's new support for binary-only packages
  649. and for Fortran code in cgo-based packages,
  650. the
  651. <a href="/pkg/go/build/#Package"><code>Package</code></a> type
  652. adds new fields <code>BinaryOnly</code>, <code>CgoFFLAGS</code>, and <code>FFiles</code>.
  653. </p>
  654. </dd>
  655. </dl>
  656. <dl id="go_doc"><dt><a href="/pkg/go/doc/">go/doc</a></dt>
  657. <dd>
  658. <p>
  659. To support the corresponding change in <code>go</code> <code>test</code> described above,
  660. <a href="/pkg/go/doc/#Example"><code>Example</code></a> struct adds a Unordered field
  661. indicating whether the example may generate its output lines in any order.
  662. </p>
  663. </dd>
  664. </dl>
  665. <dl id="io"><dt><a href="/pkg/io/">io</a></dt>
  666. <dd>
  667. <p>
  668. The package adds new constants
  669. <code>SeekStart</code>, <code>SeekCurrent</code>, and <code>SeekEnd</code>,
  670. for use with
  671. <a href="/pkg/io/#Seeker"><code>Seeker</code></a>
  672. implementations.
  673. These constants are preferred over <code>os.SEEK_SET</code>, <code>os.SEEK_CUR</code>, and <code>os.SEEK_END</code>,
  674. but the latter will be preserved for compatibility.
  675. </p>
  676. </dd>
  677. </dl>
  678. <dl id="math_big"><dt><a href="/pkg/math/big/">math/big</a></dt>
  679. <dd>
  680. <p>
  681. The
  682. <a href="/pkg/math/big/#Float"><code>Float</code></a> type adds
  683. <a href="/pkg/math/big/#Float.GobEncode"><code>GobEncode</code></a> and
  684. <a href="/pkg/math/big/#Float.GobDecode"><code>GobDecode</code></a> methods,
  685. so that values of type <code>Float</code> can now be encoded and decoded using the
  686. <a href="/pkg/encoding/gob/"><code>encoding/gob</code></a>
  687. package.
  688. </p>
  689. </dd>
  690. </dl>
  691. <dl id="math_rand"><dt><a href="/pkg/math/rand/">math/rand</a></dt>
  692. <dd>
  693. <p>
  694. The
  695. <a href="/pkg/math/rand/#Read"><code>Read</code></a> function and
  696. <a href="/pkg/math/rand/#Rand"><code>Rand</code></a>'s
  697. <a href="/pkg/math/rand/#Rand.Read"><code>Read</code></a> method
  698. now produce a pseudo-random stream of bytes that is consistent and not
  699. dependent on the size of the input buffer.
  700. </p>
  701. <p>
  702. The documentation clarifies that
  703. Rand's <a href="/pkg/math/rand/#Rand.Seed"><code>Seed</code></a>
  704. and <a href="/pkg/math/rand/#Rand.Read"><code>Read</code></a> methods
  705. are not safe to call concurrently, though the global
  706. functions <a href="/pkg/math/rand/#Seed"><code>Seed</code></a>
  707. and <a href="/pkg/math/rand/#Read"><code>Read</code></a> are (and have
  708. always been) safe.
  709. </p>
  710. </dd>
  711. </dl>
  712. <dl id="mime_multipart"><dt><a href="/pkg/mime/multipart/">mime/multipart</a></dt>
  713. <dd>
  714. <p>
  715. The
  716. <a href="/pkg/mime/multipart/#Writer"><code>Writer</code></a>
  717. implementation now emits each multipart section's header sorted by key.
  718. Previously, iteration over a map caused the section header to use a
  719. non-deterministic order.
  720. </p>
  721. </dd>
  722. </dl>
  723. <dl id="net"><dt><a href="/pkg/net/">net</a></dt>
  724. <dd>
  725. <p>
  726. As part of the introduction of <a href="#context">context</a>, the
  727. <a href="/pkg/net/#Dialer"><code>Dialer</code></a> type has a new method
  728. <a href="/pkg/net/#Dialer.DialContext"><code>DialContext</code></a>, like
  729. <a href="/pkg/net/#Dialer.Dial"><code>Dial</code></a> but adding the
  730. <a href="/pkg/context/#Context"><code>context.Context</code></a>
  731. for the dial operation.
  732. The context is intended to obsolete the <code>Dialer</code>'s
  733. <code>Cancel</code> and <code>Deadline</code> fields,
  734. but the implementation continues to respect them,
  735. for backwards compatibility.
  736. </p>
  737. <p>
  738. The
  739. <a href="/pkg/net/#IP"><code>IP</code></a> type's
  740. <a href="/pkg/net/#IP.String"><code>String</code></a> method has changed its result for invalid <code>IP</code> addresses.
  741. In past releases, if an <code>IP</code> byte slice had length other than 0, 4, or 16, <code>String</code>
  742. returned <code>"?"</code>.
  743. Go 1.7 adds the hexadecimal encoding of the bytes, as in <code>"?12ab"</code>.
  744. </p>
  745. <p>
  746. The pure Go <a href="/pkg/net/#hdr-Name_Resolution">name resolution</a>
  747. implementation now respects <code>nsswitch.conf</code>'s
  748. stated preference for the priority of DNS lookups compared to
  749. local file (that is, <code>/etc/hosts</code>) lookups.
  750. </p>
  751. </dd>
  752. </dl>
  753. <dl id="net_http"><dt><a href="/pkg/net/http/">net/http</a></dt>
  754. <dd>
  755. <p>
  756. <a href="/pkg/net/http/#ResponseWriter"><code>ResponseWriter</code></a>'s
  757. documentation now makes clear that beginning to write the response
  758. may prevent future reads on the request body.
  759. For maximal compatibility, implementations are encouraged to
  760. read the request body completely before writing any part of the response.
  761. </p>
  762. <p>
  763. As part of the introduction of <a href="#context">context</a>, the
  764. <a href="/pkg/net/http/#Request"><code>Request</code></a> has a new methods
  765. <a href="/pkg/net/http/#Request.Context"><code>Context</code></a>, to retrieve the associated context, and
  766. <a href="/pkg/net/http/#Request.WithContext"><code>WithContext</code></a>, to construct a copy of <code>Request</code>
  767. with a modified context.
  768. </p>
  769. <p>
  770. In the
  771. <a href="/pkg/net/http/#Server"><code>Server</code></a> implementation,
  772. <a href="/pkg/net/http/#Server.Serve"><code>Serve</code></a> records in the request context
  773. both the underlying <code>*Server</code> using the key <code>ServerContextKey</code>
  774. and the local address on which the request was received (a
  775. <a href="/pkg/net/#Addr"><code>Addr</code></a>) using the key <code>LocalAddrContextKey</code>.
  776. For example, the address on which a request received is
  777. <code>req.Context().Value(http.LocalAddrContextKey).(net.Addr)</code>.
  778. </p>
  779. <p>
  780. The server's <a href="/pkg/net/http/#Server.Serve"><code>Serve</code></a> method
  781. now only enables HTTP/2 support if the <code>Server.TLSConfig</code> field is <code>nil</code>
  782. or includes <code>"h2"</code> in its <code>TLSConfig.NextProtos</code>.
  783. </p>
  784. <p>
  785. The server implementation now
  786. pads response codes less than 100 to three digits
  787. as required by the protocol,
  788. so that <code>w.WriteHeader(5)</code> uses the HTTP response
  789. status <code>005</code>, not just <code>5</code>.
  790. </p>
  791. <p>
  792. The server implementation now correctly sends only one "Transfer-Encoding" header when "chunked"
  793. is set explicitly, following <a href="https://tools.ietf.org/html/rfc7230#section-3.3.1">RFC 7230</a>.
  794. </p>
  795. <p>
  796. The server implementation is now stricter about rejecting requests with invalid HTTP versions.
  797. Invalid requests claiming to be HTTP/0.x are now rejected (HTTP/0.9 was never fully supported),
  798. and plaintext HTTP/2 requests other than the "PRI * HTTP/2.0" upgrade request are now rejected as well.
  799. The server continues to handle encrypted HTTP/2 requests.
  800. </p>
  801. <p>
  802. In the server, a 200 status code is sent back by the timeout handler on an empty
  803. response body, instead of sending back 0 as the status code.
  804. </p>
  805. <p>
  806. In the client, the
  807. <a href="/pkg/net/http/#Transport"><code>Transport</code></a> implementation passes the request context
  808. to any dial operation connecting to the remote server.
  809. If a custom dialer is needed, the new <code>Transport</code> field
  810. <code>DialContext</code> is preferred over the existing <code>Dial</code> field,
  811. to allow the transport to supply a context.
  812. </p>
  813. <p>
  814. The
  815. <a href="/pkg/net/http/#Transport"><code>Transport</code></a> also adds fields
  816. <code>IdleConnTimeout</code>,
  817. <code>MaxIdleConns</code>,
  818. and
  819. <code>MaxResponseHeaderBytes</code>
  820. to help control client resources consumed
  821. by idle or chatty servers.
  822. </p>
  823. <p>
  824. A
  825. <a href="/pkg/net/http/#Client"><code>Client</code></a>'s configured <code>CheckRedirect</code> function can now
  826. return <code>ErrUseLastResponse</code> to indicate that the
  827. most recent redirect response should be returned as the
  828. result of the HTTP request.
  829. That response is now available to the <code>CheckRedirect</code> function
  830. as <code>req.Response</code>.
  831. </p>
  832. <p>
  833. Since Go 1, the default behavior of the HTTP client is
  834. to request server-side compression
  835. using the <code>Accept-Encoding</code> request header
  836. and then to decompress the response body transparently,
  837. and this behavior is adjustable using the
  838. <a href="/pkg/net/http/#Transport"><code>Transport</code></a>'s <code>DisableCompression</code> field.
  839. In Go 1.7, to aid the implementation of HTTP proxies, the
  840. <a href="/pkg/net/http/#Response"><code>Response</code></a>'s new
  841. <code>Uncompressed</code> field reports whether
  842. this transparent decompression took place.
  843. </p>
  844. <p>
  845. <a href="/pkg/net/http/#DetectContentType"><code>DetectContentType</code></a>
  846. adds support for a few new audio and video content types.
  847. </p>
  848. </dd>
  849. </dl>
  850. <dl id="net_http_cgi"><dt><a href="/pkg/net/http/cgi/">net/http/cgi</a></dt>
  851. <dd>
  852. <p>
  853. The
  854. <a href="/pkg/net/http/cgi/#Handler"><code>Handler</code></a>
  855. adds a new field
  856. <code>Stderr</code>
  857. that allows redirection of the child process's
  858. standard error away from the host process's
  859. standard error.
  860. </p>
  861. </dd>
  862. </dl>
  863. <dl id="net_http_httptest"><dt><a href="/pkg/net/http/httptest/">net/http/httptest</a></dt>
  864. <dd>
  865. <p>
  866. The new function
  867. <a href="/pkg/net/http/httptest/#NewRequest"><code>NewRequest</code></a>
  868. prepares a new
  869. <a href="/pkg/net/http/#Request"><code>http.Request</code></a>
  870. suitable for passing to an
  871. <a href="/pkg/net/http/#Handler"><code>http.Handler</code></a> during a test.
  872. </p>
  873. <p>
  874. The
  875. <a href="/pkg/net/http/httptest/#ResponseRecorder"><code>ResponseRecorder</code></a>'s new
  876. <a href="/pkg/net/http/httptest/#ResponseRecorder.Result"><code>Result</code></a> method
  877. returns the recorded
  878. <a href="/pkg/net/http/#Response"><code>http.Response</code></a>.
  879. Tests that need to check the response's headers or trailers
  880. should call <code>Result</code> and inspect the response fields
  881. instead of accessing
  882. <code>ResponseRecorder</code>'s <code>HeaderMap</code> directly.
  883. </p>
  884. </dd>
  885. </dl>
  886. <dl id="net_http_httputil"><dt><a href="/pkg/net/http/httputil/">net/http/httputil</a></dt>
  887. <dd>
  888. <p>
  889. The
  890. <a href="/pkg/net/http/httputil/#ReverseProxy"><code>ReverseProxy</code></a> implementation now responds with “502 Bad Gateway”
  891. when it cannot reach a back end; in earlier releases it responded with “500 Internal Server Error.”
  892. </p>
  893. <p>
  894. Both
  895. <a href="/pkg/net/http/httputil/#ClientConn"><code>ClientConn</code></a> and
  896. <a href="/pkg/net/http/httputil/#ServerConn"><code>ServerConn</code></a> have been documented as deprecated.
  897. They are low-level, old, and unused by Go's current HTTP stack
  898. and will no longer be updated.
  899. Programs should use
  900. <a href="/pkg/net/http/#Client"><code>http.Client</code></a>,
  901. <a href="/pkg/net/http/#Transport"><code>http.Transport</code></a>,
  902. and
  903. <a href="/pkg/net/http/#Server"><code>http.Server</code></a>
  904. instead.
  905. </p>
  906. </dd>
  907. </dl>
  908. <dl id="net_http_pprof"><dt><a href="/pkg/net/http/pprof/">net/http/pprof</a></dt>
  909. <dd>
  910. <p>
  911. The runtime trace HTTP handler, installed to handle the path <code>/debug/pprof/trace</code>,
  912. now accepts a fractional number in its <code>seconds</code> query parameter,
  913. allowing collection of traces for intervals smaller than one second.
  914. This is especially useful on busy servers.
  915. </p>
  916. </dd>
  917. </dl>
  918. <dl><dt><a href="/pkg/net/mail/">net/mail</a></dt>
  919. <dd>
  920. <p>
  921. The address parser now allows unescaped UTF-8 text in addresses
  922. following <a href="https://tools.ietf.org/html/rfc6532">RFC 6532</a>,
  923. but it does not apply any normalization to the result.
  924. For compatibility with older mail parsers,
  925. the address encoder, namely
  926. <a href="/pkg/net/mail/#Address"><code>Address</code></a>'s
  927. <a href="/pkg/net/mail/#Address.String"><code>String</code></a> method,
  928. continues to escape all UTF-8 text following <a href="https://tools.ietf.org/html/rfc5322">RFC 5322</a>.
  929. </p>
  930. <p>
  931. The <a href="/pkg/net/mail/#ParseAddress"><code>ParseAddress</code></a>
  932. function and
  933. the <a href="/pkg/net/mail/#AddressParser.Parse"><code>AddressParser.Parse</code></a>
  934. method are stricter.
  935. They used to ignore any characters following an e-mail address, but
  936. will now return an error for anything other than whitespace.
  937. </p>
  938. </dd>
  939. </dl>
  940. <dl id="net_url"><dt><a href="/pkg/net/url/">net/url</a></dt>
  941. <dd>
  942. <p>
  943. The
  944. <a href="/pkg/net/url/#URL"><code>URL</code></a>'s
  945. new <code>ForceQuery</code> field
  946. records whether the URL must have a query string,
  947. in order to distinguish URLs without query strings (like <code>/search</code>)
  948. from URLs with empty query strings (like <code>/search?</code>).
  949. </p>
  950. </dd>
  951. </dl>
  952. <dl id="os"><dt><a href="/pkg/os/">os</a></dt>
  953. <dd>
  954. <p>
  955. <a href="/pkg/os/#IsExist"><code>IsExist</code></a> now returns true for <code>syscall.ENOTEMPTY</code>,
  956. on systems where that error exists.
  957. </p>
  958. <p>
  959. On Windows,
  960. <a href="/pkg/os/#Remove"><code>Remove</code></a> now removes read-only files when possible,
  961. making the implementation behave as on
  962. non-Windows systems.
  963. </p>
  964. </dd>
  965. </dl>
  966. <dl id="os_exec"><dt><a href="/pkg/os/exec/">os/exec</a></dt>
  967. <dd>
  968. <p>
  969. As part of the introduction of <a href="#context">context</a>,
  970. the new constructor
  971. <a href="/pkg/os/exec/#CommandContext"><code>CommandContext</code></a>
  972. is like
  973. <a href="/pkg/os/exec/#Command"><code>Command</code></a> but includes a context that can be used to cancel the command execution.
  974. </p>
  975. </dd>
  976. </dl>
  977. <dl id="os_user"><dt><a href="/pkg/os/user/">os/user</a></dt>
  978. <dd>
  979. <p>
  980. The
  981. <a href="/pkg/os/user/#Current"><code>Current</code></a>
  982. function is now implemented even when cgo is not available.
  983. </p>
  984. <p>
  985. The new
  986. <a href="/pkg/os/user/#Group"><code>Group</code></a> type,
  987. along with the lookup functions
  988. <a href="/pkg/os/user/#LookupGroup"><code>LookupGroup</code></a> and
  989. <a href="/pkg/os/user/#LookupGroupId"><code>LookupGroupId</code></a>
  990. and the new field <code>GroupIds</code> in the <code>User</code> struct,
  991. provides access to system-specific user group information.
  992. </p>
  993. </dd>
  994. </dl>
  995. <dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt>
  996. <dd>
  997. <p>
  998. Although
  999. <a href="/pkg/reflect/#Value"><code>Value</code></a>'s
  1000. <a href="/pkg/reflect/#Value.Field"><code>Field</code></a> method has always been documented to panic
  1001. if the given field number <code>i</code> is out of range, it has instead
  1002. silently returned a zero
  1003. <a href="/pkg/reflect/#Value"><code>Value</code></a>.
  1004. Go 1.7 changes the method to behave as documented.
  1005. </p>
  1006. <p>
  1007. The new
  1008. <a href="/pkg/reflect/#StructOf"><code>StructOf</code></a>
  1009. function constructs a struct type at run time.
  1010. It completes the set of type constructors, joining
  1011. <a href="/pkg/reflect/#ArrayOf"><code>ArrayOf</code></a>,
  1012. <a href="/pkg/reflect/#ChanOf"><code>ChanOf</code></a>,
  1013. <a href="/pkg/reflect/#FuncOf"><code>FuncOf</code></a>,
  1014. <a href="/pkg/reflect/#MapOf"><code>MapOf</code></a>,
  1015. <a href="/pkg/reflect/#PtrTo"><code>PtrTo</code></a>,
  1016. and
  1017. <a href="/pkg/reflect/#SliceOf"><code>SliceOf</code></a>.
  1018. </p>
  1019. <p>
  1020. <a href="/pkg/reflect/#StructTag"><code>StructTag</code></a>'s
  1021. new method
  1022. <a href="/pkg/reflect/#StructTag.Lookup"><code>Lookup</code></a>
  1023. is like
  1024. <a href="/pkg/reflect/#StructTag.Get"><code>Get</code></a>
  1025. but distinguishes the tag not containing the given key
  1026. from the tag associating an empty string with the given key.
  1027. </p>
  1028. <p>
  1029. The
  1030. <a href="/pkg/reflect/#Type.Method"><code>Method</code></a> and
  1031. <a href="/pkg/reflect/#Type.NumMethod"><code>NumMethod</code></a>
  1032. methods of
  1033. <a href="/pkg/reflect/#Type"><code>Type</code></a> and
  1034. <a href="/pkg/reflect/#Value"><code>Value</code></a>
  1035. no longer return or count unexported methods.
  1036. </p>
  1037. </dd>
  1038. </dl>
  1039. <dl id="strings"><dt><a href="/pkg/strings/">strings</a></dt>
  1040. <dd>
  1041. <p>
  1042. In previous releases of Go, if
  1043. <a href="/pkg/strings/#Reader"><code>Reader</code></a>'s
  1044. <a href="/pkg/strings/#Reader.Read"><code>Read</code></a> method
  1045. were asked for zero bytes with no data remaining, it would
  1046. return a count of 0 and no error.
  1047. Now it returns a count of 0 and the error
  1048. <a href="/pkg/io/#EOF"><code>io.EOF</code></a>.
  1049. </p>
  1050. <p>
  1051. The
  1052. <a href="/pkg/strings/#Reader"><code>Reader</code></a> type has a new method
  1053. <a href="/pkg/strings/#Reader.Reset"><code>Reset</code></a> to allow reuse of a <code>Reader</code>.
  1054. </p>
  1055. </dd>
  1056. </dl>
  1057. <dl id="time"><dt><a href="/pkg/time/">time</a></dt>
  1058. <dd>
  1059. <p>
  1060. <a href="/pkg/time/#Duration"><code>Duration</code></a>'s
  1061. time.Duration.String method now reports the zero duration as <code>"0s"</code>, not <code>"0"</code>.
  1062. <a href="/pkg/time/#ParseDuration"><code>ParseDuration</code></a> continues to accept both forms.
  1063. </p>
  1064. <p>
  1065. The method call <code>time.Local.String()</code> now returns <code>"Local"</code> on all systems;
  1066. in earlier releases, it returned an empty string on Windows.
  1067. </p>
  1068. <p>
  1069. The time zone database in
  1070. <code>$GOROOT/lib/time</code> has been updated
  1071. to IANA release 2016d.
  1072. This fallback database is only used when the system time zone database
  1073. cannot be found, for example on Windows.
  1074. The Windows time zone abbreviation list has also been updated.
  1075. </p>
  1076. </dd>
  1077. </dl>
  1078. <dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt>
  1079. <dd>
  1080. <p>
  1081. On Linux, the
  1082. <a href="/pkg/syscall/#SysProcAttr"><code>SysProcAttr</code></a> struct
  1083. (as used in
  1084. <a href="/pkg/os/exec/#Cmd"><code>os/exec.Cmd</code></a>'s <code>SysProcAttr</code> field)
  1085. has a new <code>Unshareflags</code> field.
  1086. If the field is nonzero, the child process created by
  1087. <a href="/pkg/syscall/#ForkExec"><code>ForkExec</code></a>
  1088. (as used in <code>exec.Cmd</code>'s <code>Run</code> method)
  1089. will call the
  1090. <a href="http://man7.org/linux/man-pages/man2/unshare.2.html"><i>unshare</i>(2)</a>
  1091. system call before executing the new program.
  1092. </p>
  1093. </dd>
  1094. </dl>
  1095. <dl id="unicode"><dt><a href="/pkg/unicode/">unicode</a></dt>
  1096. <dd>
  1097. <p>
  1098. The <a href="/pkg/unicode/"><code>unicode</code></a> package and associated
  1099. support throughout the system has been upgraded from version 8.0 to
  1100. <a href="http://www.unicode.org/versions/Unicode9.0.0/">Unicode 9.0</a>.
  1101. </p>
  1102. </dd>
  1103. </dl>