go1.11.html 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934
  1. <!--{
  2. "Title": "Go 1.11 Release Notes",
  3. "Path": "/doc/go1.11",
  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.11</h2>
  16. <p>
  17. The latest Go release, version 1.11, arrives six months after <a href="go1.10">Go 1.10</a>.
  18. Most of its changes are in the implementation of the toolchain, runtime, and libraries.
  19. As always, the release maintains the Go 1 <a href="/doc/go1compat.html">promise of compatibility</a>.
  20. We expect almost all Go programs to continue to compile and run as before.
  21. </p>
  22. <h2 id="language">Changes to the language</h2>
  23. <p>
  24. There are no changes to the language specification.
  25. </p>
  26. <h2 id="ports">Ports</h2>
  27. <p> <!-- CL 94255, CL 115038, etc -->
  28. As <a href="go1.10#ports">announced in the Go 1.10 release notes</a>, Go 1.11 now requires
  29. OpenBSD 6.2 or later, macOS 10.10 Yosemite or later, or Windows 7 or later;
  30. support for previous versions of these operating systems has been removed.
  31. </p>
  32. <p> <!-- CL 121657 -->
  33. Go 1.11 supports the upcoming OpenBSD 6.4 release. Due to changes in
  34. the OpenBSD kernel, older versions of Go will not work on OpenBSD 6.4.
  35. </p>
  36. <p>
  37. There are <a href="https://golang.org/issue/25206">known issues</a> with NetBSD on i386 hardware.
  38. </p>
  39. <p><!-- CL 107935 -->
  40. The race detector is now supported on <code>linux/ppc64le</code>
  41. and, to a lesser extent, on <code>netbsd/amd64</code>. The NetBSD race detector support
  42. has <a href="https://golang.org/issue/26403">known issues</a>.
  43. </p>
  44. <p><!-- CL 109255 -->
  45. The memory sanitizer (<code>-msan</code>) is now supported on <code>linux/arm64</code>.
  46. </p>
  47. <p><!-- CL 93875 -->
  48. The build modes <code>c-shared</code> and <code>c-archive</code> are now supported on
  49. <code>freebsd/amd64</code>.
  50. </p>
  51. <p id="mips"><!-- CL 108475 -->
  52. On 64-bit MIPS systems, the new environment variable settings
  53. <code>GOMIPS64=hardfloat</code> (the default) and
  54. <code>GOMIPS64=softfloat</code> select whether to use
  55. hardware instructions or software emulation for floating-point computations.
  56. For 32-bit systems, the environment variable is still <code>GOMIPS</code>,
  57. as <a href="go1.10#mips">added in Go 1.10</a>.
  58. </p>
  59. <p><!-- CL 107475 -->
  60. On soft-float ARM systems (<code>GOARM=5</code>), Go now uses a more
  61. efficient software floating point interface. This is transparent to
  62. Go code, but ARM assembly that uses floating-point instructions not
  63. guarded on GOARM will break and must be ported to
  64. the <a href="https://golang.org/cl/107475">new interface</a>.
  65. </p>
  66. <p><!-- CL 94076 -->
  67. Go 1.11 on ARMv7 no longer requires a Linux kernel configured
  68. with <code>KUSER_HELPERS</code>. This setting is enabled in default
  69. kernel configurations, but is sometimes disabled in stripped-down
  70. configurations.
  71. </p>
  72. <h3 id="wasm">WebAssembly</h3>
  73. <p>
  74. Go 1.11 adds an experimental port to <a href="https://webassembly.org">WebAssembly</a>
  75. (<code>js/wasm</code>).
  76. </p>
  77. <p>
  78. Go programs currently compile to one WebAssembly module that
  79. includes the Go runtime for goroutine scheduling, garbage
  80. collection, maps, etc.
  81. As a result, the resulting size is at minimum around
  82. 2 MB, or 500 KB compressed. Go programs can call into JavaScript
  83. using the new experimental
  84. <a href="/pkg/syscall/js/"><code>syscall/js</code></a> package.
  85. Binary size and interop with other languages has not yet been a
  86. priority but may be addressed in future releases.
  87. </p>
  88. <p>
  89. As a result of the addition of the new <code>GOOS</code> value
  90. "<code>js</code>" and <code>GOARCH</code> value "<code>wasm</code>",
  91. Go files named <code>*_js.go</code> or <code>*_wasm.go</code> will
  92. now be <a href="/pkg/go/build/#hdr-Build_Constraints">ignored by Go
  93. tools</a> except when those GOOS/GOARCH values are being used.
  94. If you have existing filenames matching those patterns, you will need to rename them.
  95. </p>
  96. <p>
  97. More information can be found on the
  98. <a href="https://golang.org/wiki/WebAssembly">WebAssembly wiki page</a>.
  99. </p>
  100. <h3 id="riscv">RISC-V GOARCH values reserved</h3>
  101. <p><!-- CL 106256 -->
  102. The main Go compiler does not yet support the RISC-V architecture <!-- is gonna change everything -->
  103. but we've reserved the <code>GOARCH</code> values
  104. "<code>riscv</code>" and "<code>riscv64</code>", as used by Gccgo,
  105. which does support RISC-V. This means that Go files
  106. named <code>*_riscv.go</code> will now also
  107. be <a href="/pkg/go/build/#hdr-Build_Constraints">ignored by Go
  108. tools</a> except when those GOOS/GOARCH values are being used.
  109. </p>
  110. <h2 id="tools">Tools</h2>
  111. <h3 id="modules">Modules, package versioning, and dependency management</h3>
  112. <p>
  113. Go 1.11 adds preliminary support for a <a href="/cmd/go/#hdr-Modules__module_versions__and_more">new concept called “modules,”</a>
  114. an alternative to GOPATH with integrated support for versioning and
  115. package distribution.
  116. Using modules, developers are no longer confined to working inside GOPATH,
  117. version dependency information is explicit yet lightweight,
  118. and builds are more reliable and reproducible.
  119. </p>
  120. <p>
  121. Module support is considered experimental.
  122. Details are likely to change in response to feedback from Go 1.11 users,
  123. and we have more tools planned.
  124. Although the details of module support may change, projects that convert
  125. to modules using Go 1.11 will continue to work with Go 1.12 and later.
  126. If you encounter bugs using modules,
  127. please <a href="https://golang.org/issue/new">file issues</a>
  128. so we can fix them. For more information, see the
  129. <a href="/cmd/go#hdr-Modules__module_versions__and_more"><code>go</code> command documentation</a>.
  130. </p>
  131. <h3 id="importpath">Import path restriction</h3>
  132. <p>
  133. Because Go module support assigns special meaning to the
  134. <code>@</code> symbol in command line operations,
  135. the <code>go</code> command now disallows the use of
  136. import paths containing <code>@</code> symbols.
  137. Such import paths were never allowed by <code>go</code> <code>get</code>,
  138. so this restriction can only affect users building
  139. custom GOPATH trees by other means.
  140. </p>
  141. <h3 id="gopackages">Package loading</h3>
  142. <p>
  143. The new package
  144. <a href="https://godoc.org/golang.org/x/tools/go/packages"><code>golang.org/x/tools/go/packages</code></a>
  145. provides a simple API for locating and loading packages of Go source code.
  146. Although not yet part of the standard library, for many tasks it
  147. effectively replaces the <a href="/pkg/go/build"><code>go/build</code></a>
  148. package, whose API is unable to fully support modules.
  149. Because it runs an external query command such as
  150. <a href="/cmd/go/#hdr-List_packages"><code>go list</code></a>
  151. to obtain information about Go packages, it enables the construction of
  152. analysis tools that work equally well with alternative build systems
  153. such as <a href="https://bazel.build">Bazel</a>
  154. and <a href="https://buckbuild.com">Buck</a>.
  155. </p>
  156. <h3 id="gocache">Build cache requirement</h3>
  157. <p>
  158. Go 1.11 will be the last release to support setting the environment
  159. variable <code>GOCACHE=off</code> to disable the
  160. <a href="/cmd/go/#hdr-Build_and_test_caching">build cache</a>,
  161. introduced in Go 1.10.
  162. Starting in Go 1.12, the build cache will be required,
  163. as a step toward eliminating <code>$GOPATH/pkg</code>.
  164. The module and package loading support described above
  165. already require that the build cache be enabled.
  166. If you have disabled the build cache to avoid problems you encountered,
  167. please <a href="https://golang.org/issue/new">file an issue</a> to let us know about them.
  168. </p>
  169. <h3 id="compiler">Compiler toolchain</h3>
  170. <p><!-- CL 109918 -->
  171. More functions are now eligible for inlining by default, including
  172. functions that call <code>panic</code>.
  173. </p>
  174. <p><!-- CL 97375 -->
  175. The compiler toolchain now supports column information
  176. in <a href="/cmd/compile/#hdr-Compiler_Directives">line
  177. directives</a>.
  178. </p>
  179. <p><!-- CL 106797 -->
  180. A new package export data format has been introduced.
  181. This should be transparent to end users, except for speeding up
  182. build times for large Go projects.
  183. If it does cause problems, it can be turned off again by
  184. passing <code>-gcflags=all=-iexport=false</code> to
  185. the <code>go</code> tool when building a binary.
  186. </p>
  187. <p><!-- CL 100459 -->
  188. The compiler now rejects unused variables declared in a type switch
  189. guard, such as <code>x</code> in the following example:
  190. </p>
  191. <pre>
  192. func f(v interface{}) {
  193. switch x := v.(type) {
  194. }
  195. }
  196. </pre>
  197. <p>
  198. This was already rejected by both <code>gccgo</code>
  199. and <a href="/pkg/go/types/">go/types</a>.
  200. </p>
  201. <h3 id="assembler">Assembler</h3>
  202. <p><!-- CL 113315 -->
  203. The assembler for <code>amd64</code> now accepts AVX512 instructions.
  204. </p>
  205. <h3 id="debugging">Debugging</h3>
  206. <p><!-- CL 100738, CL 93664 -->
  207. The compiler now produces significantly more accurate debug
  208. information for optimized binaries, including variable location
  209. information, line numbers, and breakpoint locations.
  210. This should make it possible to debug binaries
  211. compiled <em>without</em> <code>-N</code>&nbsp;<code>-l</code>.
  212. There are still limitations to the quality of the debug information,
  213. some of which are fundamental, and some of which will continue to
  214. improve with future releases.
  215. </p>
  216. <p><!-- CL 118276 -->
  217. DWARF sections are now compressed by default because of the expanded
  218. and more accurate debug information produced by the compiler.
  219. This is transparent to most ELF tools (such as debuggers on Linux
  220. and *BSD) and is supported by the Delve debugger on all platforms,
  221. but has limited support in the native tools on macOS and Windows.
  222. To disable DWARF compression,
  223. pass <code>-ldflags=-compressdwarf=false</code> to
  224. the <code>go</code> tool when building a binary.
  225. </p>
  226. <p><!-- CL 109699 -->
  227. Go 1.11 adds experimental support for calling Go functions from
  228. within a debugger.
  229. This is useful, for example, to call <code>String</code> methods
  230. when paused at a breakpoint.
  231. This is currently only supported by Delve (version 1.1.0 and up).
  232. </p>
  233. <h3 id="test">Test</h3>
  234. <p>
  235. Since Go 1.10, the <code>go</code>&nbsp;<code>test</code> command runs
  236. <code>go</code>&nbsp;<code>vet</code> on the package being tested,
  237. to identify problems before running the test. Since <code>vet</code>
  238. typechecks the code with <a href="/pkg/go/types/">go/types</a>
  239. before running, tests that do not typecheck will now fail.
  240. In particular, tests that contain an unused variable inside a
  241. closure compiled with Go 1.10, because the Go compiler incorrectly
  242. accepted them (<a href="https://golang.org/issues/3059">Issue #3059</a>),
  243. but will now fail, since <code>go/types</code> correctly reports an
  244. "unused variable" error in this case.
  245. </p>
  246. <p><!-- CL 102696 -->
  247. The <code>-memprofile</code> flag
  248. to <code>go</code>&nbsp;<code>test</code> now defaults to the
  249. "allocs" profile, which records the total bytes allocated since the
  250. test began (including garbage-collected bytes).
  251. </p>
  252. <h3 id="vet">Vet</h3>
  253. <p><!-- CL 108555 -->
  254. The <a href="/cmd/vet/"><code>go</code>&nbsp;<code>vet</code></a>
  255. command now reports a fatal error when the package under analysis
  256. does not typecheck. Previously, a type checking error simply caused
  257. a warning to be printed, and <code>vet</code> to exit with status 1.
  258. </p>
  259. <p><!-- CL 108559 -->
  260. Additionally, <a href="/cmd/vet"><code>go</code>&nbsp;<code>vet</code></a>
  261. has become more robust when format-checking <code>printf</code> wrappers.
  262. Vet now detects the mistake in this example:
  263. </p>
  264. <pre>
  265. func wrapper(s string, args ...interface{}) {
  266. fmt.Printf(s, args...)
  267. }
  268. func main() {
  269. wrapper("%s", 42)
  270. }
  271. </pre>
  272. <h3 id="trace">Trace</h3>
  273. <p><!-- CL 63274 -->
  274. With the new <code>runtime/trace</code>
  275. package's <a href="/pkg/runtime/trace/#hdr-User_annotation">user
  276. annotation API</a>, users can record application-level information
  277. in execution traces and create groups of related goroutines.
  278. The <code>go</code>&nbsp;<code>tool</code>&nbsp;<code>trace</code>
  279. command visualizes this information in the trace view and the new
  280. user task/region analysis page.
  281. </p>
  282. <h3 id="cgo">Cgo</h3>
  283. <p>
  284. Since Go 1.10, cgo has translated some C pointer types to the Go
  285. type <code>uintptr</code>. These types include
  286. the <code>CFTypeRef</code> hierarchy in Darwin's CoreFoundation
  287. framework and the <code>jobject</code> hierarchy in Java's JNI
  288. interface. In Go 1.11, several improvements have been made to the code
  289. that detects these types. Code that uses these types may need some
  290. updating. See the <a href="go1.10.html#cgo">Go 1.10 release notes</a> for
  291. details. <!-- CL 126275, CL 127156, CL 122217, CL 122575, CL 123177 -->
  292. </p>
  293. <h3 id="go_command">Go command</h3>
  294. <p><!-- CL 126656 -->
  295. The environment variable <code>GOFLAGS</code> may now be used
  296. to set default flags for the <code>go</code> command.
  297. This is useful in certain situations.
  298. Linking can be noticeably slower on underpowered systems due to DWARF,
  299. and users may want to set <code>-ldflags=-w</code> by default.
  300. For modules, some users and CI systems will want vendoring always,
  301. so they should set <code>-mod=vendor</code> by default.
  302. For more information, see the <a href="/cmd/go/#hdr-Environment_variables"><code>go</code>
  303. command documentation</a>.
  304. </p>
  305. <h3 id="godoc">Godoc</h3>
  306. <p>
  307. Go 1.11 will be the last release to support <code>godoc</code>'s command-line interface.
  308. In future releases, <code>godoc</code> will only be a web server. Users should use
  309. <code>go</code> <code>doc</code> for command-line help output instead.
  310. </p>
  311. <p><!-- CL 85396, CL 124495 -->
  312. The <code>godoc</code> web server now shows which version of Go introduced
  313. new API features. The initial Go version of types, funcs, and methods are shown
  314. right-aligned. For example, see <a href="/pkg/os/#UserCacheDir"><code>UserCacheDir</code></a>, with "1.11"
  315. on the right side. For struct fields, inline comments are added when the struct field was
  316. added in a Go version other than when the type itself was introduced.
  317. For a struct field example, see
  318. <a href="/pkg/net/http/httptrace/#ClientTrace.Got1xxResponse"><code>ClientTrace.Got1xxResponse</code></a>.
  319. </p>
  320. <h3 id="gofmt">Gofmt</h3>
  321. <p>
  322. One minor detail of the default formatting of Go source code has changed.
  323. When formatting expression lists with inline comments, the comments were
  324. aligned according to a heuristic.
  325. However, in some cases the alignment would be split up too easily, or
  326. introduce too much whitespace.
  327. The heuristic has been changed to behave better for human-written code.
  328. </p>
  329. <p>
  330. Note that these kinds of minor updates to gofmt are expected from time to
  331. time.
  332. In general, systems that need consistent formatting of Go source code should
  333. use a specific version of the <code>gofmt</code> binary.
  334. See the <a href="/pkg/go/format/">go/format</a> package documentation for more
  335. information.
  336. </p>
  337. <h3 id="run">Run</h3>
  338. <p>
  339. <!-- CL 109341 -->
  340. The <a href="/cmd/go/"><code>go</code>&nbsp;<code>run</code></a>
  341. command now allows a single import path, a directory name or a
  342. pattern matching a single package.
  343. This allows <code>go</code>&nbsp;<code>run</code>&nbsp;<code>pkg</code> or <code>go</code>&nbsp;<code>run</code>&nbsp;<code>dir</code>, most importantly <code>go</code>&nbsp;<code>run</code>&nbsp;<code>.</code>
  344. </p>
  345. <h2 id="runtime">Runtime</h2>
  346. <p><!-- CL 85887 -->
  347. The runtime now uses a sparse heap layout so there is no longer a
  348. limit to the size of the Go heap (previously, the limit was 512GiB).
  349. This also fixes rare "address space conflict" failures in mixed Go/C
  350. binaries or binaries compiled with <code>-race</code>.
  351. </p>
  352. <p><!-- CL 108679, CL 106156 -->
  353. On macOS and iOS, the runtime now uses <code>libSystem.dylib</code> instead of
  354. calling the kernel directly. This should make Go binaries more
  355. compatible with future versions of macOS and iOS.
  356. The <a href="/pkg/syscall">syscall</a> package still makes direct
  357. system calls; fixing this is planned for a future release.
  358. </p>
  359. <h2 id="performance">Performance</h2>
  360. <p>
  361. As always, the changes are so general and varied that precise
  362. statements about performance are difficult to make. Most programs
  363. should run a bit faster, due to better generated code and
  364. optimizations in the core library.
  365. </p>
  366. <p><!-- CL 74851 -->
  367. There were multiple performance changes to the <code>math/big</code>
  368. package as well as many changes across the tree specific to <code>GOARCH=arm64</code>.
  369. </p>
  370. <h3 id="performance-compiler">Compiler toolchain</h3>
  371. <p><!-- CL 110055 -->
  372. The compiler now optimizes map clearing operations of the form:
  373. </p>
  374. <pre>
  375. for k := range m {
  376. delete(m, k)
  377. }
  378. </pre>
  379. <p><!-- CL 109517 -->
  380. The compiler now optimizes slice extension of the form
  381. <code>append(s,</code>&nbsp;<code>make([]T,</code>&nbsp;<code>n)...)</code>.
  382. </p>
  383. <p><!-- CL 100277, CL 105635, CL 109776 -->
  384. The compiler now performs significantly more aggressive bounds-check
  385. and branch elimination. Notably, it now recognizes transitive
  386. relations, so if <code>i&lt;j</code> and <code>j&lt;len(s)</code>,
  387. it can use these facts to eliminate the bounds check
  388. for <code>s[i]</code>. It also understands simple arithmetic such
  389. as <code>s[i-10]</code> and can recognize more inductive cases in
  390. loops. Furthermore, the compiler now uses bounds information to more
  391. aggressively optimize shift operations.
  392. </p>
  393. <h2 id="library">Core library</h2>
  394. <p>
  395. All of the changes to the standard library are minor.
  396. </p>
  397. <h3 id="minor_library_changes">Minor changes to the library</h3>
  398. <p>
  399. As always, there are various minor changes and updates to the library,
  400. made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a>
  401. in mind.
  402. </p>
  403. <!-- CL 115095: https://golang.org/cl/115095: yes (`go test pkg` now always builds pkg even if there are no test files): cmd/go: output coverage report even if there are no test files -->
  404. <!-- CL 110395: https://golang.org/cl/110395: cmd/go, cmd/compile: use Windows response files to avoid arg length limits -->
  405. <!-- CL 112436: https://golang.org/cl/112436: cmd/pprof: add readline support similar to upstream -->
  406. <dl id="crypto"><dt><a href="/pkg/crypto/">crypto</a></dt>
  407. <dd>
  408. <p><!-- CL 64451 -->
  409. Certain crypto operations, including
  410. <a href="/pkg/crypto/ecdsa/#Sign"><code>ecdsa.Sign</code></a>,
  411. <a href="/pkg/crypto/rsa/#EncryptPKCS1v15"><code>rsa.EncryptPKCS1v15</code></a> and
  412. <a href="/pkg/crypto/rsa/#GenerateKey"><code>rsa.GenerateKey</code></a>,
  413. now randomly read an extra byte of randomness to ensure tests don't rely on internal behavior.
  414. </p>
  415. </dl><!-- crypto -->
  416. <dl id="crypto/cipher"><dt><a href="/pkg/crypto/cipher/">crypto/cipher</a></dt>
  417. <dd>
  418. <p><!-- CL 48510, CL 116435 -->
  419. The new function <a href="/pkg/crypto/cipher/#NewGCMWithTagSize"><code>NewGCMWithTagSize</code></a>
  420. implements Galois Counter Mode with non-standard tag lengths for compatibility with existing cryptosystems.
  421. </p>
  422. </dl><!-- crypto/cipher -->
  423. <dl id="crypto/rsa"><dt><a href="/pkg/crypto/rsa/">crypto/rsa</a></dt>
  424. <dd>
  425. <p><!-- CL 103876 -->
  426. <a href="/pkg/crypto/rsa/#PublicKey"><code>PublicKey</code></a> now implements a
  427. <a href="/pkg/crypto/rsa/#PublicKey.Size"><code>Size</code></a> method that
  428. returns the modulus size in bytes.
  429. </p>
  430. </dl><!-- crypto/rsa -->
  431. <dl id="crypto/tls"><dt><a href="/pkg/crypto/tls/">crypto/tls</a></dt>
  432. <dd>
  433. <p><!-- CL 85115 -->
  434. <a href="/pkg/crypto/tls/#ConnectionState"><code>ConnectionState</code></a>'s new
  435. <a href="/pkg/crypto/tls/#ConnectionState.ExportKeyingMaterial"><code>ExportKeyingMaterial</code></a>
  436. method allows exporting keying material bound to the
  437. connection according to RFC 5705.
  438. </p>
  439. </dl><!-- crypto/tls -->
  440. <dl id="crypto/x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt>
  441. <dd>
  442. <p><!-- CL 123355, CL 123695 -->
  443. The deprecated, legacy behavior of treating the <code>CommonName</code> field as
  444. a hostname when no Subject Alternative Names are present is now disabled when the CN is not a
  445. valid hostname.
  446. The <code>CommonName</code> can be completely ignored by adding the experimental value
  447. <code>x509ignoreCN=1</code> to the <code>GODEBUG</code> environment variable.
  448. When the CN is ignored, certificates without SANs validate under chains with name constraints
  449. instead of returning <code>NameConstraintsWithoutSANs</code>.
  450. </p>
  451. <p><!-- CL 113475 -->
  452. Extended key usage restrictions are again checked only if they appear in the <code>KeyUsages</code>
  453. field of <a href="/pkg/crypto/x509/#VerifyOptions"><code>VerifyOptions</code></a>, instead of always being checked.
  454. This matches the behavior of Go 1.9 and earlier.
  455. </p>
  456. <p><!-- CL 102699 -->
  457. The value returned by <a href="/pkg/crypto/x509/#SystemCertPool"><code>SystemCertPool</code></a>
  458. is now cached and might not reflect system changes between invocations.
  459. </p>
  460. </dl><!-- crypto/x509 -->
  461. <dl id="debug/elf"><dt><a href="/pkg/debug/elf/">debug/elf</a></dt>
  462. <dd>
  463. <p><!-- CL 112115 -->
  464. More <a href="/pkg/debug/elf/#ELFOSABI_NONE"><code>ELFOSABI</code></a>
  465. and <a href="/pkg/debug/elf/#EM_NONE"><code>EM</code></a>
  466. constants have been added.
  467. </p>
  468. </dl><!-- debug/elf -->
  469. <dl id="encoding/asn1"><dt><a href="/pkg/encoding/asn1/">encoding/asn1</a></dt>
  470. <dd>
  471. <p><!-- CL 110561 -->
  472. <code>Marshal</code> and <code><a href="/pkg/encoding/asn1/#Unmarshal">Unmarshal</a></code>
  473. now support "private" class annotations for fields.
  474. </p>
  475. </dl><!-- encoding/asn1 -->
  476. <dl id="encoding/base32"><dt><a href="/pkg/encoding/base32/">encoding/base32</a></dt>
  477. <dd>
  478. <p><!-- CL 112516 -->
  479. The decoder now consistently
  480. returns <code>io.ErrUnexpectedEOF</code> for an incomplete
  481. chunk. Previously it would return <code>io.EOF</code> in some
  482. cases.
  483. </p>
  484. </dl><!-- encoding/base32 -->
  485. <dl id="encoding/csv"><dt><a href="/pkg/encoding/csv/">encoding/csv</a></dt>
  486. <dd>
  487. <p><!-- CL 99696 -->
  488. The <code>Reader</code> now rejects attempts to set
  489. the <a href="/pkg/encoding/csv/#Reader.Comma"><code>Comma</code></a>
  490. field to a double-quote character, as double-quote characters
  491. already have a special meaning in CSV.
  492. </p>
  493. </dl><!-- encoding/csv -->
  494. <!-- CL 100235 was reverted -->
  495. <dl id="html/template"><dt><a href="/pkg/html/template/">html/template</a></dt>
  496. <dd>
  497. <p><!-- CL 121815 -->
  498. The package has changed its behavior when a typed interface
  499. value is passed to an implicit escaper function. Previously such
  500. a value was written out as (an escaped form)
  501. of <code>&lt;nil&gt;</code>. Now such values are ignored, just
  502. as an untyped <code>nil</code> value is (and always has been)
  503. ignored.
  504. </p>
  505. </dl><!-- html/template -->
  506. <dl id="image/gif"><dt><a href="/pkg/image/gif/">image/gif</a></dt>
  507. <dd>
  508. <p><!-- CL 93076 -->
  509. Non-looping animated GIFs are now supported. They are denoted by having a
  510. <code><a href="/pkg/image/gif/#GIF.LoopCount">LoopCount</a></code> of -1.
  511. </p>
  512. </dl><!-- image/gif -->
  513. <dl id="io/ioutil"><dt><a href="/pkg/io/ioutil/">io/ioutil</a></dt>
  514. <dd>
  515. <p><!-- CL 105675 -->
  516. The <code><a href="/pkg/io/ioutil/#TempFile">TempFile</a></code>
  517. function now supports specifying where the random characters in
  518. the filename are placed. If the <code>prefix</code> argument
  519. includes a "<code>*</code>", the random string replaces the
  520. "<code>*</code>". For example, a <code>prefix</code> argument of "<code>myname.*.bat</code>" will
  521. result in a random filename such as
  522. "<code>myname.123456.bat</code>". If no "<code>*</code>" is
  523. included the old behavior is retained, and the random digits are
  524. appended to the end.
  525. </p>
  526. </dl><!-- io/ioutil -->
  527. <dl id="math/big"><dt><a href="/pkg/math/big/">math/big</a></dt>
  528. <dd>
  529. <p><!-- CL 108996 -->
  530. <a href="/pkg/math/big/#Int.ModInverse"><code>ModInverse</code></a> now returns nil when g and n are not relatively prime. The result was previously undefined.
  531. </p>
  532. </dl><!-- math/big -->
  533. <dl id="mime/multipart"><dt><a href="/pkg/mime/multipart/">mime/multipart</a></dt>
  534. <dd>
  535. <p><!-- CL 121055 -->
  536. The handling of form-data with missing/empty file names has been
  537. restored to the behavior in Go 1.9: in the
  538. <a href="/pkg/mime/multipart/#Form"><code>Form</code></a> for
  539. the form-data part the value is available in
  540. the <code>Value</code> field rather than the <code>File</code>
  541. field. In Go releases 1.10 through 1.10.3 a form-data part with
  542. a missing/empty file name and a non-empty "Content-Type" field
  543. was stored in the <code>File</code> field. This change was a
  544. mistake in 1.10 and has been reverted to the 1.9 behavior.
  545. </p>
  546. </dl><!-- mime/multipart -->
  547. <dl id="mime/quotedprintable"><dt><a href="/pkg/mime/quotedprintable/">mime/quotedprintable</a></dt>
  548. <dd>
  549. <p><!-- CL 121095 -->
  550. To support invalid input found in the wild, the package now
  551. permits non-ASCII bytes but does not validate their encoding.
  552. </p>
  553. </dl><!-- mime/quotedprintable -->
  554. <dl id="net"><dt><a href="/pkg/net/">net</a></dt>
  555. <dd>
  556. <p><!-- CL 72810 -->
  557. The new <a href="/pkg/net/#ListenConfig"><code>ListenConfig</code></a> type and the new
  558. <a href="/pkg/net/#Dialer.Control"><code>Dialer.Control</code></a> field permit
  559. setting socket options before accepting and creating connections, respectively.
  560. </p>
  561. <p><!-- CL 76391 -->
  562. The <a href="/pkg/syscall/#RawConn"><code>syscall.RawConn</code></a> <code>Read</code>
  563. and <code>Write</code> methods now work correctly on Windows.
  564. </p>
  565. <p><!-- CL 107715 -->
  566. The <code>net</code> package now automatically uses the
  567. <a href="http://man7.org/linux/man-pages/man2/splice.2.html"><code>splice</code> system call</a>
  568. on Linux when copying data between TCP connections in
  569. <a href="/pkg/net/#TCPConn.ReadFrom"><code>TCPConn.ReadFrom</code></a>, as called by
  570. <a href="/pkg/io/#Copy"><code>io.Copy</code></a>. The result is faster, more efficient TCP proxying.
  571. </p>
  572. <p><!-- CL 108297 -->
  573. The <a href="/pkg/net/#TCPConn.File"><code>TCPConn.File</code></a>,
  574. <a href="/pkg/net/#UDPConn.File"><code>UDPConn.File</code></a>,
  575. <a href="/pkg/net/#UnixCOnn.File"><code>UnixConn.File</code></a>,
  576. and <a href="/pkg/net/#IPConn.File"><code>IPConn.File</code></a>
  577. methods no longer put the returned <code>*os.File</code> into
  578. blocking mode.
  579. </p>
  580. </dl><!-- net -->
  581. <dl id="net/http"><dt><a href="/pkg/net/http/">net/http</a></dt>
  582. <dd>
  583. <p><!-- CL 71272 -->
  584. The <a href="/pkg/net/http/#Transport"><code>Transport</code></a> type has a
  585. new <a href="/pkg/net/http/#Transport.MaxConnsPerHost"><code>MaxConnsPerHost</code></a>
  586. option that permits limiting the maximum number of connections
  587. per host.
  588. </p>
  589. <p><!-- CL 79919 -->
  590. The <a href="/pkg/net/http/#Cookie"><code>Cookie</code></a> type has a new
  591. <a href="/pkg/net/http/#Cookie.SameSite"><code>SameSite</code></a> field
  592. (of new type also named
  593. <a href="/pkg/net/http/#SameSite"><code>SameSite</code></a>) to represent the new cookie attribute recently supported by most browsers.
  594. The <code>net/http</code>'s <code>Transport</code> does not use the <code>SameSite</code>
  595. attribute itself, but the package supports parsing and serializing the
  596. attribute for browsers to use.
  597. </p>
  598. <p><!-- CL 81778 -->
  599. It is no longer allowed to reuse a <a href="/pkg/net/http/#Server"><code>Server</code></a>
  600. after a call to
  601. <a href="/pkg/net/http/#Server.Shutdown"><code>Shutdown</code></a> or
  602. <a href="/pkg/net/http/#Server.Close"><code>Close</code></a>. It was never officially supported
  603. in the past and had often surprising behavior. Now, all future calls to the server's <code>Serve</code>
  604. methods will return errors after a shutdown or close.
  605. </p>
  606. <!-- CL 89275 was reverted before Go 1.11 -->
  607. <p><!-- CL 93296 -->
  608. The constant <code>StatusMisdirectedRequest</code> is now defined for HTTP status code 421.
  609. </p>
  610. <p><!-- CL 123875 -->
  611. The HTTP server will no longer cancel contexts or send on
  612. <a href="/pkg/net/http/#CloseNotifier"><code>CloseNotifier</code></a>
  613. channels upon receiving pipelined HTTP/1.1 requests. Browsers do
  614. not use HTTP pipelining, but some clients (such as
  615. Debian's <code>apt</code>) may be configured to do so.
  616. </p>
  617. <p><!-- CL 115255 -->
  618. <a href="/pkg/net/http/#ProxyFromEnvironment"><code>ProxyFromEnvironment</code></a>, which is used by the
  619. <a href="/pkg/net/http/#DefaultTransport"><code>DefaultTransport</code></a>, now
  620. supports CIDR notation and ports in the <code>NO_PROXY</code> environment variable.
  621. </p>
  622. </dl><!-- net/http -->
  623. <dl id="net/http/httputil"><dt><a href="/pkg/net/http/httputil/">net/http/httputil</a></dt>
  624. <dd>
  625. <p><!-- CL 77410 -->
  626. The
  627. <a href="/pkg/net/http/httputil/#ReverseProxy"><code>ReverseProxy</code></a>
  628. has a new
  629. <a href="/pkg/net/http/httputil/#ReverseProxy.ErrorHandler"><code>ErrorHandler</code></a>
  630. option to permit changing how errors are handled.
  631. </p>
  632. <p><!-- CL 115135 -->
  633. The <code>ReverseProxy</code> now also passes
  634. "<code>TE:</code>&nbsp;<code>trailers</code>" request headers
  635. through to the backend, as required by the gRPC protocol.
  636. </p>
  637. </dl><!-- net/http/httputil -->
  638. <dl id="os"><dt><a href="/pkg/os/">os</a></dt>
  639. <dd>
  640. <p><!-- CL 78835 -->
  641. The new <a href="/pkg/os/#UserCacheDir"><code>UserCacheDir</code></a> function
  642. returns the default root directory to use for user-specific cached data.
  643. </p>
  644. <p><!-- CL 94856 -->
  645. The new <a href="/pkg/os/#ModeIrregular"><code>ModeIrregular</code></a>
  646. is a <a href="/pkg/os/#FileMode"><code>FileMode</code></a> bit to represent
  647. that a file is not a regular file, but nothing else is known about it, or that
  648. it's not a socket, device, named pipe, symlink, or other file type for which
  649. Go has a defined mode bit.
  650. </p>
  651. <p><!-- CL 99337 -->
  652. <a href="/pkg/os/#Symlink"><code>Symlink</code></a> now works
  653. for unprivileged users on Windows 10 on machines with Developer
  654. Mode enabled.
  655. </p>
  656. <p><!-- CL 100077 -->
  657. When a non-blocking descriptor is passed
  658. to <a href="/pkg/os#NewFile"><code>NewFile</code></a>, the
  659. resulting <code>*File</code> will be kept in non-blocking
  660. mode. This means that I/O for that <code>*File</code> will use
  661. the runtime poller rather than a separate thread, and that
  662. the <a href="/pkg/os/#File.SetDeadline"><code>SetDeadline</code></a>
  663. methods will work.
  664. </p>
  665. </dl><!-- os -->
  666. <dl id="os/signal"><dt><a href="/pkg/os/signal/">os/signal</a></dt>
  667. <dd>
  668. <p><!-- CL 108376 -->
  669. The new <a href="/pkg/os/signal/#Ignored"><code>Ignored</code></a> function reports
  670. whether a signal is currently ignored.
  671. </p>
  672. </dl><!-- os/signal -->
  673. <dl id="os/user"><dt><a href="/pkg/os/user/">os/user</a></dt>
  674. <dd>
  675. <p><!-- CL 92456 -->
  676. The <code>os/user</code> package can now be built in pure Go
  677. mode using the build tag "<code>osusergo</code>",
  678. independent of the use of the environment
  679. variable <code>CGO_ENABLED=0</code>. Previously the only way to use
  680. the package's pure Go implementation was to disable <code>cgo</code>
  681. support across the entire program.
  682. </p>
  683. </dl><!-- os/user -->
  684. <!-- CL 101715 was reverted -->
  685. <dl id="runtime-again"><dt><a href="/pkg/runtime/">runtime</a></dt>
  686. <dd>
  687. <p><!-- CL 70993 -->
  688. Setting the <code>GODEBUG=tracebackancestors=<em>N</em></code>
  689. environment variable now extends tracebacks with the stacks at
  690. which goroutines were created, where <em>N</em> limits the
  691. number of ancestor goroutines to report.
  692. </p>
  693. </dl><!-- runtime -->
  694. <dl id="runtime/pprof"><dt><a href="/pkg/runtime/pprof/">runtime/pprof</a></dt>
  695. <dd>
  696. <p><!-- CL 102696 -->
  697. This release adds a new "allocs" profile type that profiles
  698. total number of bytes allocated since the program began
  699. (including garbage-collected bytes). This is identical to the
  700. existing "heap" profile viewed in <code>-alloc_space</code> mode.
  701. Now <code>go test -memprofile=...</code> reports an "allocs" profile
  702. instead of "heap" profile.
  703. </p>
  704. </dl><!-- runtime/pprof -->
  705. <dl id="sync"><dt><a href="/pkg/sync/">sync</a></dt>
  706. <dd>
  707. <p><!-- CL 87095 -->
  708. The mutex profile now includes reader/writer contention
  709. for <a href="/pkg/sync/#RWMutex"><code>RWMutex</code></a>.
  710. Writer/writer contention was already included in the mutex
  711. profile.
  712. </p>
  713. </dl><!-- sync -->
  714. <dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt>
  715. <dd>
  716. <p><!-- CL 106275 -->
  717. On Windows, several fields were changed from <code>uintptr</code> to a new
  718. <a href="/pkg/syscall/?GOOS=windows&GOARCH=amd64#Pointer"><code>Pointer</code></a>
  719. type to avoid problems with Go's garbage collector. The same change was made
  720. to the <a href="https://godoc.org/golang.org/x/sys/windows"><code>golang.org/x/sys/windows</code></a>
  721. package. For any code affected, users should first migrate away from the <code>syscall</code>
  722. package to the <code>golang.org/x/sys/windows</code> package, and then change
  723. to using the <code>Pointer</code>, while obeying the
  724. <a href="/pkg/unsafe/#Pointer"><code>unsafe.Pointer</code> conversion rules</a>.
  725. </p>
  726. <p><!-- CL 118658 -->
  727. On Linux, the <code>flags</code> parameter to
  728. <a href="/pkg/syscall/?GOOS=linux&GOARCH=amd64#Faccessat"><code>Faccessat</code></a>
  729. is now implemented just as in glibc. In earlier Go releases the
  730. flags parameter was ignored.
  731. </p>
  732. <p><!-- CL 118658 -->
  733. On Linux, the <code>flags</code> parameter to
  734. <a href="/pkg/syscall/?GOOS=linux&GOARCH=amd64#Fchmodat"><code>Fchmodat</code></a>
  735. is now validated. Linux's <code>fchmodat</code> doesn't support the <code>flags</code> parameter
  736. so we now mimic glibc's behavior and return an error if it's non-zero.
  737. </p>
  738. </dl><!-- syscall -->
  739. <dl id="text/scanner"><dt><a href="/pkg/text/scanner/">text/scanner</a></dt>
  740. <dd>
  741. <p><!-- CL 112037 -->
  742. The <a href="/pkg/text/scanner/#Scanner.Scan"><code>Scanner.Scan</code></a> method now returns
  743. the <a href="/pkg/text/scanner/#RawString"><code>RawString</code></a> token
  744. instead of <a href="/pkg/text/scanner/#String"><code>String</code></a>
  745. for raw string literals.
  746. </p>
  747. </dl><!-- text/scanner -->
  748. <dl id="text/template"><dt><a href="/pkg/text/template/">text/template</a></dt>
  749. <dd>
  750. <p><!-- CL 84480 -->
  751. Modifying template variables via assignments is now permitted via the <code>=</code> token:
  752. </p>
  753. <pre>
  754. {{"{{"}} $v := "init" {{"}}"}}
  755. {{"{{"}} if true {{"}}"}}
  756. {{"{{"}} $v = "changed" {{"}}"}}
  757. {{"{{"}} end {{"}}"}}
  758. v: {{"{{"}} $v {{"}}"}} {{"{{"}}/* "changed" */{{"}}"}}</pre>
  759. <p><!-- CL 95215 -->
  760. In previous versions untyped <code>nil</code> values passed to
  761. template functions were ignored. They are now passed as normal
  762. arguments.
  763. </p>
  764. </dl><!-- text/template -->
  765. <dl id="time"><dt><a href="/pkg/time/">time</a></dt>
  766. <dd>
  767. <p><!-- CL 98157 -->
  768. Parsing of timezones denoted by sign and offset is now
  769. supported. In previous versions, numeric timezone names
  770. (such as <code>+03</code>) were not considered valid, and only
  771. three-letter abbreviations (such as <code>MST</code>) were accepted
  772. when expecting a timezone name.
  773. </p>
  774. </dl><!-- time -->