go1.9.html 37 KB

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