go1.9.html 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985
  1. <!--{
  2. "Title": "Go 1.9 Release Notes",
  3. "Path": "/doc/go1.9",
  4. "Template": true
  5. }-->
  6. <!--
  7. NOTE: In this document and others in this directory, the convention is to
  8. set fixed-width phrases with non-fixed-width spaces, as in
  9. <code>hello</code> <code>world</code>.
  10. Do not send CLs removing the interior tags from such phrases.
  11. -->
  12. <style>
  13. ul li { margin: 0.5em 0; }
  14. </style>
  15. <h2 id="introduction">DRAFT RELEASE NOTES - Introduction to Go 1.9</h2>
  16. <p><strong>
  17. Go 1.9 is not yet released. These are work-in-progress
  18. release notes. Go 1.9 is expected to be released in August 2017.
  19. </strong></p>
  20. <p>
  21. The latest Go release, version 1.9, arrives six months
  22. after <a href="go1.8">Go 1.8</a> and is the tenth release in
  23. the <a href="https://golang.org/doc/devel/release.html">Go 1.x
  24. series</a>.
  25. There are two <a href="#language">changes to the language</a>:
  26. adding support for type aliases and defining when implementations
  27. may fuse floating point operations.
  28. Most of the changes are in the implementation of the toolchain,
  29. runtime, and libraries.
  30. As always, the release maintains the Go 1
  31. <a href="/doc/go1compat.html">promise of compatibility</a>.
  32. We expect almost all Go programs to continue to compile and run as
  33. before.
  34. </p>
  35. <p>
  36. The release
  37. adds <a href="#monotonic-time">transparent monotonic time support</a>,
  38. <a href="#parallel-compile">parallelizes compilation of functions</a> within a package,
  39. better supports <a href="#test-helper">test helper functions</a>,
  40. includes a new <a href="#math-bits">bit manipulation package</a>,
  41. and has a new <a href="#sync-map">concurrent map type</a>.
  42. </p>
  43. <h2 id="language">Changes to the language</h2>
  44. <p>
  45. There are two changes to the language.
  46. </p>
  47. <p>
  48. Go now supports type aliases to support gradual code repair while
  49. moving a type between packages.
  50. The <a href="https://golang.org/design/18130-type-alias">type alias
  51. design document</a>
  52. and <a href="https://talks.golang.org/2016/refactor.article">an
  53. article on refactoring</a> cover the problem in detail.
  54. In short, a type alias declaration has the form:
  55. </p>
  56. <pre>
  57. type T1 = T2
  58. </pre>
  59. <p>
  60. This declaration introduces an alias name <code>T1</code>—an
  61. alternate spelling—for the type denoted by <code>T2</code>; that is,
  62. both <code>T1</code> and <code>T2</code> denote the same type.
  63. </p>
  64. <p> <!-- CL 40391 -->
  65. A smaller language change is that the
  66. <a href="/ref/spec#Floating_point_operators">language specification
  67. now states</a> when implementations are allowed to fuse floating
  68. point operations together, such as by using an architecture's "fused
  69. multiply and add" (FMA) instruction to compute <code>x*y</code>&nbsp;<code>+</code>&nbsp;<code>z</code>
  70. without rounding the intermediate result <code>x*y</code>.
  71. To force the intermediate rounding, write <code>float64(x*y)</code>&nbsp;<code>+</code>&nbsp;<code>z</code>.
  72. </p>
  73. <h2 id="ports">Ports</h2>
  74. <p>
  75. There are no new supported operating systems or processor
  76. architectures in this release.
  77. </p>
  78. <h3 id="power8">ppc64x requires POWER8</h3>
  79. <p> <!-- CL 36725, CL 36832 -->
  80. Both <code>GOARCH=ppc64</code> and <code>GOARCH=ppc64le</code> now
  81. require at least POWER8 support. In previous releases,
  82. only <code>GOARCH=ppc64le</code> required POWER8 and the big
  83. endian <code>ppc64</code> architecture supported older
  84. hardware.
  85. <p>
  86. <h3 id="freebsd">FreeBSD</h3>
  87. <p>
  88. Go 1.9 is the last release that will run on FreeBSD 9.3,
  89. which is already
  90. <a href="https://www.freebsd.org/security/unsupported.html">unsupported by FreeBSD</a>.
  91. Go 1.10 will require FreeBSD 10.3+.
  92. </p>
  93. <h3 id="openbsd">OpenBSD 6.0</h3>
  94. <p> <!-- CL 40331 -->
  95. Go 1.9 now enables PT_TLS generation for cgo binaries and thus
  96. requires OpenBSD 6.0 or newer. Go 1.9 no longer supports
  97. OpenBSD 5.9.
  98. <p>
  99. <h3 id="known_issues">Known Issues</h3>
  100. <p>
  101. There are some instabilities on FreeBSD that are known but not understood.
  102. These can lead to program crashes in rare cases.
  103. See <a href="https://golang.org/issue/15658">issue 15658</a>.
  104. Any help in solving this FreeBSD-specific issue would be appreciated.
  105. </p>
  106. <p>
  107. Go stopped running NetBSD builders during the Go 1.9 development
  108. cycle due to NetBSD kernel crashes, up to and including NetBSD 7.1.
  109. As Go 1.9 is being released, NetBSD 7.1.1 is being released with a fix.
  110. However, at this time we have no NetBSD builders passing our test suite.
  111. Any help investigating the
  112. <a href="https://github.com/golang/go/labels/OS-NetBSD">various NetBSD issues</a>
  113. would be appreciated.
  114. </p>
  115. <h2 id="tools">Tools</h2>
  116. <h3 id="parallel-compile">Parallel Compilation</h3>
  117. <p>
  118. The Go compiler now supports compiling a package's functions in parallel, taking
  119. advantage of multiple cores. This is in addition to the <code>go</code> command's
  120. existing support for parallel compilation of separate packages.
  121. Parallel compilation is on by default, but it can be disabled by setting the
  122. environment variable <code>GO19CONCURRENTCOMPILATION</code> to <code>0</code>.
  123. </p>
  124. <h3 id="vendor-dotdotdot">Vendor matching with ./...</h3>
  125. <p><!-- CL 38745 -->
  126. By popular request, <code>./...</code> no longer matches packages
  127. in <code>vendor</code> directories in tools accepting package names,
  128. such as <code>go</code> <code>test</code>. To match vendor
  129. directories, write <code>./vendor/...</code>.
  130. </p>
  131. <h3 id="compiler">Compiler Toolchain</h3>
  132. <p><!-- CL 37441 -->
  133. Complex division is now C99-compatible. This has always been the
  134. case in gccgo and is now fixed in the gc toolchain.
  135. </p>
  136. <p> <!-- CL 36983 -->
  137. The linker will now generate DWARF information for cgo executables on Windows.
  138. </p>
  139. <p> <!-- CL 44210, CL 40095 -->
  140. The compiler now includes lexical scopes in the generated DWARF if the
  141. <code>-N -l</code> flags are provided, allowing
  142. debuggers to hide variables that are not in scope. The <code>.debug_info</code>
  143. section is now DWARF version 4.
  144. </p>
  145. <p> <!-- CL 43855 -->
  146. The values of <code>GOARM</code> and <code>GO386</code> now affect a
  147. compiled package's build ID, as used by the <code>go</code> tool's
  148. dependency caching.
  149. </p>
  150. <h3 id="asm">Assembler</h3>
  151. <p> <!-- CL 42028 -->
  152. The four-operand ARM <code>MULA</code> instruction is now assembled correctly,
  153. with the addend register as the third argument and the result
  154. register as the fourth and final argument.
  155. In previous releases, the two meanings were reversed.
  156. The three-operand form, in which the fourth argument is implicitly
  157. the same as the third, is unaffected.
  158. Code using four-operand <code>MULA</code> instructions
  159. will need to be updated, but we believe this form is very rarely used.
  160. <code>MULAWT</code> and <code>MULAWB</code> were already
  161. using the correct order in all forms and are unchanged.
  162. </p>
  163. <p> <!-- CL 42990 -->
  164. The assembler now supports <code>ADDSUBPS/PD</code>, completing the
  165. two missing x86 SSE3 instructions.
  166. </p>
  167. <h3 id="go-doc">Doc</h3>
  168. <p><!-- CL 36031 -->
  169. Long lists of arguments are now truncated. This improves the readability
  170. of <code>go</code> <code>doc</code> on some generated code.
  171. </p>
  172. <p><!-- CL 38438 -->
  173. Viewing documentation on struct fields is now supported.
  174. For example, <code>go</code> <code>doc</code> <code>http.Client.Jar</code>.
  175. </p>
  176. <h3 id="go-env-json">Env</h3>
  177. <p> <!-- CL 38757 -->
  178. The new <code>go</code> <code>env</code> <code>-json</code> flag
  179. enables JSON output, instead of the default OS-specific output
  180. format.
  181. </p>
  182. <h3 id="go-test-list">Test</h3>
  183. <p> <!-- CL 41195 -->
  184. The <a href="/cmd/go/#hdr-Description_of_testing_flags"><code>go</code> <code>test</code></a>
  185. command accepts a new <code>-list</code> flag, which takes a regular
  186. expression as an argument and prints to stdout the name of any
  187. tests, benchmarks, or examples that match it, without running them.
  188. </p>
  189. <h3 id="go-tool-pprof">Pprof</h3>
  190. <p> <!-- CL 34192 -->
  191. Profiles produced by the <code>runtime/pprof</code> package now
  192. include symbol information, so they can be viewed
  193. in <code>go</code> <code>tool</code> <code>pprof</code>
  194. without the binary that produced the profile.
  195. </p>
  196. <p> <!-- CL 38343 -->
  197. The <code>go</code> <code>tool</code> <code>pprof</code> command now
  198. uses the HTTP proxy information defined in the environment, using
  199. <a href="/pkg/net/http/#ProxyFromEnvironment"><code>http.ProxyFromEnvironment</code></a>.
  200. </p>
  201. <h3 id="vet">Vet</h3>
  202. <!-- CL 40112 -->
  203. <p>
  204. The <a href="/cmd/vet/"><code>vet</code> command</a>
  205. has been better integrated into the
  206. <a href="/cmd/go/"><code>go</code> tool</a>,
  207. so <code>go</code> <code>vet</code> now supports all standard build
  208. flags while <code>vet</code>'s own flags are now available
  209. from <code>go</code> <code>vet</code> as well as
  210. from <code>go</code> <code>tool</code> <code>vet</code>.
  211. </p>
  212. <h3 id="gccgo">Gccgo</h3>
  213. <p>
  214. Due to the alignment of Go's semiannual release schedule with GCC's
  215. annual release schedule,
  216. GCC release 7 contains the Go 1.8.3 version of gccgo.
  217. We expect that the next release, GCC 8, will contain the Go 1.10
  218. version of gccgo.
  219. </p>
  220. <h2 id="runtime">Runtime</h2>
  221. <h3 id="callersframes">Call stacks with inlined frames</h3>
  222. <p>
  223. Users of
  224. <a href="/pkg/runtime#Callers"><code>runtime.Callers</code></a>
  225. should avoid directly inspecting the resulting PC slice and instead use
  226. <a href="/pkg/runtime#CallersFrames"><code>runtime.CallersFrames</code></a>
  227. to get a complete view of the call stack, or
  228. <a href="/pkg/runtime#Caller"><code>runtime.Caller</code></a>
  229. to get information about a single caller.
  230. This is because an individual element of the PC slice cannot account
  231. for inlined frames or other nuances of the call stack.
  232. </p>
  233. <p>
  234. Specifically, code that directly iterates over the PC slice and uses
  235. functions such as
  236. <a href="/pkg/runtime#FuncForPC"><code>runtime.FuncForPC</code></a>
  237. to resolve each PC individually will miss inlined frames.
  238. To get a complete view of the stack, such code should instead use
  239. <code>CallersFrames</code>.
  240. Likewise, code should not assume that the length returned by
  241. <code>Callers</code> is any indication of the call depth.
  242. It should instead count the number of frames returned by
  243. <code>CallersFrames</code>.
  244. </p>
  245. <p>
  246. Code that queries a single caller at a specific depth should use
  247. <code>Caller</code> rather than passing a slice of length 1 to
  248. <code>Callers</code>.
  249. </p>
  250. <p>
  251. <a href="/pkg/runtime#CallersFrames"><code>runtime.CallersFrames</code></a>
  252. has been available since Go 1.7, so code can be updated prior to
  253. upgrading to Go 1.9.
  254. </p>
  255. <h2 id="performance">Performance</h2>
  256. <p>
  257. As always, the changes are so general and varied that precise
  258. statements about performance are difficult to make. Most programs
  259. should run a bit faster, due to speedups in the garbage collector,
  260. better generated code, and optimizations in the core library.
  261. </p>
  262. <h3 id="gc">Garbage Collector</h3>
  263. <p> <!-- CL 37520 -->
  264. Library functions that used to trigger stop-the-world garbage
  265. collection now trigger concurrent garbage collection.
  266. Specifically, <a href="/pkg/runtime/#GC"><code>runtime.GC</code></a>,
  267. <a href="/pkg/runtime/debug/#SetGCPercent"><code>debug.SetGCPercent</code></a>,
  268. and
  269. <a href="/pkg/runtime/debug/#FreeOSMemory"><code>debug.FreeOSMemory</code></a>,
  270. now trigger concurrent garbage collection, blocking only the calling
  271. goroutine until the garbage collection is done.
  272. </p>
  273. <p> <!-- CL 34103, CL 39835 -->
  274. The
  275. <a href="/pkg/runtime/debug/#SetGCPercent"><code>debug.SetGCPercent</code></a>
  276. function only triggers a garbage collection if one is immediately
  277. necessary because of the new GOGC value.
  278. This makes it possible to adjust GOGC on-the-fly.
  279. </p>
  280. <p> <!-- CL 38732 -->
  281. Large object allocation performance is significantly improved in
  282. applications using large (&gt;50GB) heaps containing many large
  283. objects.
  284. </p>
  285. <p> <!-- CL 34937 -->
  286. The <a href="/pkg/runtime/#ReadMemStats"><code>runtime.ReadMemStats</code></a>
  287. function now takes less than 100µs even for very large heaps.
  288. </p>
  289. <h2 id="library">Core library</h2>
  290. <h3 id="monotonic-time">Transparent Monotonic Time support</h3>
  291. <p> <!-- CL 36255 -->
  292. The <a href="/pkg/time/"><code>time</code></a> package now transparently
  293. tracks monotonic time in each <a href="/pkg/time/#Time"><code>Time</code></a>
  294. value, making computing durations between two <code>Time</code> values
  295. a safe operation in the presence of wall clock adjustments.
  296. See the <a href="/pkg/time/#hdr-Monotonic_Clocks">package docs</a> and
  297. <a href="https://golang.org/design/12914-monotonic">design document</a>
  298. for details.
  299. </p>
  300. <h3 id="math-bits">New bit manipulation package</h3>
  301. <p> <!-- CL 36315 -->
  302. Go 1.9 includes a new package,
  303. <a href="/pkg/math/bits/"><code>math/bits</code></a>, with optimized
  304. implementations for manipulating bits. On most architectures,
  305. functions in this package are additionally recognized by the
  306. compiler and treated as intrinsics for additional performance.
  307. </p>
  308. <h3 id="test-helper">Test Helper Functions</h3>
  309. <p> <!-- CL 38796 -->
  310. The
  311. new <a href="/pkg/testing/#T.Helper"><code>(*T).Helper</code></a>
  312. and <a href="/pkg/testing/#B.Helper"><code>(*B).Helper</code></a>
  313. methods mark the calling function as a test helper function. When
  314. printing file and line information, that function will be skipped.
  315. This permits writing test helper functions while still having useful
  316. line numbers for users.
  317. </p>
  318. <h3 id="sync-map">Concurrent Map</h3>
  319. <p> <!-- CL 36617 -->
  320. The new <a href="/pkg/sync/#Map"><code>Map</code></a> type
  321. in the <a href="/pkg/sync/"><code>sync</code></a> package
  322. is a concurrent map with amortized-constant-time loads, stores, and
  323. deletes. It is safe for multiple goroutines to call a <code>Map</code>'s methods
  324. concurrently.
  325. </p>
  326. <h3 id="pprof-labels">Profiler Labels</h3>
  327. <p><!-- CL 34198 -->
  328. The <a href="/pkg/runtime/pprof"><code>runtime/pprof</code> package</a>
  329. now supports adding labels to <code>pprof</code> profiler records.
  330. Labels form a key-value map that is used to distinguish calls of the
  331. same function in different contexts when looking at profiles
  332. with the <a href="/cmd/pprof/"><code>pprof</code> command</a>.
  333. The <code>pprof</code> package's
  334. new <a href="/pkg/runtime/pprof/#Do"><code>Do</code> function</a>
  335. runs code associated with some provided labels. Other new functions
  336. in the package help work with labels.
  337. </p>
  338. </dl><!-- runtime/pprof -->
  339. <h3 id="minor_library_changes">Minor changes to the library</h3>
  340. <p>
  341. As always, there are various minor changes and updates to the library,
  342. made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a>
  343. in mind.
  344. </p>
  345. <dl id="archive/zip"><dt><a href="/pkg/archive/zip/">archive/zip</a></dt>
  346. <dd>
  347. <p><!-- CL 39570 -->
  348. The
  349. ZIP <a href="/pkg/archive/zip/#Writer"><code>Writer</code></a>
  350. now sets the UTF-8 bit in
  351. the <a href="/pkg/archive/zip/#FileHeader.Flags"><code>FileHeader.Flags</code></a>
  352. when appropriate.
  353. </p>
  354. </dl><!-- archive/zip -->
  355. <dl id="crypto/rand"><dt><a href="/pkg/crypto/rand/">crypto/rand</a></dt>
  356. <dd>
  357. <p><!-- CL 43852 -->
  358. On Linux, Go now calls the <code>getrandom</code> system call
  359. without the <code>GRND_NONBLOCK</code> flag; it will now block
  360. until the kernel has sufficient randomness. On kernels predating
  361. the <code>getrandom</code> system call, Go continues to read
  362. from <code>/dev/urandom</code>.
  363. </p>
  364. </dl><!-- crypto/rand -->
  365. <dl id="crypto/x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt>
  366. <dd>
  367. <p><!-- CL 36093 -->
  368. On Unix systems the environment
  369. variables <code>SSL_CERT_FILE</code>
  370. and <code>SSL_CERT_DIR</code> can now be used to override the
  371. system default locations for the SSL certificate file and SSL
  372. certificate files directory, respectively.
  373. </p>
  374. <p>The FreeBSD file <code>/usr/local/etc/ssl/cert.pem</code> is
  375. now included in the certificate search path.
  376. </p>
  377. <p><!-- CL 36900 -->
  378. The package now supports excluded domains in name constraints.
  379. In addition to enforcing such constraints,
  380. <a href="/pkg/crypto/x509/#CreateCertificate"><code>CreateCertificate</code></a>
  381. will create certificates with excluded name constraints
  382. if the provided template certificate has the new
  383. field
  384. <a href="/pkg/crypto/x509/#Certificate.ExcludedDNSDomains"><code>ExcludedDNSDomains</code></a>
  385. populated.
  386. </p>
  387. </dl><!-- crypto/x509 -->
  388. <dl id="database/sql"><dt><a href="/pkg/database/sql/">database/sql</a></dt>
  389. <dd>
  390. <p><!-- CL 35476 -->
  391. The package will now use a cached <a href="/pkg/database/sql/#Stmt"><code>Stmt</code></a> if
  392. available in <a href="/pkg/database/sql/#Tx.Stmt"><code>Tx.Stmt</code></a>.
  393. This prevents statements from being re-prepared each time
  394. <a href="/pkg/database/sql/#Tx.Stmt"><code>Tx.Stmt</code></a> is called.
  395. </p>
  396. <p><!-- CL 38533 -->
  397. The package now allows drivers to implement their own argument checkers by implementing
  398. <a href="/pkg/database/sql/driver/#NamedValueChecker"><code>driver.NamedValueChecker</code></a>.
  399. This also allows drivers to support <code>OUTPUT</code> and <code>INOUT</code> parameter types.
  400. <a href="/pkg/database/sql/#Out"><code>Out</code></a> should be used to return output parameters
  401. when supported by the driver.
  402. </p>
  403. <p><!-- CL 39031 -->
  404. <a href="/pkg/database/sql/#Rows.Scan"><code>Rows.Scan</code></a> can now scan user-defined string types.
  405. Previously the package supported scanning into numeric types like <code>type</code> <code>Int</code> <code>int64</code>. It now also supports
  406. scanning into string types like <code>type</code> <code>String</code> <code>string</code>.
  407. </p>
  408. <p><!-- CL 40694 -->
  409. The new <a href="/pkg/database/sql/#DB.Conn"><code>DB.Conn</code></a> method returns the new
  410. <a href="/pkg/database/sql/#Conn"><code>Conn</code></a> type representing an
  411. exclusive connection to the database from the connection pool. All queries run on
  412. a <a href="/pkg/database/sql/#Conn"><code>Conn</code></a> will use the same underlying
  413. connection until <a href="/pkg/database/sql/#Conn.Close"><code>Conn.Close</code></a> is called
  414. to return the connection to the connection pool.
  415. </p>
  416. </dl><!-- database/sql -->
  417. <dl id="encoding/asn1"><dt><a href="/pkg/encoding/asn1/">encoding/asn1</a></dt>
  418. <dd>
  419. <p><!-- CL 38660 -->
  420. The new
  421. <a href="/pkg/encoding/asn1/#NullBytes"><code>NullBytes</code></a>
  422. and
  423. <a href="/pkg/encoding/asn1/#NullRawValue"><code>NullRawValue</code></a>
  424. represent the ASN.1 NULL type.
  425. </p>
  426. </dl><!-- encoding/asn1 -->
  427. <dl id="encoding/base32"><dt><a href="/pkg/encoding/base32/">encoding/base32</a></dt>
  428. <dd>
  429. <p><!-- CL 38634 -->
  430. The new <a href="/pkg/encoding/base32/#Encoding.WithPadding">Encoding.WithPadding</a>
  431. method adds support for custom padding characters and disabling padding.
  432. </p>
  433. </dl><!-- encoding/base32 -->
  434. <dl id="encoding/csv"><dt><a href="/pkg/encoding/csv/">encoding/csv</a></dt>
  435. <dd>
  436. <p><!-- CL 41730 -->
  437. The new field
  438. <a href="/pkg/encoding/csv/#Reader.ReuseRecord"><code>Reader.ReuseRecord</code></a>
  439. controls whether calls to
  440. <a href="/pkg/encoding/csv/#Reader.Read"><code>Read</code></a>
  441. may return a slice sharing the backing array of the previous
  442. call's returned slice for improved performance.
  443. </p>
  444. </dl><!-- encoding/csv -->
  445. <dl id="fmt"><dt><a href="/pkg/fmt/">fmt</a></dt>
  446. <dd>
  447. <p><!-- CL 37051 -->
  448. The sharp flag ('<code>#</code>') is now supported when printing
  449. floating point and complex numbers. It will always print a
  450. decimal point
  451. for <code>%e</code>, <code>%E</code>, <code>%f</code>, <code>%F</code>, <code>%g</code>
  452. and <code>%G</code>; it will not remove trailing zeros
  453. for <code>%g</code> and <code>%G</code>.
  454. </p>
  455. </dl><!-- fmt -->
  456. <dl id="hash/fnv"><dt><a href="/pkg/hash/fnv/">hash/fnv</a></dt>
  457. <dd>
  458. <p><!-- CL 38356 -->
  459. The package now includes 128-bit FNV-1 and FNV-1a hash support with
  460. <a href="/pkg/hash/fnv/#New128"><code>New128</code></a> and
  461. <a href="/pkg/hash/fnv/#New128a"><code>New128a</code></a>, respectively.
  462. </p>
  463. </dl><!-- hash/fnv -->
  464. <dl id="html/template"><dt><a href="/pkg/html/template/">html/template</a></dt>
  465. <dd>
  466. <p><!-- CL 37880, CL 40936 -->
  467. The package now reports an error if a predefined escaper (one of
  468. "html", "urlquery" and "js") is found in a pipeline and does not match
  469. what the auto-escaper would have decided on its own.
  470. This avoids certain security or correctness issues.
  471. Now use of one of these escapers is always either a no-op or an error.
  472. (The no-op case eases migration from <a href="/pkg/text/template/">text/template</a>.)
  473. </p>
  474. </dl><!-- html/template -->
  475. <dl id="image"><dt><a href="/pkg/image/">image</a></dt>
  476. <dd>
  477. <p><!-- CL 36734 -->
  478. The <a href="/pkg/image/#Rectangle.Intersect"><code>Rectangle.Intersect</code></a>
  479. method now returns a zero <code>Rectangle</code> when called on
  480. adjacent but non-overlapping rectangles, as documented. In
  481. earlier releases it would incorrectly return an empty but
  482. non-zero <code>Rectangle</code>.
  483. </p>
  484. </dl><!-- image -->
  485. <dl id="image/color"><dt><a href="/pkg/image/color/">image/color</a></dt>
  486. <dd>
  487. <p><!-- CL 36732 -->
  488. The YCbCr to RGBA conversion formula has been tweaked to ensure
  489. that rounding adjustments span the complete [0, 0xffff] RGBA
  490. range.
  491. </p>
  492. </dl><!-- image/color -->
  493. <dl id="image/png"><dt><a href="/pkg/image/png/">image/png</a></dt>
  494. <dd>
  495. <p><!-- CL 34150 -->
  496. The new <a href="/pkg/image/png/#Encoder.BufferPool"><code>Encoder.BufferPool</code></a>
  497. field allows specifying an <a href="/pkg/image/png/#EncoderBufferPool"><code>EncoderBufferPool</code></a>,
  498. that will be used by the encoder to get temporary <code>EncoderBuffer</code>
  499. buffers when encoding a PNG image.
  500. The use of a <code>BufferPool</code> reduces the number of
  501. memory allocations performed while encoding multiple images.
  502. </p>
  503. <p><!-- CL 38271 -->
  504. The package now supports the decoding of transparent 8-bit
  505. grayscale ("Gray8") images.
  506. </p>
  507. </dl><!-- image/png -->
  508. <dl id="math/big"><dt><a href="/pkg/math/big/">math/big</a></dt>
  509. <dd>
  510. <p><!-- CL 36487 -->
  511. The new
  512. <a href="/pkg/math/big/#Int.IsInt64"><code>IsInt64</code></a>
  513. and
  514. <a href="/pkg/math/big/#Int.IsUint64"><code>IsUint64</code></a>
  515. methods report whether an <code>Int</code>
  516. may be represented as an <code>int64</code> or <code>uint64</code>
  517. value.
  518. </p>
  519. </dl><!-- math/big -->
  520. <dl id="mime/multipart"><dt><a href="/pkg/mime/multipart/">mime/multipart</a></dt>
  521. <dd>
  522. <p><!-- CL 39223 -->
  523. The new
  524. <a href="/pkg/mime/multipart/#FileHeader.Size"><code>FileHeader.Size</code></a>
  525. field describes the size of a file in a multipart message.
  526. </p>
  527. </dl><!-- mime/multipart -->
  528. <dl id="net"><dt><a href="/pkg/net/">net</a></dt>
  529. <dd>
  530. <p><!-- CL 32572 -->
  531. The new
  532. <a href="/pkg/net/#Resolver.StrictErrors"><code>Resolver.StrictErrors</code></a>
  533. provides control over how Go's built-in DNS resolver handles
  534. temporary errors during queries composed of multiple sub-queries,
  535. such as an A+AAAA address lookup.
  536. </p>
  537. <p><!-- CL 37260 -->
  538. The new
  539. <a href="/pkg/net/#Resolver.Dial"><code>Resolver.Dial</code></a>
  540. allows a <code>Resolver</code> to use a custom dial function.
  541. </p>
  542. <p><!-- CL 40510 -->
  543. <a href="/pkg/net/#JoinHostPort"><code>JoinHostPort</code></a> now only places an address in square brackets if the host contains a colon.
  544. In previous releases it would also wrap addresses in square brackets if they contained a percent ('<code>%</code>') sign.
  545. </p>
  546. <p><!-- CL 37913 -->
  547. The new methods
  548. <a href="/pkg/net/#TCPConn.SyscallConn"><code>TCPConn.SyscallConn</code></a>,
  549. <a href="/pkg/net/#IPConn.SyscallConn"><code>IPConn.SyscallConn</code></a>,
  550. <a href="/pkg/net/#UDPConn.SyscallConn"><code>UDPConn.SyscallConn</code></a>,
  551. and
  552. <a href="/pkg/net/#UnixConn.SyscallConn"><code>UnixConn.SyscallConn</code></a>
  553. provide access to the connections' underlying file descriptors.
  554. </p>
  555. <p><!-- 45088 -->
  556. It is now safe to call <a href="/pkg/net/#Dial"><code>Dial</code></a> with the address obtained from
  557. <code>(*TCPListener).String()</code> after creating the listener with
  558. <code><a href="/pkg/net/#Listen">Listen</a>("tcp", ":0")</code>.
  559. Previously it failed on some machines with half-configured IPv6 stacks.
  560. </p>
  561. </dl><!-- net -->
  562. <dl id="net/http"><dt><a href="/pkg/net/http/">net/http</a></dt>
  563. <dd>
  564. <p><!-- CL 37328 -->
  565. The <a href="/pkg/net/http/#Cookie.String"><code>Cookie.String</code></a> method, used for
  566. <code>Cookie</code> and <code>Set-Cookie</code> headers, now encloses values in double quotes
  567. if the value contains either a space or a comma.
  568. </p>
  569. <p>Server changes:</p>
  570. <ul>
  571. <li><!-- CL 38194 -->
  572. <a href="/pkg/net/http/#ServeMux"><code>ServeMux</code></a> now ignores ports in the host
  573. header when matching handlers. The host is matched unmodified for <code>CONNECT</code> requests.
  574. </li>
  575. <li><!-- CL 34727 -->
  576. <a href="/pkg/net/http/#Server.WriteTimeout"><code>Server.WriteTimeout</code></a>
  577. now applies to HTTP/2 connections and is enforced per-stream.
  578. </li>
  579. <li><!-- CL 43231 -->
  580. HTTP/2 now uses the priority write scheduler by default.
  581. Frames are scheduled by following HTTP/2 priorities as described in
  582. <a href="https://tools.ietf.org/html/rfc7540#section-5.3">RFC 7540 Section 5.3</a>.
  583. </li>
  584. <li><!-- CL 36483 -->
  585. The HTTP handler returned by <a href="/pkg/net/http/#StripPrefix"><code>StripPrefix</code></a>
  586. now calls its provided handler with a modified clone of the original <code>*http.Request</code>.
  587. Any code storing per-request state in maps keyed by <code>*http.Request</code> should
  588. use
  589. <a href="/pkg/net/http/#Request.Context"><code>Request.Context</code></a>,
  590. <a href="/pkg/net/http/#Request.WithContext"><code>Request.WithContext</code></a>,
  591. and
  592. <a href="/pkg/context/#WithValue"><code>context.WithValue</code></a> instead.
  593. </li>
  594. </ul>
  595. <p>Client &amp; Transport changes:</p>
  596. <ul>
  597. <li><!-- CL 35488 -->
  598. The <a href="/pkg/net/http/#Transport"><code>Transport</code></a>
  599. now supports making requests via SOCKS5 proxy when the URL returned by
  600. <a href="/net/http/#Transport.Proxy"><code>Transport.Proxy</code></a>
  601. has the scheme <code>socks5</code>.
  602. </li>
  603. </ul>
  604. </dl><!-- net/http -->
  605. <dl id="net/http/fcgi"><dt><a href="/pkg/net/http/fcgi/">net/http/fcgi</a></dt>
  606. <dd>
  607. <p><!-- CL 40012 -->
  608. The new
  609. <a href="/pkg/net/http/fcgi/#ProcessEnv"><code>ProcessEnv</code></a>
  610. function returns FastCGI environment variables associated with an HTTP request
  611. for which there are no appropriate
  612. <a href="/pkg/net/http/#Request"><code>http.Request</code></a>
  613. fields, such as <code>REMOTE_USER</code>.
  614. </p>
  615. </dl><!-- net/http/fcgi -->
  616. <dl id="net/http/httptest"><dt><a href="/pkg/net/http/httptest/">net/http/httptest</a></dt>
  617. <dd>
  618. <p><!-- CL 34639 -->
  619. The new
  620. <a href="/pkg/net/http/httptest/#Server.Client"><code>Server.Client</code></a>
  621. method returns an HTTP client configured for making requests to the test server.
  622. </p>
  623. <p>
  624. The new
  625. <a href="/pkg/net/http/httptest/#Server.Certificate"><code>Server.Certificate</code></a>
  626. method returns the test server's TLS certificate, if any.
  627. </p>
  628. </dl><!-- net/http/httptest -->
  629. <dl id="os"><dt><a href="/pkg/os/">os</a></dt>
  630. <dd>
  631. <p><!-- CL 36800 -->
  632. The <code>os</code> package now uses the internal runtime poller
  633. for file I/O.
  634. This reduces the number of threads required for read/write
  635. operations on pipes, and it eliminates races when one goroutine
  636. closes a file while another is using the file for I/O.
  637. </p>
  638. <dd>
  639. <p><!-- CL 37915 -->
  640. On Windows,
  641. <a href="/pkg/os/#Args"><code>Args</code></a>
  642. is now populated without <code>shell32.dll</code>, improving process start-up time by 1-7 ms.
  643. </p>
  644. </dl><!-- os -->
  645. <dl id="os/exec"><dt><a href="/pkg/os/exec/">os/exec</a></dt>
  646. <dd>
  647. <p><!-- CL 37586 -->
  648. The <code>os/exec</code> package now prevents child processes from being created with
  649. any duplicate environment variables.
  650. If <a href="/pkg/os/exec/#Cmd.Env"><code>Cmd.Env</code></a>
  651. contains duplicate environment keys, only the last
  652. value in the slice for each duplicate key is used.
  653. </p>
  654. </dl><!-- os/exec -->
  655. <dl id="os/user"><dt><a href="/pkg/os/user/">os/user</a></dt>
  656. <dd>
  657. <p><!-- CL 37664 -->
  658. <a href="/pkg/os/user/#Lookup"><code>Lookup</code></a> and
  659. <a href="/pkg/os/user/#LookupId"><code>LookupId</code></a> now
  660. work on Unix systems when <code>CGO_ENABLED=0</code> by reading
  661. the <code>/etc/passwd</code> file.
  662. </p>
  663. <p><!-- CL 33713 -->
  664. <a href="/pkg/os/user/#LookupGroup"><code>LookupGroup</code></a> and
  665. <a href="/pkg/os/user/#LookupGroupId"><code>LookupGroupId</code></a> now
  666. work on Unix systems when <code>CGO_ENABLED=0</code> by reading
  667. the <code>/etc/group</code> file.
  668. </p>
  669. </dl><!-- os/user -->
  670. <dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt>
  671. <dd>
  672. <p><!-- CL 38335 -->
  673. The new
  674. <a href="/pkg/reflect/#MakeMapWithSize"><code>MakeMapWithSize</code></a>
  675. function creates a map with a capacity hint.
  676. </p>
  677. </dl><!-- reflect -->
  678. <dl id="runtime"><dt><a href="/pkg/runtime/">runtime</a></dt>
  679. <dd>
  680. <p><!-- CL 37233, CL 37726 -->
  681. Tracebacks generated by the runtime and recorded in profiles are
  682. now accurate in the presence of inlining.
  683. To retrieve tracebacks programmatically, applications should use
  684. <a href="/pkg/runtime/#CallersFrames"><code>runtime.CallersFrames</code></a>
  685. rather than directly iterating over the results of
  686. <a href="/pkg/runtime/#Callers"><code>runtime.Callers</code></a>.
  687. </p>
  688. <p><!-- CL 38403 -->
  689. On Windows, Go no longer forces the system timer to run at high
  690. resolution when the program is idle.
  691. This should reduce the impact of Go programs on battery life.
  692. </p>
  693. <p><!-- CL 29341 -->
  694. On FreeBSD, <code>GOMAXPROCS</code> and
  695. <a href="/pkg/runtime/#NumCPU"><code>runtime.NumCPU</code></a>
  696. are now based on the process' CPU mask, rather than the total
  697. number of CPUs.
  698. </p>
  699. <p><!-- CL 43641 -->
  700. The runtime has preliminary support for Android O.
  701. </p>
  702. </dl><!-- runtime -->
  703. <dl id="runtime/debug"><dt><a href="/pkg/runtime/debug/">runtime/debug</a></dt>
  704. <dd>
  705. <p><!-- CL 34013 -->
  706. Calling
  707. <a href="/pkg/runtime/debug/#SetGCPercent"><code>SetGCPercent</code></a>
  708. with a negative value no longer runs an immediate garbage collection.
  709. </p>
  710. </dl><!-- runtime/debug -->
  711. <dl id="runtime/trace"><dt><a href="/pkg/runtime/trace/">runtime/trace</a></dt>
  712. <dd>
  713. <p><!-- CL 36015 -->
  714. The execution trace now displays mark assist events, which
  715. indicate when an application goroutine is forced to assist
  716. garbage collection because it is allocating too quickly.
  717. </p>
  718. <p><!-- CL 40810 -->
  719. "Sweep" events now encompass the entire process of finding free
  720. space for an allocation, rather than recording each individual
  721. span that is swept.
  722. This reduces allocation latency when tracing allocation-heavy
  723. programs.
  724. The sweep event shows how many bytes were swept and how many
  725. were reclaimed.
  726. </p>
  727. </dl><!-- runtime/trace -->
  728. <dl id="sync"><dt><a href="/pkg/sync/">sync</a></dt>
  729. <dd>
  730. <p><!-- CL 34310 -->
  731. <a href="/pkg/sync/#Mutex"><code>Mutex</code></a> is now more fair.
  732. </p>
  733. </dl><!-- sync -->
  734. <dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt>
  735. <dd>
  736. <p><!-- CL 36697 -->
  737. The new field
  738. <a href="/pkg/syscall/#Credential.NoSetGroups"><code>Credential.NoSetGroups</code></a>
  739. controls whether Unix systems make a <code>setgroups</code> system call
  740. to set supplementary groups when starting a new process.
  741. </p>
  742. <p><!-- CL 43512 -->
  743. The new field
  744. <a href="/pkg/syscall/#SysProcAttr.AmbientCaps"><code>SysProcAttr.AmbientCaps</code></a>
  745. allows setting ambient capabilities on Linux 4.3+ when creating
  746. a new process.
  747. </p>
  748. <p><!-- CL 37439 -->
  749. On 64-bit x86 Linux, process creation latency has been optimized with
  750. use of <code>CLONE_VFORK</code> and <code>CLONE_VM</code>.
  751. </p>
  752. <p><!-- CL 37913 -->
  753. The new
  754. <a href="/pkg/syscall/#Conn"><code>Conn</code></a>
  755. interface describes some types in the
  756. <a href="/pkg/net/"><code>net</code></a>
  757. package that can provide access to their underlying file descriptor
  758. using the new
  759. <a href="/pkg/syscall/#RawConn"><code>RawConn</code></a>
  760. interface.
  761. </p>
  762. </dl><!-- syscall -->
  763. <dl id="testing/quick"><dt><a href="/pkg/testing/quick/">testing/quick</a></dt>
  764. <dd>
  765. <p><!-- CL 39152 -->
  766. The package now chooses values in the full range when
  767. generating <code>int64</code> and <code>uint64</code> random
  768. numbers; in earlier releases generated values were always
  769. limited to the [-2<sup>62</sup>, 2<sup>62</sup>) range.
  770. </p>
  771. <p>
  772. In previous releases, using a nil
  773. <a href="/pkg/testing/quick/#Config.Rand"><code>Config.Rand</code></a>
  774. value caused a fixed deterministic random number generator to be used.
  775. It now uses a random number generator seeded with the current time.
  776. For the old behavior, set <code>Config.Rand</code> to <code>rand.New(rand.NewSource(0))</code>.
  777. </p>
  778. </dl><!-- testing/quick -->
  779. <dl id="text/template"><dt><a href="/pkg/text/template/">text/template</a></dt>
  780. <dd>
  781. <p><!-- CL 38420 -->
  782. The handling of empty blocks, which was broken by a Go 1.8
  783. change that made the result dependent on the order of templates,
  784. has been fixed, restoring the old Go 1.7 behavior.
  785. </p>
  786. </dl><!-- text/template -->
  787. <dl id="time"><dt><a href="/pkg/time/">time</a></dt>
  788. <dd>
  789. <p><!-- CL 36615 -->
  790. The new methods
  791. <a href="/pkg/time/#Duration.Round"><code>Duration.Round</code></a>
  792. and
  793. <a href="/pkg/time/#Duration.Truncate"><code>Duration.Truncate</code></a>
  794. handle rounding and truncating durations to multiples of a given duration.
  795. </p>
  796. <p><!-- CL 35710 -->
  797. Retrieving the time and sleeping now work correctly under Wine.
  798. </p>
  799. <p>
  800. If a <code>Time</code> value has a monotonic clock reading, its
  801. string representation (as returned by <code>String</code>) now includes a
  802. final field <code>"m=±value"</code>, where <code>value</code> is the
  803. monotonic clock reading formatted as a decimal number of seconds.
  804. </p>
  805. <p><!-- CL 44832 -->
  806. The included <code>tzdata</code> timezone database has been
  807. updated to version 2017b. As always, it is only used if the
  808. system does not already have the database available.
  809. </p>
  810. </dl><!-- time -->