go1.12.html 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949
  1. <!--{
  2. "Title": "Go 1.12 Release Notes",
  3. "Path": "/doc/go1.12",
  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.12</h2>
  16. <p>
  17. The latest Go release, version 1.12, arrives six months after <a href="go1.11">Go 1.11</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">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 138675 -->
  28. The race detector is now supported on <code>linux/arm64</code>.
  29. </p>
  30. <p id="freebsd">
  31. Go 1.12 is the last release that is supported on FreeBSD 10.x, which has
  32. already reached end-of-life. Go 1.13 will require FreeBSD 11.2+ or FreeBSD
  33. 12.0+.
  34. FreeBSD 12.0+ requires a kernel with the COMPAT_FREEBSD11 option set (this is the default).
  35. </p>
  36. <p><!-- CL 146898 -->
  37. cgo is now supported on <code>linux/ppc64</code>.
  38. </p>
  39. <p id="hurd"><!-- CL 146023 -->
  40. <code>hurd</code> is now a recognized value for <code>GOOS</code>, reserved
  41. for the GNU/Hurd system for use with <code>gccgo</code>.
  42. </p>
  43. <h3 id="windows">Windows</h3>
  44. <p>
  45. Go's new <code>windows/arm</code> port supports running Go on Windows 10
  46. IoT Core on 32-bit ARM chips such as the Raspberry Pi 3.
  47. </p>
  48. <h3 id="aix">AIX</h3>
  49. <p>
  50. Go now supports AIX 7.2 and later on POWER8 architectures (<code>aix/ppc64</code>). External linking, cgo, pprof and the race detector aren't yet supported.
  51. </p>
  52. <h3 id="darwin">Darwin</h3>
  53. <p>
  54. Go 1.12 is the last release that will run on macOS 10.10 Yosemite.
  55. Go 1.13 will require macOS 10.11 El Capitan or later.
  56. </p>
  57. <p><!-- CL 141639 -->
  58. <code>libSystem</code> is now used when making syscalls on Darwin,
  59. ensuring forward-compatibility with future versions of macOS and iOS.
  60. <!-- CL 153338 -->
  61. The switch to <code>libSystem</code> triggered additional App Store
  62. checks for private API usage. Since it is considered private,
  63. <code>syscall.Getdirentries</code> now always fails with
  64. <code>ENOSYS</code> on iOS.
  65. Additionally, <a href="/pkg/syscall/#Setrlimit"><code>syscall.Setrlimit</code></a>
  66. reports <code>invalid</code> <code>argument</code> in places where it historically
  67. succeeded. These consequences are not specific to Go and users should expect
  68. behavioral parity with <code>libSystem</code>'s implementation going forward.
  69. </p>
  70. <h2 id="tools">Tools</h2>
  71. <h3 id="vet"><code>go tool vet</code> no longer supported</h3>
  72. <p>
  73. The <code>go vet</code> command has been rewritten to serve as the
  74. base for a range of different source code analysis tools. See
  75. the <a href="https://godoc.org/golang.org/x/tools/go/analysis">golang.org/x/tools/go/analysis</a>
  76. package for details. A side-effect is that <code>go tool vet</code>
  77. is no longer supported. External tools that use <code>go tool
  78. vet</code> must be changed to use <code>go
  79. vet</code>. Using <code>go vet</code> instead of <code>go tool
  80. vet</code> should work with all supported versions of Go.
  81. </p>
  82. <p>
  83. As part of this change, the experimental <code>-shadow</code> option
  84. is no longer available with <code>go vet</code>. Checking for
  85. variable shadowing may now be done using
  86. <pre>
  87. go get -u golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
  88. go vet -vettool=$(which shadow)
  89. </pre>
  90. </p>
  91. <h3 id="tour">Tour</h3>
  92. <p> <!-- CL 152657 -->
  93. The Go tour is no longer included in the main binary distribution. To
  94. run the tour locally, instead of running <code>go</code> <code>tool</code> <code>tour</code>,
  95. manually install it:
  96. <pre>
  97. go get -u golang.org/x/tour
  98. tour
  99. </pre>
  100. </p>
  101. <h3 id="gocache">Build cache requirement</h3>
  102. <p>
  103. The <a href="/cmd/go/#hdr-Build_and_test_caching">build cache</a> is now
  104. required as a step toward eliminating
  105. <code>$GOPATH/pkg</code>. Setting the environment variable
  106. <code>GOCACHE=off</code> will cause <code>go</code> commands that write to the
  107. cache to fail.
  108. </p>
  109. <h3 id="binary-only">Binary-only packages</h3>
  110. <p>
  111. Go 1.12 is the last release that will support binary-only packages.
  112. </p>
  113. <h3 id="cgo">Cgo</h3>
  114. <p>
  115. Go 1.12 will translate the C type <code>EGLDisplay</code> to the Go type <code>uintptr</code>.
  116. This change is similar to how Go 1.10 and newer treats Darwin's CoreFoundation
  117. and Java's JNI types. See the
  118. <a href="/cmd/cgo/#hdr-Special_cases">cgo documentation</a>
  119. for more information.
  120. </p>
  121. <p><!-- CL 152657 -->
  122. Mangled C names are no longer accepted in packages that use Cgo. Use the Cgo
  123. names instead. For example, use the documented cgo name <code>C.char</code>
  124. rather than the mangled name <code>_Ctype_char</code> that cgo generates.
  125. </p>
  126. <h3 id="modules">Modules</h3>
  127. <p><!-- CL 148517 -->
  128. When <code>GO111MODULE</code> is set to <code>on</code>, the <code>go</code>
  129. command now supports module-aware operations outside of a module directory,
  130. provided that those operations do not need to resolve import paths relative to
  131. the current directory or explicitly edit the <code>go.mod</code> file.
  132. Commands such as <code>go</code> <code>get</code>,
  133. <code>go</code> <code>list</code>, and
  134. <code>go</code> <code>mod</code> <code>download</code> behave as if in a
  135. module with initially-empty requirements.
  136. In this mode, <code>go</code> <code>env</code> <code>GOMOD</code> reports
  137. the system's null device (<code>/dev/null</code> or <code>NUL</code>).
  138. </p>
  139. <p><!-- CL 146382 -->
  140. <code>go</code> commands that download and extract modules are now safe to
  141. invoke concurrently.
  142. The module cache (<code>GOPATH/pkg/mod</code>) must reside in a filesystem that
  143. supports file locking.
  144. </p>
  145. <p><!-- CL 147282, 147281 -->
  146. The <code>go</code> directive in a <code>go.mod</code> file now indicates the
  147. version of the language used by the files within that module.
  148. It will be set to the current release
  149. (<code>go</code> <code>1.12</code>) if no existing version is
  150. present.
  151. If the <code>go</code> directive for a module specifies a
  152. version <em>newer</em> than the toolchain in use, the <code>go</code> command
  153. will attempt to build the packages regardless, and will note the mismatch only if
  154. that build fails.
  155. </p>
  156. <p><!-- CL 147282, 147281 -->
  157. This changed use of the <code>go</code> directive means that if you
  158. use Go 1.12 to build a module, thus recording <code>go 1.12</code>
  159. in the <code>go.mod</code> file, you will get an error when
  160. attempting to build the same module with Go 1.11 through Go 1.11.3.
  161. Go 1.11.4 or later will work fine, as will releases older than Go 1.11.
  162. If you must use Go 1.11 through 1.11.3, you can avoid the problem by
  163. setting the language version to 1.11, using the Go 1.12 go tool,
  164. via <code>go mod edit -go=1.11</code>.
  165. </p>
  166. <p><!-- CL 152739 -->
  167. When an import cannot be resolved using the active modules,
  168. the <code>go</code> command will now try to use the modules mentioned in the
  169. main module's <code>replace</code> directives before consulting the module
  170. cache and the usual network sources.
  171. If a matching replacement is found but the <code>replace</code> directive does
  172. not specify a version, the <code>go</code> command uses a pseudo-version
  173. derived from the zero <code>time.Time</code> (such
  174. as <code>v0.0.0-00010101000000-000000000000</code>).
  175. </p>
  176. <h3 id="compiler">Compiler toolchain</h3>
  177. <p><!-- CL 134155, 134156 -->
  178. The compiler's live variable analysis has improved. This may mean that
  179. finalizers will be executed sooner in this release than in previous
  180. releases. If that is a problem, consider the appropriate addition of a
  181. <a href="/pkg/runtime/#KeepAlive"><code>runtime.KeepAlive</code></a> call.
  182. </p>
  183. <p><!-- CL 147361 -->
  184. More functions are now eligible for inlining by default, including
  185. functions that do nothing but call another function.
  186. This extra inlining makes it additionally important to use
  187. <a href="/pkg/runtime/#CallersFrames"><code>runtime.CallersFrames</code></a>
  188. instead of iterating over the result of
  189. <a href="/pkg/runtime/#Callers"><code>runtime.Callers</code></a> directly.
  190. <pre>
  191. // Old code which no longer works correctly (it will miss inlined call frames).
  192. var pcs [10]uintptr
  193. n := runtime.Callers(1, pcs[:])
  194. for _, pc := range pcs[:n] {
  195. f := runtime.FuncForPC(pc)
  196. if f != nil {
  197. fmt.Println(f.Name())
  198. }
  199. }
  200. </pre>
  201. <pre>
  202. // New code which will work correctly.
  203. var pcs [10]uintptr
  204. n := runtime.Callers(1, pcs[:])
  205. frames := runtime.CallersFrames(pcs[:n])
  206. for {
  207. frame, more := frames.Next()
  208. fmt.Println(frame.Function)
  209. if !more {
  210. break
  211. }
  212. }
  213. </pre>
  214. </p>
  215. <p><!-- CL 153477 -->
  216. Wrappers generated by the compiler to implement method expressions
  217. are no longer reported
  218. by <a href="/pkg/runtime/#CallersFrames"><code>runtime.CallersFrames</code></a>
  219. and <a href="/pkg/runtime/#Stack"><code>runtime.Stack</code></a>. They
  220. are also not printed in panic stack traces.
  221. This change aligns the <code>gc</code> toolchain to match
  222. the <code>gccgo</code> toolchain, which already elided such wrappers
  223. from stack traces.
  224. Clients of these APIs might need to adjust for the missing
  225. frames. For code that must interoperate between 1.11 and 1.12
  226. releases, you can replace the method expression <code>x.M</code>
  227. with the function literal <code>func (...) { x.M(...) } </code>.
  228. </p>
  229. <p><!-- CL 144340 -->
  230. The compiler now accepts a <code>-lang</code> flag to set the Go language
  231. version to use. For example, <code>-lang=go1.8</code> causes the compiler to
  232. emit an error if the program uses type aliases, which were added in Go 1.9.
  233. Language changes made before Go 1.12 are not consistently enforced.
  234. </p>
  235. <p><!-- CL 147160 -->
  236. The compiler toolchain now uses different conventions to call Go
  237. functions and assembly functions. This should be invisible to users,
  238. except for calls that simultaneously cross between Go and
  239. assembly <em>and</em> cross a package boundary. If linking results
  240. in an error like "relocation target not defined for ABIInternal (but
  241. is defined for ABI0)", please refer to the
  242. <a href="https://github.com/golang/proposal/blob/master/design/27539-internal-abi.md#compatibility">compatibility section</a>
  243. of the ABI design document.
  244. </p>
  245. <p><!-- CL 145179 -->
  246. There have been many improvements to the DWARF debug information
  247. produced by the compiler, including improvements to argument
  248. printing and variable location information.
  249. </p>
  250. <p><!-- CL 61511 -->
  251. Go programs now also maintain stack frame pointers on <code>linux/arm64</code>
  252. for the benefit of profiling tools like <code>perf</code>. The frame pointer
  253. maintenance has a small run-time overhead that varies but averages around 3%.
  254. To build a toolchain that does not use frame pointers, set
  255. <code>GOEXPERIMENT=noframepointer</code> when running <code>make.bash</code>.
  256. </p>
  257. <p><!-- CL 142717 -->
  258. The obsolete "safe" compiler mode (enabled by the <code>-u</code> gcflag) has been removed.
  259. </p>
  260. <h3 id="godoc"><code>godoc</code> and <code>go</code> <code>doc</code></h3>
  261. <p>
  262. In Go 1.12, <code>godoc</code> no longer has a command-line interface and
  263. is only a web server. Users should use <code>go</code> <code>doc</code>
  264. for command-line help output instead. Go 1.12 is the last release that will
  265. include the <code>godoc</code> webserver; in Go 1.13 it will be available
  266. via <code>go</code> <code>get</code>.
  267. </p>
  268. <p><!-- CL 141977 -->
  269. <code>go</code> <code>doc</code> now supports the <code>-all</code> flag,
  270. which will cause it to print all exported APIs and their documentation,
  271. as the <code>godoc</code> command line used to do.
  272. </p>
  273. <p><!-- CL 140959 -->
  274. <code>go</code> <code>doc</code> also now includes the <code>-src</code> flag,
  275. which will show the target's source code.
  276. </p>
  277. <h3 id="trace">Trace</h3>
  278. <p><!-- CL 60790 -->
  279. The trace tool now supports plotting mutator utilization curves,
  280. including cross-references to the execution trace. These are useful
  281. for analyzing the impact of the garbage collector on application
  282. latency and throughput.
  283. </p>
  284. <h3 id="assembler">Assembler</h3>
  285. <p><!-- CL 147218 -->
  286. On <code>arm64</code>, the platform register was renamed from
  287. <code>R18</code> to <code>R18_PLATFORM</code> to prevent accidental
  288. use, as the OS could choose to reserve this register.
  289. </p>
  290. <h2 id="runtime">Runtime</h2>
  291. <p><!-- CL 138959 -->
  292. Go 1.12 significantly improves the performance of sweeping when a
  293. large fraction of the heap remains live. This reduces allocation
  294. latency immediately following a garbage collection.
  295. </p>
  296. <p><!-- CL 139719 -->
  297. The Go runtime now releases memory back to the operating system more
  298. aggressively, particularly in response to large allocations that
  299. can't reuse existing heap space.
  300. </p>
  301. <p><!-- CL 146342, CL 146340, CL 146345, CL 146339, CL 146343, CL 146337, CL 146341, CL 146338 -->
  302. The Go runtime's timer and deadline code is faster and scales better
  303. with higher numbers of CPUs. In particular, this improves the
  304. performance of manipulating network connection deadlines.
  305. </p>
  306. <p><!-- CL 135395 -->
  307. On Linux, the runtime now uses <code>MADV_FREE</code> to release unused
  308. memory. This is more efficient but may result in higher reported
  309. RSS. The kernel will reclaim the unused data when it is needed.
  310. To revert to the Go 1.11 behavior (<code>MADV_DONTNEED</code>), set the
  311. environment variable <code>GODEBUG=madvdontneed=1</code>.
  312. </p>
  313. <p><!-- CL 149578 -->
  314. Adding cpu.<em>extension</em>=off to the
  315. <a href="/doc/diagnostics.html#godebug">GODEBUG</a> environment
  316. variable now disables the use of optional CPU instruction
  317. set extensions in the standard library and runtime. This is not
  318. yet supported on Windows.
  319. </p>
  320. <p><!-- CL 158337 -->
  321. Go 1.12 improves the accuracy of memory profiles by fixing
  322. overcounting of large heap allocations.
  323. </p>
  324. <p><!-- CL 159717 -->
  325. Tracebacks, <code>runtime.Caller</code>,
  326. and <code>runtime.Callers</code> no longer include
  327. compiler-generated initialization functions. Doing a traceback
  328. during the initialization of a global variable will now show a
  329. function named <code>PKG.init.ializers</code>.
  330. </p>
  331. <h2 id="library">Core library</h2>
  332. <h3 id="tls_1_3">TLS 1.3</h3>
  333. <p>
  334. Go 1.12 adds opt-in support for TLS 1.3 in the <code>crypto/tls</code> package as
  335. specified by <a href="https://www.rfc-editor.org/info/rfc8446">RFC 8446</a>. It can
  336. be enabled by adding the value <code>tls13=1</code> to the <code>GODEBUG</code>
  337. environment variable. It will be enabled by default in Go 1.13.
  338. </p>
  339. <p>
  340. To negotiate TLS 1.3, make sure you do not set an explicit <code>MaxVersion</code> in
  341. <a href="/pkg/crypto/tls/#Config"><code>Config</code></a> and run your program with
  342. the environment variable <code>GODEBUG=tls13=1</code> set.
  343. </p>
  344. <p>
  345. All TLS 1.2 features except <code>TLSUnique</code> in
  346. <a href="/pkg/crypto/tls/#ConnectionState"><code>ConnectionState</code></a>
  347. and renegotiation are available in TLS 1.3 and provide equivalent or
  348. better security and performance. Note that even though TLS 1.3 is backwards
  349. compatible with previous versions, certain legacy systems might not work
  350. correctly when attempting to negotiate it. RSA certificate keys too small
  351. to be secure (including 512-bit keys) will not work with TLS 1.3.
  352. </p>
  353. <p>
  354. TLS 1.3 cipher suites are not configurable. All supported cipher suites are
  355. safe, and if <code>PreferServerCipherSuites</code> is set in
  356. <a href="/pkg/crypto/tls/#Config"><code>Config</code></a> the preference order
  357. is based on the available hardware.
  358. </p>
  359. <p>
  360. Early data (also called "0-RTT mode") is not currently supported as a
  361. client or server. Additionally, a Go 1.12 server does not support skipping
  362. unexpected early data if a client sends it. Since TLS 1.3 0-RTT mode
  363. involves clients keeping state regarding which servers support 0-RTT,
  364. a Go 1.12 server cannot be part of a load-balancing pool where some other
  365. servers do support 0-RTT. If switching a domain from a server that supported
  366. 0-RTT to a Go 1.12 server, 0-RTT would have to be disabled for at least the
  367. lifetime of the issued session tickets before the switch to ensure
  368. uninterrupted operation.
  369. </p>
  370. <p>
  371. In TLS 1.3 the client is the last one to speak in the handshake, so if it causes
  372. an error to occur on the server, it will be returned on the client by the first
  373. <a href="/pkg/crypto/tls/#Conn.Read"><code>Read</code></a>, not by
  374. <a href="/pkg/crypto/tls/#Conn.Handshake"><code>Handshake</code></a>. For
  375. example, that will be the case if the server rejects the client certificate.
  376. Similarly, session tickets are now post-handshake messages, so are only
  377. received by the client upon its first
  378. <a href="/pkg/crypto/tls/#Conn.Read"><code>Read</code></a>.
  379. </p>
  380. <h3 id="minor_library_changes">Minor changes to the library</h3>
  381. <p>
  382. As always, there are various minor changes and updates to the library,
  383. made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a>
  384. in mind.
  385. </p>
  386. <!-- TODO: CL 115677: https://golang.org/cl/115677: cmd/vet: check embedded field tags too -->
  387. <dl id="bufio"><dt><a href="/pkg/bufio/">bufio</a></dt>
  388. <dd>
  389. <p><!-- CL 149297 -->
  390. <code>Reader</code>'s <a href="/pkg/bufio/#Reader.UnreadRune"><code>UnreadRune</code></a> and
  391. <a href="/pkg/bufio/#Reader.UnreadByte"><code>UnreadByte</code></a> methods will now return an error
  392. if they are called after <a href="/pkg/bufio/#Reader.Peek"><code>Peek</code></a>.
  393. </p>
  394. </dl><!-- bufio -->
  395. <dl id="bytes"><dt><a href="/pkg/bytes/">bytes</a></dt>
  396. <dd>
  397. <p><!-- CL 137855 -->
  398. The new function <a href="/pkg/bytes/#ReplaceAll"><code>ReplaceAll</code></a> returns a copy of
  399. a byte slice with all non-overlapping instances of a value replaced by another.
  400. </p>
  401. <p><!-- CL 145098 -->
  402. A pointer to a zero-value <a href="/pkg/bytes/#Reader"><code>Reader</code></a> is now
  403. functionally equivalent to <a href="/pkg/bytes/#NewReader"><code>NewReader</code></a><code>(nil)</code>.
  404. Prior to Go 1.12, the former could not be used as a substitute for the latter in all cases.
  405. </p>
  406. </dl><!-- bytes -->
  407. <dl id="crypto/rand"><dt><a href="/pkg/crypto/rand/">crypto/rand</a></dt>
  408. <dd>
  409. <p><!-- CL 139419 -->
  410. A warning will now be printed to standard error the first time
  411. <code>Reader.Read</code> is blocked for more than 60 seconds waiting
  412. to read entropy from the kernel.
  413. </p>
  414. <p><!-- CL 120055 -->
  415. On FreeBSD, <code>Reader</code> now uses the <code>getrandom</code>
  416. system call if available, <code>/dev/urandom</code> otherwise.
  417. </p>
  418. </dl><!-- crypto/rand -->
  419. <dl id="crypto/rc4"><dt><a href="/pkg/crypto/rc4/">crypto/rc4</a></dt>
  420. <dd>
  421. <p><!-- CL 130397 -->
  422. This release removes the assembly implementations, leaving only
  423. the pure Go version. The Go compiler generates code that is
  424. either slightly better or slightly worse, depending on the exact
  425. CPU. RC4 is insecure and should only be used for compatibility
  426. with legacy systems.
  427. </p>
  428. </dl><!-- crypto/rc4 -->
  429. <dl id="crypto/tls"><dt><a href="/pkg/crypto/tls/">crypto/tls</a></dt>
  430. <dd>
  431. <p><!-- CL 143177 -->
  432. If a client sends an initial message that does not look like TLS, the server
  433. will no longer reply with an alert, and it will expose the underlying
  434. <code>net.Conn</code> in the new field <code>Conn</code> of
  435. <a href="/pkg/crypto/tls/#RecordHeaderError"><code>RecordHeaderError</code></a>.
  436. </p>
  437. </dl><!-- crypto/tls -->
  438. <dl id="database/sql"><dt><a href="/pkg/database/sql/">database/sql</a></dt>
  439. <dd>
  440. <p><!-- CL 145738 -->
  441. A query cursor can now be obtained by passing a
  442. <a href="/pkg/database/sql/#Rows"><code>*Rows</code></a>
  443. value to the <a href="/pkg/database/sql/#Row.Scan"><code>Row.Scan</code></a> method.
  444. </p>
  445. </dl><!-- database/sql -->
  446. <dl id="expvar"><dt><a href="/pkg/expvar/">expvar</a></dt>
  447. <dd>
  448. <p><!-- CL 139537 -->
  449. The new <a href="/pkg/expvar/#Map.Delete"><code>Delete</code></a> method allows
  450. for deletion of key/value pairs from a <a href="/pkg/expvar/#Map"><code>Map</code></a>.
  451. </p>
  452. </dl><!-- expvar -->
  453. <dl id="fmt"><dt><a href="/pkg/fmt/">fmt</a></dt>
  454. <dd>
  455. <p><!-- CL 142737 -->
  456. Maps are now printed in key-sorted order to ease testing. The ordering rules are:
  457. <ul>
  458. <li>When applicable, nil compares low
  459. <li>ints, floats, and strings order by <
  460. <li>NaN compares less than non-NaN floats
  461. <li>bool compares false before true
  462. <li>Complex compares real, then imaginary
  463. <li>Pointers compare by machine address
  464. <li>Channel values compare by machine address
  465. <li>Structs compare each field in turn
  466. <li>Arrays compare each element in turn
  467. <li>Interface values compare first by <code>reflect.Type</code> describing the concrete type
  468. and then by concrete value as described in the previous rules.
  469. </ul>
  470. </p>
  471. <p><!-- CL 129777 -->
  472. When printing maps, non-reflexive key values like <code>NaN</code> were previously
  473. displayed as <code>&lt;nil&gt;</code>. As of this release, the correct values are printed.
  474. </p>
  475. </dl><!-- fmt -->
  476. <dl id="go/doc"><dt><a href="/pkg/go/doc/">go/doc</a></dt>
  477. <dd>
  478. <p><!-- CL 140958 -->
  479. To address some outstanding issues in <a href="/cmd/doc/"><code>cmd/doc</code></a>,
  480. this package has a new <a href="/pkg/go/doc/#Mode"><code>Mode</code></a> bit,
  481. <code>PreserveAST</code>, which controls whether AST data is cleared.
  482. </p>
  483. </dl><!-- go/doc -->
  484. <dl id="go/token"><dt><a href="/pkg/go/token/">go/token</a></dt>
  485. <dd>
  486. <p><!-- CL 134075 -->
  487. The <a href="/pkg/go/token#File"><code>File</code></a> type has a new
  488. <a href="/pkg/go/token#File.LineStart"><code>LineStart</code></a> field,
  489. which returns the position of the start of a given line. This is especially useful
  490. in programs that occasionally handle non-Go files, such as assembly, but wish to use
  491. the <code>token.Pos</code> mechanism to identify file positions.
  492. </p>
  493. </dl><!-- go/token -->
  494. <dl id="image"><dt><a href="/pkg/image/">image</a></dt>
  495. <dd>
  496. <p><!-- CL 118755 -->
  497. The <a href="/pkg/image/#RegisterFormat"><code>RegisterFormat</code></a> function is now safe for concurrent use.
  498. </p>
  499. </dl><!-- image -->
  500. <dl id="image/png"><dt><a href="/pkg/image/png/">image/png</a></dt>
  501. <dd>
  502. <p><!-- CL 134235 -->
  503. Paletted images with fewer than 16 colors now encode to smaller outputs.
  504. </p>
  505. </dl><!-- image/png -->
  506. <dl id="io"><dt><a href="/pkg/io/">io</a></dt>
  507. <dd>
  508. <p><!-- CL 139457 -->
  509. The new <a href="/pkg/io#StringWriter"><code>StringWriter</code></a> interface wraps the
  510. <a href="/pkg/io/#WriteString"><code>WriteString</code></a> function.
  511. </p>
  512. </dl><!-- io -->
  513. <dl id="math"><dt><a href="/pkg/math/">math</a></dt>
  514. <dd>
  515. <p><!-- CL 153059 -->
  516. The functions
  517. <a href="/pkg/math/#Sin"><code>Sin</code></a>,
  518. <a href="/pkg/math/#Cos"><code>Cos</code></a>,
  519. <a href="/pkg/math/#Tan"><code>Tan</code></a>,
  520. and <a href="/pkg/math/#Sincos"><code>Sincos</code></a> now
  521. apply Payne-Hanek range reduction to huge arguments. This
  522. produces more accurate answers, but they will not be bit-for-bit
  523. identical with the results in earlier releases.
  524. </p>
  525. </dl><!-- math -->
  526. <dl id="math/bits"><dt><a href="/pkg/math/bits/">math/bits</a></dt>
  527. <dd>
  528. <p><!-- CL 123157 -->
  529. New extended precision operations <a href="/pkg/math/bits/#Add"><code>Add</code></a>, <a href="/pkg/math/bits/#Sub"><code>Sub</code></a>, <a href="/pkg/math/bits/#Mul"><code>Mul</code></a>, and <a href="/pkg/math/bits/#Div"><code>Div</code></a> are available in <code>uint</code>, <code>uint32</code>, and <code>uint64</code> versions.
  530. </p>
  531. </dl><!-- math/bits -->
  532. <dl id="net"><dt><a href="/pkg/net/">net</a></dt>
  533. <dd>
  534. <p><!-- CL 146659 -->
  535. The
  536. <a href="/pkg/net/#Dialer.DualStack"><code>Dialer.DualStack</code></a> setting is now ignored and deprecated;
  537. RFC 6555 Fast Fallback ("Happy Eyeballs") is now enabled by default. To disable, set
  538. <a href="/pkg/net/#Dialer.FallbackDelay"><code>Dialer.FallbackDelay</code></a> to a negative value.
  539. </p>
  540. <p><!-- CL 107196 -->
  541. Similarly, TCP keep-alives are now enabled by default if
  542. <a href="/pkg/net/#Dialer.KeepAlive"><code>Dialer.KeepAlive</code></a> is zero.
  543. To disable, set it to a negative value.
  544. </p>
  545. <p><!-- CL 113997 -->
  546. On Linux, the <a href="http://man7.org/linux/man-pages/man2/splice.2.html"><code>splice</code> system call</a> is now used when copying from a
  547. <a href="/pkg/net/#UnixConn"><code>UnixConn</code></a> to a
  548. <a href="/pkg/net/#TCPConn"><code>TCPConn</code></a>.
  549. </p>
  550. </dl><!-- net -->
  551. <dl id="net/http"><dt><a href="/pkg/net/http/">net/http</a></dt>
  552. <dd>
  553. <p><!-- CL 143177 -->
  554. The HTTP server now rejects misdirected HTTP requests to HTTPS servers with a plaintext "400 Bad Request" response.
  555. </p>
  556. <p><!-- CL 130115 -->
  557. The new <a href="/pkg/net/http/#Client.CloseIdleConnections"><code>Client.CloseIdleConnections</code></a>
  558. method calls the <code>Client</code>'s underlying <code>Transport</code>'s <code>CloseIdleConnections</code>
  559. if it has one.
  560. </p>
  561. <p><!-- CL 145398 -->
  562. The <a href="/pkg/net/http/#Transport"><code>Transport</code></a> no longer rejects HTTP responses which declare
  563. HTTP Trailers but don't use chunked encoding. Instead, the declared trailers are now just ignored.
  564. </p>
  565. <p><!-- CL 152080 --> <!-- CL 151857 -->
  566. The <a href="/pkg/net/http/#Transport"><code>Transport</code></a> no longer handles <code>MAX_CONCURRENT_STREAMS</code> values
  567. advertised from HTTP/2 servers as strictly as it did during Go 1.10 and Go 1.11. The default behavior is now back
  568. to how it was in Go 1.9: each connection to a server can have up to <code>MAX_CONCURRENT_STREAMS</code> requests
  569. active and then new TCP connections are created as needed. In Go 1.10 and Go 1.11 the <code>http2</code> package
  570. would block and wait for requests to finish instead of creating new connections.
  571. To get the stricter behavior back, import the
  572. <a href="https://godoc.org/golang.org/x/net/http2"><code>golang.org/x/net/http2</code></a> package
  573. directly and set
  574. <a href="https://godoc.org/golang.org/x/net/http2#Transport.StrictMaxConcurrentStreams"><code>Transport.StrictMaxConcurrentStreams</code></a> to
  575. <code>true</code>.
  576. </p>
  577. </dl><!-- net/http -->
  578. <dl id="net/url"><dt><a href="/pkg/net/url/">net/url</a></dt>
  579. <dd>
  580. <p><!-- CL 159157, CL 160178 -->
  581. <a href="/pkg/net/url/#Parse"><code>Parse</code></a>,
  582. <a href="/pkg/net/url/#ParseRequestURI"><code>ParseRequestURI</code></a>,
  583. and
  584. <a href="/pkg/net/url/#URL.Parse"><code>URL.Parse</code></a>
  585. now return an
  586. error for URLs containing ASCII control characters, which includes NULL,
  587. tab, and newlines.
  588. </p>
  589. </dl><!-- net/url -->
  590. <dl id="net/http/httputil"><dt><a href="/pkg/net/http/httputil/">net/http/httputil</a></dt>
  591. <dd>
  592. <p><!-- CL 146437 -->
  593. The <a href="/pkg/net/http/httputil/#ReverseProxy"><code>ReverseProxy</code></a> now automatically
  594. proxies WebSocket requests.
  595. </p>
  596. </dl><!-- net/http/httputil -->
  597. <dl id="os"><dt><a href="/pkg/os/">os</a></dt>
  598. <dd>
  599. <p><!-- CL 125443 -->
  600. The new <a href="/pkg/os/#ProcessState.ExitCode"><code>ProcessState.ExitCode</code></a> method
  601. returns the process's exit code.
  602. </p>
  603. <p><!-- CL 135075 -->
  604. <code>ModeCharDevice</code> has been added to the <code>ModeType</code> bitmask, allowing for
  605. <code>ModeDevice | ModeCharDevice</code> to be recovered when masking a
  606. <a href="/pkg/os/#FileMode"><code>FileMode</code></a> with <code>ModeType</code>.
  607. </p>
  608. <p><!-- CL 139418 -->
  609. The new function <a href="/pkg/os/#UserHomeDir"><code>UserHomeDir</code></a> returns the
  610. current user's home directory.
  611. </p>
  612. <p><!-- CL 146020 -->
  613. <a href="/pkg/os/#RemoveAll"><code>RemoveAll</code></a> now supports paths longer than 4096 characters
  614. on most Unix systems.
  615. </p>
  616. <p><!-- CL 130676 -->
  617. <a href="/pkg/os/#File.Sync"><code>File.Sync</code></a> now uses <code>F_FULLFSYNC</code> on macOS
  618. to correctly flush the file contents to permanent storage.
  619. This may cause the method to run more slowly than in previous releases.
  620. </p>
  621. <p><!--CL 155517 -->
  622. <a href="/pkg/os/#File"><code>File</code></a> now supports
  623. a <a href="/pkg/os/#File.SyscallConn"><code>SyscallConn</code></a>
  624. method returning
  625. a <a href="/pkg/syscall/#RawConn"><code>syscall.RawConn</code></a>
  626. interface value. This may be used to invoke system-specific
  627. operations on the underlying file descriptor.
  628. </p>
  629. </dl><!-- os -->
  630. <dl id="path/filepath"><dt><a href="/pkg/path/filepath/">path/filepath</a></dt>
  631. <dd>
  632. <p><!-- CL 145220 -->
  633. The <a href="/pkg/path/filepath/#IsAbs"><code>IsAbs</code></a> function now returns true when passed
  634. a reserved filename on Windows such as <code>NUL</code>.
  635. <a href="https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#naming-conventions">List of reserved names.</a>
  636. </p>
  637. </dl><!-- path/filepath -->
  638. <dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt>
  639. <dd>
  640. <p><!-- CL 33572 -->
  641. A new <a href="/pkg/reflect#MapIter"><code>MapIter</code></a> type is
  642. an iterator for ranging over a map. This type is exposed through the
  643. <a href="/pkg/reflect#Value"><code>Value</code></a> type's new
  644. <a href="/pkg/reflect#Value.MapRange"><code>MapRange</code></a> method.
  645. This follows the same iteration semantics as a range statement, with <code>Next</code>
  646. to advance the iterator, and <code>Key</code>/<code>Value</code> to access each entry.
  647. </p>
  648. </dl><!-- reflect -->
  649. <dl id="regexp"><dt><a href="/pkg/regexp/">regexp</a></dt>
  650. <dd>
  651. <p><!-- CL 139784 -->
  652. <a href="/pkg/regexp/#Regexp.Copy"><code>Copy</code></a> is no longer necessary
  653. to avoid lock contention, so it has been given a partial deprecation comment.
  654. <a href="/pkg/regexp/#Regexp.Copy"><code>Copy</code></a>
  655. may still be appropriate if the reason for its use is to make two copies with
  656. different <a href="/pkg/regexp/#Regexp.Longest"><code>Longest</code></a> settings.
  657. </p>
  658. </dl><!-- regexp -->
  659. <dl id="runtime/debug"><dt><a href="/pkg/runtime/debug/">runtime/debug</a></dt>
  660. <dd>
  661. <p><!-- CL 144220 -->
  662. A new <a href="/pkg/runtime/debug/#BuildInfo"><code>BuildInfo</code></a> type
  663. exposes the build information read from the running binary, available only in
  664. binaries built with module support. This includes the main package path, main
  665. module information, and the module dependencies. This type is given through the
  666. <a href="/pkg/runtime/debug/#ReadBuildInfo"><code>ReadBuildInfo</code></a> function
  667. on <a href="/pkg/runtime/debug/#BuildInfo"><code>BuildInfo</code></a>.
  668. </p>
  669. </dl><!-- runtime/debug -->
  670. <dl id="strings"><dt><a href="/pkg/strings/">strings</a></dt>
  671. <dd>
  672. <p><!-- CL 137855 -->
  673. The new function <a href="/pkg/strings/#ReplaceAll"><code>ReplaceAll</code></a> returns a copy of
  674. a string with all non-overlapping instances of a value replaced by another.
  675. </p>
  676. <p><!-- CL 145098 -->
  677. A pointer to a zero-value <a href="/pkg/strings/#Reader"><code>Reader</code></a> is now
  678. functionally equivalent to <a href="/pkg/strings/#NewReader"><code>NewReader</code></a><code>(nil)</code>.
  679. Prior to Go 1.12, the former could not be used as a substitute for the latter in all cases.
  680. </p>
  681. <p><!-- CL 122835 -->
  682. The new <a href="/pkg/strings/#Builder.Cap"><code>Builder.Cap</code></a> method returns the capacity of the builder's underlying byte slice.
  683. </p>
  684. <p><!-- CL 131495 -->
  685. The character mapping functions <a href="/pkg/strings/#Map"><code>Map</code></a>,
  686. <a href="/pkg/strings/#Title"><code>Title</code></a>,
  687. <a href="/pkg/strings/#ToLower"><code>ToLower</code></a>,
  688. <a href="/pkg/strings/#ToLowerSpecial"><code>ToLowerSpecial</code></a>,
  689. <a href="/pkg/strings/#ToTitle"><code>ToTitle</code></a>,
  690. <a href="/pkg/strings/#ToTitleSpecial"><code>ToTitleSpecial</code></a>,
  691. <a href="/pkg/strings/#ToUpper"><code>ToUpper</code></a>, and
  692. <a href="/pkg/strings/#ToUpperSpecial"><code>ToUpperSpecial</code></a>
  693. now always guarantee to return valid UTF-8. In earlier releases, if the input was invalid UTF-8 but no character replacements
  694. needed to be applied, these routines incorrectly returned the invalid UTF-8 unmodified.
  695. </p>
  696. </dl><!-- strings -->
  697. <dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt>
  698. <dd>
  699. <p><!-- CL 138595 -->
  700. 64-bit inodes are now supported on FreeBSD 12. Some types have been adjusted accordingly.
  701. </p>
  702. <p><!-- CL 125456 -->
  703. The Unix socket
  704. (<a href="https://blogs.msdn.microsoft.com/commandline/2017/12/19/af_unix-comes-to-windows/"><code>AF_UNIX</code></a>)
  705. address family is now supported for compatible versions of Windows.
  706. </p>
  707. <p><!-- CL 147117 -->
  708. The new function <a href="/pkg/syscall/?GOOS=windows&GOARCH=amd64#Syscall18"><code>Syscall18</code></a>
  709. has been introduced for Windows, allowing for calls with up to 18 arguments.
  710. </p>
  711. </dl><!-- syscall -->
  712. <dl id="syscall/js"><dt><a href="/pkg/syscall/js/">syscall/js</a></dt>
  713. <dd>
  714. <p><!-- CL 153559 -->
  715. <p>
  716. The <code>Callback</code> type and <code>NewCallback</code> function have been renamed;
  717. they are now called
  718. <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Func"><code>Func</code></a> and
  719. <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#FuncOf"><code>FuncOf</code></a>, respectively.
  720. This is a breaking change, but WebAssembly support is still experimental
  721. and not yet subject to the
  722. <a href="/doc/go1compat">Go 1 compatibility promise</a>. Any code using the
  723. old names will need to be updated.
  724. </p>
  725. <p><!-- CL 141644 -->
  726. If a type implements the new
  727. <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Wrapper"><code>Wrapper</code></a>
  728. interface,
  729. <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#ValueOf"><code>ValueOf</code></a>
  730. will use it to return the JavaScript value for that type.
  731. </p>
  732. <p><!-- CL 143137 -->
  733. The meaning of the zero
  734. <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Value"><code>Value</code></a>
  735. has changed. It now represents the JavaScript <code>undefined</code> value
  736. instead of the number zero.
  737. This is a breaking change, but WebAssembly support is still experimental
  738. and not yet subject to the
  739. <a href="/doc/go1compat">Go 1 compatibility promise</a>. Any code relying on
  740. the zero <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Value"><code>Value</code></a>
  741. to mean the number zero will need to be updated.
  742. </p>
  743. <p><!-- CL 144384 -->
  744. The new
  745. <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Value.Truthy"><code>Value.Truthy</code></a>
  746. method reports the
  747. <a href="https://developer.mozilla.org/en-US/docs/Glossary/Truthy">JavaScript "truthiness"</a>
  748. of a given value.
  749. </p>
  750. </dl><!-- syscall/js -->
  751. <dl id="testing"><dt><a href="/pkg/testing/">testing</a></dt>
  752. <dd>
  753. <p><!-- CL 139258 -->
  754. The <a href="/cmd/go/#hdr-Testing_flags"><code>-benchtime</code></a> flag now supports setting an explicit iteration count instead of a time when the value ends with an "<code>x</code>". For example, <code>-benchtime=100x</code> runs the benchmark 100 times.
  755. </p>
  756. </dl><!-- testing -->
  757. <dl id="text/template"><dt><a href="/pkg/text/template/">text/template</a></dt>
  758. <dd>
  759. <p><!-- CL 142217 -->
  760. When executing a template, long context values are no longer truncated in errors.
  761. </p>
  762. <p>
  763. <code>executing "tmpl" at <.very.deep.context.v...>: map has no entry for key "notpresent"</code>
  764. </p>
  765. <p>
  766. is now
  767. </p>
  768. <p>
  769. <code>executing "tmpl" at <.very.deep.context.value.notpresent>: map has no entry for key "notpresent"</code>
  770. </p>
  771. <dd>
  772. <p><!-- CL 143097 -->
  773. If a user-defined function called by a template panics, the
  774. panic is now caught and returned as an error by
  775. the <code>Execute</code> or <code>ExecuteTemplate</code> method.
  776. </p>
  777. </dl><!-- text/template -->
  778. <dl id="time"><dt><a href="/pkg/time/">time</a></dt>
  779. <dd>
  780. <p><!-- CL 151299 -->
  781. The time zone database in <code>$GOROOT/lib/time/zoneinfo.zip</code>
  782. has been updated to version 2018i. Note that this ZIP file is
  783. only used if a time zone database is not provided by the operating
  784. system.
  785. </p>
  786. </dl><!-- time -->
  787. <dl id="unsafe"><dt><a href="/pkg/unsafe/">unsafe</a></dt>
  788. <dd>
  789. <p><!-- CL 146058 -->
  790. It is invalid to convert a nil <code>unsafe.Pointer</code> to <code>uintptr</code> and back with arithmetic.
  791. (This was already invalid, but will now cause the compiler to misbehave.)
  792. </p>
  793. </dl><!-- unsafe -->