go1.1.html 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  1. <!--{
  2. "Title": "Go 1.1 Release Notes",
  3. "Path": "/doc/go1.1",
  4. "Template": true
  5. }-->
  6. <h2 id="introduction">Introduction to Go 1.1</h2>
  7. <p>
  8. The release of <a href="/doc/go1.html">Go version 1</a> (Go 1 or Go 1.0 for short)
  9. in March of 2012 introduced a new period
  10. of stability in the Go language and libraries.
  11. That stability has helped nourish a growing community of Go users
  12. and systems around the world.
  13. Several "point" releases since
  14. then—1.0.1, 1.0.2, and 1.0.3—have been issued.
  15. These point releases fixed known bugs but made
  16. no non-critical changes to the implementation.
  17. </p>
  18. <p>
  19. This new release, Go 1.1, keeps the <a href="/doc/go1compat.html">promise
  20. of compatibility</a> but adds a couple of significant
  21. (backwards-compatible, of course) language changes, has a long list
  22. of (again, compatible) library changes, and
  23. includes major work on the implementation of the compilers,
  24. libraries, and run-time.
  25. The focus is on performance.
  26. Benchmarking is an inexact science at best, but we see significant,
  27. sometimes dramatic speedups for many of our test programs.
  28. We trust that many of our users' programs will also see improvements
  29. just by updating their Go installation and recompiling.
  30. </p>
  31. <p>
  32. This document summarizes the changes between Go 1 and Go 1.1.
  33. Very little if any code will need modification to run with Go 1.1,
  34. although a couple of rare error cases surface with this release
  35. and need to be addressed if they arise.
  36. Details appear below; see the discussion of
  37. <a href="#int">64-bit ints</a> and <a href="#unicode_literals">Unicode literals</a>
  38. in particular.
  39. </p>
  40. <h2 id="language">Changes to the language</h2>
  41. <p>
  42. <a href="/doc/go1compat.html">The Go compatibility document</a> promises
  43. that programs written to the Go 1 language specification will continue to operate,
  44. and those promises are maintained.
  45. In the interest of firming up the specification, though, there are
  46. details about some error cases that have been clarified.
  47. There are also some new language features.
  48. </p>
  49. <h3 id="divzero">Integer division by zero</h3>
  50. <p>
  51. In Go 1, integer division by a constant zero produced a run-time panic:
  52. </p>
  53. <pre>
  54. func f(x int) int {
  55. return x/0
  56. }
  57. </pre>
  58. <p>
  59. In Go 1.1, an integer division by constant zero is not a legal program, so it is a compile-time error.
  60. </p>
  61. <h3 id="unicode_literals">Surrogates in Unicode literals</h3>
  62. <p>
  63. The definition of string and rune literals has been refined to exclude surrogate halves from the
  64. set of valid Unicode code points.
  65. See the <a href="#unicode">Unicode</a> section for more information.
  66. </p>
  67. <h3 id="method_values">Method values</h3>
  68. <p>
  69. Go 1.1 now implements
  70. <a href="/ref/spec#Method_values">method values</a>,
  71. which are functions that have been bound to a specific receiver value.
  72. For instance, given a
  73. <a href="/pkg/bufio/#Writer"><code>Writer</code></a>
  74. value <code>w</code>,
  75. the expression
  76. <code>w.Write</code>,
  77. a method value, is a function that will always write to <code>w</code>; it is equivalent to
  78. a function literal closing over <code>w</code>:
  79. </p>
  80. <pre>
  81. func (p []byte) (n int, err error) {
  82. return w.Write(p)
  83. }
  84. </pre>
  85. <p>
  86. Method values are distinct from method expressions, which generate functions
  87. from methods of a given type; the method expression <code>(*bufio.Writer).Write</code>
  88. is equivalent to a function with an extra first argument, a receiver of type
  89. <code>(*bufio.Writer)</code>:
  90. </p>
  91. <pre>
  92. func (w *bufio.Writer, p []byte) (n int, err error) {
  93. return w.Write(p)
  94. }
  95. </pre>
  96. <p>
  97. <em>Updating</em>: No existing code is affected; the change is strictly backward-compatible.
  98. </p>
  99. <h3 id="return">Return requirements</h3>
  100. <p>
  101. Before Go 1.1, a function that returned a value needed an explicit "return"
  102. or call to <code>panic</code> at
  103. the end of the function; this was a simple way to make the programmer
  104. be explicit about the meaning of the function. But there are many cases
  105. where a final "return" is clearly unnecessary, such as a function with
  106. only an infinite "for" loop.
  107. </p>
  108. <p>
  109. In Go 1.1, the rule about final "return" statements is more permissive.
  110. It introduces the concept of a
  111. <a href="/ref/spec#Terminating_statements"><em>terminating statement</em></a>,
  112. a statement that is guaranteed to be the last one a function executes.
  113. Examples include
  114. "for" loops with no condition and "if-else"
  115. statements in which each half ends in a "return".
  116. If the final statement of a function can be shown <em>syntactically</em> to
  117. be a terminating statement, no final "return" statement is needed.
  118. </p>
  119. <p>
  120. Note that the rule is purely syntactic: it pays no attention to the values in the
  121. code and therefore requires no complex analysis.
  122. </p>
  123. <p>
  124. <em>Updating</em>: The change is backward-compatible, but existing code
  125. with superfluous "return" statements and calls to <code>panic</code> may
  126. be simplified manually.
  127. Such code can be identified by <code>go vet</code>.
  128. </p>
  129. <h2 id="impl">Changes to the implementations and tools</h2>
  130. <h3 id="gccgo">Status of gccgo</h3>
  131. <p>
  132. The GCC release schedule does not coincide with the Go release schedule, so some skew is inevitable in
  133. <code>gccgo</code>'s releases.
  134. The 4.8.0 version of GCC shipped in March, 2013 and includes a nearly-Go 1.1 version of <code>gccgo</code>.
  135. Its library is a little behind the release, but the biggest difference is that method values are not implemented.
  136. Sometime around July 2013, we expect 4.8.2 of GCC to ship with a <code>gccgo</code>
  137. providing a complete Go 1.1 implementation.
  138. </p>
  139. <h3 id="gc_flag">Command-line flag parsing</h3>
  140. <p>
  141. In the gc tool chain, the compilers and linkers now use the
  142. same command-line flag parsing rules as the Go flag package, a departure
  143. from the traditional Unix flag parsing. This may affect scripts that invoke
  144. the tool directly.
  145. For example,
  146. <code>go tool 6c -Fw -Dfoo</code> must now be written
  147. <code>go tool 6c -F -w -D foo</code>.
  148. </p>
  149. <h3 id="int">Size of int on 64-bit platforms</h3>
  150. <p>
  151. The language allows the implementation to choose whether the <code>int</code> type and
  152. <code>uint</code> types are 32 or 64 bits. Previous Go implementations made <code>int</code>
  153. and <code>uint</code> 32 bits on all systems. Both the gc and gccgo implementations
  154. now make
  155. <code>int</code> and <code>uint</code> 64 bits on 64-bit platforms such as AMD64/x86-64.
  156. Among other things, this enables the allocation of slices with
  157. more than 2 billion elements on 64-bit platforms.
  158. </p>
  159. <p>
  160. <em>Updating</em>:
  161. Most programs will be unaffected by this change.
  162. Because Go does not allow implicit conversions between distinct
  163. <a href="/ref/spec#Numeric_types">numeric types</a>,
  164. no programs will stop compiling due to this change.
  165. However, programs that contain implicit assumptions
  166. that <code>int</code> is only 32 bits may change behavior.
  167. For example, this code prints a positive number on 64-bit systems and
  168. a negative one on 32-bit systems:
  169. </p>
  170. <pre>
  171. x := ^uint32(0) // x is 0xffffffff
  172. i := int(x) // i is -1 on 32-bit systems, 0xffffffff on 64-bit
  173. fmt.Println(i)
  174. </pre>
  175. <p>Portable code intending 32-bit sign extension (yielding <code>-1</code> on all systems)
  176. would instead say:
  177. </p>
  178. <pre>
  179. i := int(int32(x))
  180. </pre>
  181. <h3 id="heap">Heap size on 64-bit architectures</h3>
  182. <p>
  183. On 64-bit architectures, the maximum heap size has been enlarged substantially,
  184. from a few gigabytes to several tens of gigabytes.
  185. (The exact details depend on the system and may change.)
  186. </p>
  187. <p>
  188. On 32-bit architectures, the heap size has not changed.
  189. </p>
  190. <p>
  191. <em>Updating</em>:
  192. This change should have no effect on existing programs beyond allowing them
  193. to run with larger heaps.
  194. </p>
  195. <h3 id="unicode">Unicode</h3>
  196. <p>
  197. To make it possible to represent code points greater than 65535 in UTF-16,
  198. Unicode defines <em>surrogate halves</em>,
  199. a range of code points to be used only in the assembly of large values, and only in UTF-16.
  200. The code points in that surrogate range are illegal for any other purpose.
  201. In Go 1.1, this constraint is honored by the compiler, libraries, and run-time:
  202. a surrogate half is illegal as a rune value, when encoded as UTF-8, or when
  203. encoded in isolation as UTF-16.
  204. When encountered, for example in converting from a rune to UTF-8, it is
  205. treated as an encoding error and will yield the replacement rune,
  206. <a href="/pkg/unicode/utf8/#RuneError"><code>utf8.RuneError</code></a>,
  207. U+FFFD.
  208. </p>
  209. <p>
  210. This program,
  211. </p>
  212. <pre>
  213. import "fmt"
  214. func main() {
  215. fmt.Printf("%+q\n", string(0xD800))
  216. }
  217. </pre>
  218. <p>
  219. printed <code>"\ud800"</code> in Go 1.0, but prints <code>"\ufffd"</code> in Go 1.1.
  220. </p>
  221. <p>
  222. Surrogate-half Unicode values are now illegal in rune and string constants, so constants such as
  223. <code>'\ud800'</code> and <code>"\ud800"</code> are now rejected by the compilers.
  224. When written explicitly as UTF-8 encoded bytes,
  225. such strings can still be created, as in <code>"\xed\xa0\x80"</code>.
  226. However, when such a string is decoded as a sequence of runes, as in a range loop, it will yield only <code>utf8.RuneError</code>
  227. values.
  228. </p>
  229. <p>
  230. The Unicode byte order mark U+FEFF, encoded in UTF-8, is now permitted as the first
  231. character of a Go source file.
  232. Even though its appearance in the byte-order-free UTF-8 encoding is clearly unnecessary,
  233. some editors add the mark as a kind of "magic number" identifying a UTF-8 encoded file.
  234. </p>
  235. <p>
  236. <em>Updating</em>:
  237. Most programs will be unaffected by the surrogate change.
  238. Programs that depend on the old behavior should be modified to avoid the issue.
  239. The byte-order-mark change is strictly backward-compatible.
  240. </p>
  241. <h3 id="race">Race detector</h3>
  242. <p>
  243. A major addition to the tools is a <em>race detector</em>, a way to
  244. find bugs in programs caused by concurrent access of the same
  245. variable, where at least one of the accesses is a write.
  246. This new facility is built into the <code>go</code> tool.
  247. For now, it is only available on Linux, Mac OS X, and Windows systems with
  248. 64-bit x86 processors.
  249. To enable it, set the <code>-race</code> flag when building or testing your program
  250. (for instance, <code>go test -race</code>).
  251. The race detector is documented in <a href="/doc/articles/race_detector.html">a separate article</a>.
  252. </p>
  253. <h3 id="gc_asm">The gc assemblers</h3>
  254. <p>
  255. Due to the change of the <a href="#int"><code>int</code></a> to 64 bits and
  256. a new internal <a href="//golang.org/s/go11func">representation of functions</a>,
  257. the arrangement of function arguments on the stack has changed in the gc tool chain.
  258. Functions written in assembly will need to be revised at least
  259. to adjust frame pointer offsets.
  260. </p>
  261. <p>
  262. <em>Updating</em>:
  263. The <code>go vet</code> command now checks that functions implemented in assembly
  264. match the Go function prototypes they implement.
  265. </p>
  266. <h3 id="gocmd">Changes to the go command</h3>
  267. <p>
  268. The <a href="/cmd/go/"><code>go</code></a> command has acquired several
  269. changes intended to improve the experience for new Go users.
  270. </p>
  271. <p>
  272. First, when compiling, testing, or running Go code, the <code>go</code> command will now give more detailed error messages,
  273. including a list of paths searched, when a package cannot be located.
  274. </p>
  275. <pre>
  276. $ go build foo/quxx
  277. can't load package: package foo/quxx: cannot find package "foo/quxx" in any of:
  278. /home/you/go/src/pkg/foo/quxx (from $GOROOT)
  279. /home/you/src/foo/quxx (from $GOPATH)
  280. </pre>
  281. <p>
  282. Second, the <code>go get</code> command no longer allows <code>$GOROOT</code>
  283. as the default destination when downloading package source.
  284. To use the <code>go get</code>
  285. command, a <a href="/doc/code.html#GOPATH">valid <code>$GOPATH</code></a> is now required.
  286. </p>
  287. <pre>
  288. $ GOPATH= go get code.google.com/p/foo/quxx
  289. package code.google.com/p/foo/quxx: cannot download, $GOPATH not set. For more details see: go help gopath
  290. </pre>
  291. <p>
  292. Finally, as a result of the previous change, the <code>go get</code> command will also fail
  293. when <code>$GOPATH</code> and <code>$GOROOT</code> are set to the same value.
  294. </p>
  295. <pre>
  296. $ GOPATH=$GOROOT go get code.google.com/p/foo/quxx
  297. warning: GOPATH set to GOROOT (/home/you/go) has no effect
  298. package code.google.com/p/foo/quxx: cannot download, $GOPATH must not be set to $GOROOT. For more details see: go help gopath
  299. </pre>
  300. <h3 id="gotest">Changes to the go test command</h3>
  301. <p>
  302. The <a href="/cmd/go/#hdr-Test_packages"><code>go test</code></a>
  303. command no longer deletes the binary when run with profiling enabled,
  304. to make it easier to analyze the profile.
  305. The implementation sets the <code>-c</code> flag automatically, so after running,
  306. </p>
  307. <pre>
  308. $ go test -cpuprofile cpuprof.out mypackage
  309. </pre>
  310. <p>
  311. the file <code>mypackage.test</code> will be left in the directory where <code>go test</code> was run.
  312. </p>
  313. <p>
  314. The <a href="/cmd/go/#hdr-Test_packages"><code>go test</code></a>
  315. command can now generate profiling information
  316. that reports where goroutines are blocked, that is,
  317. where they tend to stall waiting for an event such as a channel communication.
  318. The information is presented as a
  319. <em>blocking profile</em>
  320. enabled with the
  321. <code>-blockprofile</code>
  322. option of
  323. <code>go test</code>.
  324. Run <code>go help test</code> for more information.
  325. </p>
  326. <h3 id="gofix">Changes to the go fix command</h3>
  327. <p>
  328. The <a href="/cmd/fix/"><code>fix</code></a> command, usually run as
  329. <code>go fix</code>, no longer applies fixes to update code from
  330. before Go 1 to use Go 1 APIs.
  331. To update pre-Go 1 code to Go 1.1, use a Go 1.0 tool chain
  332. to convert the code to Go 1.0 first.
  333. </p>
  334. <h3 id="tags">Build constraints</h3>
  335. <p>
  336. The "<code>go1.1</code>" tag has been added to the list of default
  337. <a href="/pkg/go/build/#hdr-Build_Constraints">build constraints</a>.
  338. This permits packages to take advantage of the new features in Go 1.1 while
  339. remaining compatible with earlier versions of Go.
  340. </p>
  341. <p>
  342. To build a file only with Go 1.1 and above, add this build constraint:
  343. </p>
  344. <pre>
  345. // +build go1.1
  346. </pre>
  347. <p>
  348. To build a file only with Go 1.0.x, use the converse constraint:
  349. </p>
  350. <pre>
  351. // +build !go1.1
  352. </pre>
  353. <h3 id="platforms">Additional platforms</h3>
  354. <p>
  355. The Go 1.1 tool chain adds experimental support for <code>freebsd/arm</code>,
  356. <code>netbsd/386</code>, <code>netbsd/amd64</code>, <code>netbsd/arm</code>,
  357. <code>openbsd/386</code> and <code>openbsd/amd64</code> platforms.
  358. </p>
  359. <p>
  360. An ARMv6 or later processor is required for <code>freebsd/arm</code> or
  361. <code>netbsd/arm</code>.
  362. </p>
  363. <p>
  364. Go 1.1 adds experimental support for <code>cgo</code> on <code>linux/arm</code>.
  365. </p>
  366. <h3 id="crosscompile">Cross compilation</h3>
  367. <p>
  368. When cross-compiling, the <code>go</code> tool will disable <code>cgo</code>
  369. support by default.
  370. </p>
  371. <p>
  372. To explicitly enable <code>cgo</code>, set <code>CGO_ENABLED=1</code>.
  373. </p>
  374. <h2 id="performance">Performance</h2>
  375. <p>
  376. The performance of code compiled with the Go 1.1 gc tool suite should be noticeably
  377. better for most Go programs.
  378. Typical improvements relative to Go 1.0 seem to be about 30%-40%, sometimes
  379. much more, but occasionally less or even non-existent.
  380. There are too many small performance-driven tweaks through the tools and libraries
  381. to list them all here, but the following major changes are worth noting:
  382. </p>
  383. <ul>
  384. <li>The gc compilers generate better code in many cases, most noticeably for
  385. floating point on the 32-bit Intel architecture.</li>
  386. <li>The gc compilers do more in-lining, including for some operations
  387. in the run-time such as <a href="/pkg/builtin/#append"><code>append</code></a>
  388. and interface conversions.</li>
  389. <li>There is a new implementation of Go maps with significant reduction in
  390. memory footprint and CPU time.</li>
  391. <li>The garbage collector has been made more parallel, which can reduce
  392. latencies for programs running on multiple CPUs.</li>
  393. <li>The garbage collector is also more precise, which costs a small amount of
  394. CPU time but can reduce the size of the heap significantly, especially
  395. on 32-bit architectures.</li>
  396. <li>Due to tighter coupling of the run-time and network libraries, fewer
  397. context switches are required on network operations.</li>
  398. </ul>
  399. <h2 id="library">Changes to the standard library</h2>
  400. <h3 id="bufio_scanner">bufio.Scanner</h3>
  401. <p>
  402. The various routines to scan textual input in the
  403. <a href="/pkg/bufio/"><code>bufio</code></a>
  404. package,
  405. <a href="/pkg/bufio/#Reader.ReadBytes"><code>ReadBytes</code></a>,
  406. <a href="/pkg/bufio/#Reader.ReadString"><code>ReadString</code></a>
  407. and particularly
  408. <a href="/pkg/bufio/#Reader.ReadLine"><code>ReadLine</code></a>,
  409. are needlessly complex to use for simple purposes.
  410. In Go 1.1, a new type,
  411. <a href="/pkg/bufio/#Scanner"><code>Scanner</code></a>,
  412. has been added to make it easier to do simple tasks such as
  413. read the input as a sequence of lines or space-delimited words.
  414. It simplifies the problem by terminating the scan on problematic
  415. input such as pathologically long lines, and having a simple
  416. default: line-oriented input, with each line stripped of its terminator.
  417. Here is code to reproduce the input a line at a time:
  418. </p>
  419. <pre>
  420. scanner := bufio.NewScanner(os.Stdin)
  421. for scanner.Scan() {
  422. fmt.Println(scanner.Text()) // Println will add back the final '\n'
  423. }
  424. if err := scanner.Err(); err != nil {
  425. fmt.Fprintln(os.Stderr, "reading standard input:", err)
  426. }
  427. </pre>
  428. <p>
  429. Scanning behavior can be adjusted through a function to control subdividing the input
  430. (see the documentation for <a href="/pkg/bufio/#SplitFunc"><code>SplitFunc</code></a>),
  431. but for tough problems or the need to continue past errors, the older interface
  432. may still be required.
  433. </p>
  434. <h3 id="net">net</h3>
  435. <p>
  436. The protocol-specific resolvers in the <a href="/pkg/net/"><code>net</code></a> package were formerly
  437. lax about the network name passed in.
  438. Although the documentation was clear
  439. that the only valid networks for
  440. <a href="/pkg/net/#ResolveTCPAddr"><code>ResolveTCPAddr</code></a>
  441. are <code>"tcp"</code>,
  442. <code>"tcp4"</code>, and <code>"tcp6"</code>, the Go 1.0 implementation silently accepted any string.
  443. The Go 1.1 implementation returns an error if the network is not one of those strings.
  444. The same is true of the other protocol-specific resolvers <a href="/pkg/net/#ResolveIPAddr"><code>ResolveIPAddr</code></a>,
  445. <a href="/pkg/net/#ResolveUDPAddr"><code>ResolveUDPAddr</code></a>, and
  446. <a href="/pkg/net/#ResolveUnixAddr"><code>ResolveUnixAddr</code></a>.
  447. </p>
  448. <p>
  449. The previous implementation of
  450. <a href="/pkg/net/#ListenUnixgram"><code>ListenUnixgram</code></a>
  451. returned a
  452. <a href="/pkg/net/#UDPConn"><code>UDPConn</code></a> as
  453. a representation of the connection endpoint.
  454. The Go 1.1 implementation instead returns a
  455. <a href="/pkg/net/#UnixConn"><code>UnixConn</code></a>
  456. to allow reading and writing
  457. with its
  458. <a href="/pkg/net/#UnixConn.ReadFrom"><code>ReadFrom</code></a>
  459. and
  460. <a href="/pkg/net/#UnixConn.WriteTo"><code>WriteTo</code></a>
  461. methods.
  462. </p>
  463. <p>
  464. The data structures
  465. <a href="/pkg/net/#IPAddr"><code>IPAddr</code></a>,
  466. <a href="/pkg/net/#TCPAddr"><code>TCPAddr</code></a>, and
  467. <a href="/pkg/net/#UDPAddr"><code>UDPAddr</code></a>
  468. add a new string field called <code>Zone</code>.
  469. Code using untagged composite literals (e.g. <code>net.TCPAddr{ip, port}</code>)
  470. instead of tagged literals (<code>net.TCPAddr{IP: ip, Port: port}</code>)
  471. will break due to the new field.
  472. The Go 1 compatibility rules allow this change: client code must use tagged literals to avoid such breakages.
  473. </p>
  474. <p>
  475. <em>Updating</em>:
  476. To correct breakage caused by the new struct field,
  477. <code>go fix</code> will rewrite code to add tags for these types.
  478. More generally, <code>go vet</code> will identify composite literals that
  479. should be revised to use field tags.
  480. </p>
  481. <h3 id="reflect">reflect</h3>
  482. <p>
  483. The <a href="/pkg/reflect/"><code>reflect</code></a> package has several significant additions.
  484. </p>
  485. <p>
  486. It is now possible to run a "select" statement using
  487. the <code>reflect</code> package; see the description of
  488. <a href="/pkg/reflect/#Select"><code>Select</code></a>
  489. and
  490. <a href="/pkg/reflect/#SelectCase"><code>SelectCase</code></a>
  491. for details.
  492. </p>
  493. <p>
  494. The new method
  495. <a href="/pkg/reflect/#Value.Convert"><code>Value.Convert</code></a>
  496. (or
  497. <a href="/pkg/reflect/#Type"><code>Type.ConvertibleTo</code></a>)
  498. provides functionality to execute a Go conversion or type assertion operation
  499. on a
  500. <a href="/pkg/reflect/#Value"><code>Value</code></a>
  501. (or test for its possibility).
  502. </p>
  503. <p>
  504. The new function
  505. <a href="/pkg/reflect/#MakeFunc"><code>MakeFunc</code></a>
  506. creates a wrapper function to make it easier to call a function with existing
  507. <a href="/pkg/reflect/#Value"><code>Values</code></a>,
  508. doing the standard Go conversions among the arguments, for instance
  509. to pass an actual <code>int</code> to a formal <code>interface{}</code>.
  510. </p>
  511. <p>
  512. Finally, the new functions
  513. <a href="/pkg/reflect/#ChanOf"><code>ChanOf</code></a>,
  514. <a href="/pkg/reflect/#MapOf"><code>MapOf</code></a>
  515. and
  516. <a href="/pkg/reflect/#SliceOf"><code>SliceOf</code></a>
  517. construct new
  518. <a href="/pkg/reflect/#Type"><code>Types</code></a>
  519. from existing types, for example to construct the type <code>[]T</code> given
  520. only <code>T</code>.
  521. </p>
  522. <h3 id="time">time</h3>
  523. <p>
  524. On FreeBSD, Linux, NetBSD, OS X and OpenBSD, previous versions of the
  525. <a href="/pkg/time/"><code>time</code></a> package
  526. returned times with microsecond precision.
  527. The Go 1.1 implementation on these
  528. systems now returns times with nanosecond precision.
  529. Programs that write to an external format with microsecond precision
  530. and read it back, expecting to recover the original value, will be affected
  531. by the loss of precision.
  532. There are two new methods of <a href="/pkg/time/#Time"><code>Time</code></a>,
  533. <a href="/pkg/time/#Time.Round"><code>Round</code></a>
  534. and
  535. <a href="/pkg/time/#Time.Truncate"><code>Truncate</code></a>,
  536. that can be used to remove precision from a time before passing it to
  537. external storage.
  538. </p>
  539. <p>
  540. The new method
  541. <a href="/pkg/time/#Time.YearDay"><code>YearDay</code></a>
  542. returns the one-indexed integral day number of the year specified by the time value.
  543. </p>
  544. <p>
  545. The
  546. <a href="/pkg/time/#Timer"><code>Timer</code></a>
  547. type has a new method
  548. <a href="/pkg/time/#Timer.Reset"><code>Reset</code></a>
  549. that modifies the timer to expire after a specified duration.
  550. </p>
  551. <p>
  552. Finally, the new function
  553. <a href="/pkg/time/#ParseInLocation"><code>ParseInLocation</code></a>
  554. is like the existing
  555. <a href="/pkg/time/#Parse"><code>Parse</code></a>
  556. but parses the time in the context of a location (time zone), ignoring
  557. time zone information in the parsed string.
  558. This function addresses a common source of confusion in the time API.
  559. </p>
  560. <p>
  561. <em>Updating</em>:
  562. Code that needs to read and write times using an external format with
  563. lower precision should be modified to use the new methods.
  564. </p>
  565. <h3 id="exp_old">Exp and old subtrees moved to go.exp and go.text subrepositories</h3>
  566. <p>
  567. To make it easier for binary distributions to access them if desired, the <code>exp</code>
  568. and <code>old</code> source subtrees, which are not included in binary distributions,
  569. have been moved to the new <code>go.exp</code> subrepository at
  570. <code>code.google.com/p/go.exp</code>. To access the <code>ssa</code> package,
  571. for example, run
  572. </p>
  573. <pre>
  574. $ go get code.google.com/p/go.exp/ssa
  575. </pre>
  576. <p>
  577. and then in Go source,
  578. </p>
  579. <pre>
  580. import "code.google.com/p/go.exp/ssa"
  581. </pre>
  582. <p>
  583. The old package <code>exp/norm</code> has also been moved, but to a new repository
  584. <code>go.text</code>, where the Unicode APIs and other text-related packages will
  585. be developed.
  586. </p>
  587. <h3 id="new_packages">New packages</h3>
  588. <p>
  589. There are three new packages.
  590. </p>
  591. <ul>
  592. <li>
  593. The <a href="/pkg/go/format/"><code>go/format</code></a> package provides
  594. a convenient way for a program to access the formatting capabilities of the
  595. <a href="/cmd/go/#hdr-Run_gofmt_on_package_sources"><code>go fmt</code></a> command.
  596. It has two functions,
  597. <a href="/pkg/go/format/#Node"><code>Node</code></a> to format a Go parser
  598. <a href="/pkg/go/ast/#Node"><code>Node</code></a>,
  599. and
  600. <a href="/pkg/go/format/#Source"><code>Source</code></a>
  601. to reformat arbitrary Go source code into the standard format as provided by the
  602. <a href="/cmd/go/#hdr-Run_gofmt_on_package_sources"><code>go fmt</code></a> command.
  603. </li>
  604. <li>
  605. The <a href="/pkg/net/http/cookiejar/"><code>net/http/cookiejar</code></a> package provides the basics for managing HTTP cookies.
  606. </li>
  607. <li>
  608. The <a href="/pkg/runtime/race/"><code>runtime/race</code></a> package provides low-level facilities for data race detection.
  609. It is internal to the race detector and does not otherwise export any user-visible functionality.
  610. </li>
  611. </ul>
  612. <h3 id="minor_library_changes">Minor changes to the library</h3>
  613. <p>
  614. The following list summarizes a number of minor changes to the library, mostly additions.
  615. See the relevant package documentation for more information about each change.
  616. </p>
  617. <ul>
  618. <li>
  619. The <a href="/pkg/bytes/"><code>bytes</code></a> package has two new functions,
  620. <a href="/pkg/bytes/#TrimPrefix"><code>TrimPrefix</code></a>
  621. and
  622. <a href="/pkg/bytes/#TrimSuffix"><code>TrimSuffix</code></a>,
  623. with self-evident properties.
  624. Also, the <a href="/pkg/bytes/#Buffer"><code>Buffer</code></a> type
  625. has a new method
  626. <a href="/pkg/bytes/#Buffer.Grow"><code>Grow</code></a> that
  627. provides some control over memory allocation inside the buffer.
  628. Finally, the
  629. <a href="/pkg/bytes/#Reader"><code>Reader</code></a> type now has a
  630. <a href="/pkg/strings/#Reader.WriteTo"><code>WriteTo</code></a> method
  631. so it implements the
  632. <a href="/pkg/io/#WriterTo"><code>io.WriterTo</code></a> interface.
  633. </li>
  634. <li>
  635. The <a href="/pkg/compress/gzip/"><code>compress/gzip</code></a> package has
  636. a new <a href="/pkg/compress/gzip/#Writer.Flush"><code>Flush</code></a>
  637. method for its
  638. <a href="/pkg/compress/gzip/#Writer"><code>Writer</code></a>
  639. type that flushes its underlying <code>flate.Writer</code>.
  640. </li>
  641. <li>
  642. The <a href="/pkg/crypto/hmac/"><code>crypto/hmac</code></a> package has a new function,
  643. <a href="/pkg/crypto/hmac/#Equal"><code>Equal</code></a>, to compare two MACs.
  644. </li>
  645. <li>
  646. The <a href="/pkg/crypto/x509/"><code>crypto/x509</code></a> package
  647. now supports PEM blocks (see
  648. <a href="/pkg/crypto/x509/#DecryptPEMBlock"><code>DecryptPEMBlock</code></a> for instance),
  649. and a new function
  650. <a href="/pkg/crypto/x509/#ParseECPrivateKey"><code>ParseECPrivateKey</code></a> to parse elliptic curve private keys.
  651. </li>
  652. <li>
  653. The <a href="/pkg/database/sql/"><code>database/sql</code></a> package
  654. has a new
  655. <a href="/pkg/database/sql/#DB.Ping"><code>Ping</code></a>
  656. method for its
  657. <a href="/pkg/database/sql/#DB"><code>DB</code></a>
  658. type that tests the health of the connection.
  659. </li>
  660. <li>
  661. The <a href="/pkg/database/sql/driver/"><code>database/sql/driver</code></a> package
  662. has a new
  663. <a href="/pkg/database/sql/driver/#Queryer"><code>Queryer</code></a>
  664. interface that a
  665. <a href="/pkg/database/sql/driver/#Conn"><code>Conn</code></a>
  666. may implement to improve performance.
  667. </li>
  668. <li>
  669. The <a href="/pkg/encoding/json/"><code>encoding/json</code></a> package's
  670. <a href="/pkg/encoding/json/#Decoder"><code>Decoder</code></a>
  671. has a new method
  672. <a href="/pkg/encoding/json/#Decoder.Buffered"><code>Buffered</code></a>
  673. to provide access to the remaining data in its buffer,
  674. as well as a new method
  675. <a href="/pkg/encoding/json/#Decoder.UseNumber"><code>UseNumber</code></a>
  676. to unmarshal a value into the new type
  677. <a href="/pkg/encoding/json/#Number"><code>Number</code></a>,
  678. a string, rather than a float64.
  679. </li>
  680. <li>
  681. The <a href="/pkg/encoding/xml/"><code>encoding/xml</code></a> package
  682. has a new function,
  683. <a href="/pkg/encoding/xml/#EscapeText"><code>EscapeText</code></a>,
  684. which writes escaped XML output,
  685. and a method on
  686. <a href="/pkg/encoding/xml/#Encoder"><code>Encoder</code></a>,
  687. <a href="/pkg/encoding/xml/#Encoder.Indent"><code>Indent</code></a>,
  688. to specify indented output.
  689. </li>
  690. <li>
  691. In the <a href="/pkg/go/ast/"><code>go/ast</code></a> package, a
  692. new type <a href="/pkg/go/ast/#CommentMap"><code>CommentMap</code></a>
  693. and associated methods makes it easier to extract and process comments in Go programs.
  694. </li>
  695. <li>
  696. In the <a href="/pkg/go/doc/"><code>go/doc</code></a> package,
  697. the parser now keeps better track of stylized annotations such as <code>TODO(joe)</code>
  698. throughout the code,
  699. information that the <a href="/cmd/godoc/"><code>godoc</code></a>
  700. command can filter or present according to the value of the <code>-notes</code> flag.
  701. </li>
  702. <li>
  703. The undocumented and only partially implemented "noescape" feature of the
  704. <a href="/pkg/html/template/"><code>html/template</code></a>
  705. package has been removed; programs that depend on it will break.
  706. </li>
  707. <li>
  708. The <a href="/pkg/image/jpeg/"><code>image/jpeg</code></a> package now
  709. reads progressive JPEG files and handles a few more subsampling configurations.
  710. </li>
  711. <li>
  712. The <a href="/pkg/io/"><code>io</code></a> package now exports the
  713. <a href="/pkg/io/#ByteWriter"><code>io.ByteWriter</code></a> interface to capture the common
  714. functionality of writing a byte at a time.
  715. It also exports a new error, <a href="/pkg/io/#ErrNoProgress"><code>ErrNoProgress</code></a>,
  716. used to indicate a <code>Read</code> implementation is looping without delivering data.
  717. </li>
  718. <li>
  719. The <a href="/pkg/log/syslog/"><code>log/syslog</code></a> package now provides better support
  720. for OS-specific logging features.
  721. </li>
  722. <li>
  723. The <a href="/pkg/math/big/"><code>math/big</code></a> package's
  724. <a href="/pkg/math/big/#Int"><code>Int</code></a> type
  725. now has methods
  726. <a href="/pkg/math/big/#Int.MarshalJSON"><code>MarshalJSON</code></a>
  727. and
  728. <a href="/pkg/math/big/#Int.UnmarshalJSON"><code>UnmarshalJSON</code></a>
  729. to convert to and from a JSON representation.
  730. Also,
  731. <a href="/pkg/math/big/#Int"><code>Int</code></a>
  732. can now convert directly to and from a <code>uint64</code> using
  733. <a href="/pkg/math/big/#Int.Uint64"><code>Uint64</code></a>
  734. and
  735. <a href="/pkg/math/big/#Int.SetUint64"><code>SetUint64</code></a>,
  736. while
  737. <a href="/pkg/math/big/#Rat"><code>Rat</code></a>
  738. can do the same with <code>float64</code> using
  739. <a href="/pkg/math/big/#Rat.Float64"><code>Float64</code></a>
  740. and
  741. <a href="/pkg/math/big/#Rat.SetFloat64"><code>SetFloat64</code></a>.
  742. </li>
  743. <li>
  744. The <a href="/pkg/mime/multipart/"><code>mime/multipart</code></a> package
  745. has a new method for its
  746. <a href="/pkg/mime/multipart/#Writer"><code>Writer</code></a>,
  747. <a href="/pkg/mime/multipart/#Writer.SetBoundary"><code>SetBoundary</code></a>,
  748. to define the boundary separator used to package the output.
  749. The <a href="/pkg/mime/multipart/#Reader"><code>Reader</code></a> also now
  750. transparently decodes any <code>quoted-printable</code> parts and removes
  751. the <code>Content-Transfer-Encoding</code> header when doing so.
  752. </li>
  753. <li>
  754. The
  755. <a href="/pkg/net/"><code>net</code></a> package's
  756. <a href="/pkg/net/#ListenUnixgram"><code>ListenUnixgram</code></a>
  757. function has changed return types: it now returns a
  758. <a href="/pkg/net/#UnixConn"><code>UnixConn</code></a>
  759. rather than a
  760. <a href="/pkg/net/#UDPConn"><code>UDPConn</code></a>, which was
  761. clearly a mistake in Go 1.0.
  762. Since this API change fixes a bug, it is permitted by the Go 1 compatibility rules.
  763. </li>
  764. <li>
  765. The <a href="/pkg/net/"><code>net</code></a> package includes a new type,
  766. <a href="/pkg/net/#Dialer"><code>Dialer</code></a>, to supply options to
  767. <a href="/pkg/net/#Dialer.Dial"><code>Dial</code></a>.
  768. </li>
  769. <li>
  770. The <a href="/pkg/net/"><code>net</code></a> package adds support for
  771. link-local IPv6 addresses with zone qualifiers, such as <code>fe80::1%lo0</code>.
  772. The address structures <a href="/pkg/net/#IPAddr"><code>IPAddr</code></a>,
  773. <a href="/pkg/net/#UDPAddr"><code>UDPAddr</code></a>, and
  774. <a href="/pkg/net/#TCPAddr"><code>TCPAddr</code></a>
  775. record the zone in a new field, and functions that expect string forms of these addresses, such as
  776. <a href="/pkg/net/#Dial"><code>Dial</code></a>,
  777. <a href="/pkg/net/#ResolveIPAddr"><code>ResolveIPAddr</code></a>,
  778. <a href="/pkg/net/#ResolveUDPAddr"><code>ResolveUDPAddr</code></a>, and
  779. <a href="/pkg/net/#ResolveTCPAddr"><code>ResolveTCPAddr</code></a>,
  780. now accept the zone-qualified form.
  781. </li>
  782. <li>
  783. The <a href="/pkg/net/"><code>net</code></a> package adds
  784. <a href="/pkg/net/#LookupNS"><code>LookupNS</code></a> to its suite of resolving functions.
  785. <code>LookupNS</code> returns the <a href="/pkg/net/#NS">NS records</a> for a host name.
  786. </li>
  787. <li>
  788. The <a href="/pkg/net/"><code>net</code></a> package adds protocol-specific
  789. packet reading and writing methods to
  790. <a href="/pkg/net/#IPConn"><code>IPConn</code></a>
  791. (<a href="/pkg/net/#IPConn.ReadMsgIP"><code>ReadMsgIP</code></a>
  792. and <a href="/pkg/net/#IPConn.WriteMsgIP"><code>WriteMsgIP</code></a>) and
  793. <a href="/pkg/net/#UDPConn"><code>UDPConn</code></a>
  794. (<a href="/pkg/net/#UDPConn.ReadMsgUDP"><code>ReadMsgUDP</code></a> and
  795. <a href="/pkg/net/#UDPConn.WriteMsgUDP"><code>WriteMsgUDP</code></a>).
  796. These are specialized versions of <a href="/pkg/net/#PacketConn"><code>PacketConn</code></a>'s
  797. <code>ReadFrom</code> and <code>WriteTo</code> methods that provide access to out-of-band data associated
  798. with the packets.
  799. </li>
  800. <li>
  801. The <a href="/pkg/net/"><code>net</code></a> package adds methods to
  802. <a href="/pkg/net/#UnixConn"><code>UnixConn</code></a> to allow closing half of the connection
  803. (<a href="/pkg/net/#UnixConn.CloseRead"><code>CloseRead</code></a> and
  804. <a href="/pkg/net/#UnixConn.CloseWrite"><code>CloseWrite</code></a>),
  805. matching the existing methods of <a href="/pkg/net/#TCPConn"><code>TCPConn</code></a>.
  806. </li>
  807. <li>
  808. The <a href="/pkg/net/http/"><code>net/http</code></a> package includes several new additions.
  809. <a href="/pkg/net/http/#ParseTime"><code>ParseTime</code></a> parses a time string, trying
  810. several common HTTP time formats.
  811. The <a href="/pkg/net/http/#Request.PostFormValue"><code>PostFormValue</code></a> method of
  812. <a href="/pkg/net/http/#Request"><code>Request</code></a> is like
  813. <a href="/pkg/net/http/#Request.FormValue"><code>FormValue</code></a> but ignores URL parameters.
  814. The <a href="/pkg/net/http/#CloseNotifier"><code>CloseNotifier</code></a> interface provides a mechanism
  815. for a server handler to discover when a client has disconnected.
  816. The <code>ServeMux</code> type now has a
  817. <a href="/pkg/net/http/#ServeMux.Handler"><code>Handler</code></a> method to access a path's
  818. <code>Handler</code> without executing it.
  819. The <code>Transport</code> can now cancel an in-flight request with
  820. <a href="/pkg/net/http/#Transport.CancelRequest"><code>CancelRequest</code></a>.
  821. Finally, the Transport is now more aggressive at closing TCP connections when
  822. a <a href="/pkg/net/http/#Response"><code>Response.Body</code></a> is closed before
  823. being fully consumed.
  824. </li>
  825. <li>
  826. The <a href="/pkg/net/mail/"><code>net/mail</code></a> package has two new functions,
  827. <a href="/pkg/net/mail/#ParseAddress"><code>ParseAddress</code></a> and
  828. <a href="/pkg/net/mail/#ParseAddressList"><code>ParseAddressList</code></a>,
  829. to parse RFC 5322-formatted mail addresses into
  830. <a href="/pkg/net/mail/#Address"><code>Address</code></a> structures.
  831. </li>
  832. <li>
  833. The <a href="/pkg/net/smtp/"><code>net/smtp</code></a> package's
  834. <a href="/pkg/net/smtp/#Client"><code>Client</code></a> type has a new method,
  835. <a href="/pkg/net/smtp/#Client.Hello"><code>Hello</code></a>,
  836. which transmits a <code>HELO</code> or <code>EHLO</code> message to the server.
  837. </li>
  838. <li>
  839. The <a href="/pkg/net/textproto/"><code>net/textproto</code></a> package
  840. has two new functions,
  841. <a href="/pkg/net/textproto/#TrimBytes"><code>TrimBytes</code></a> and
  842. <a href="/pkg/net/textproto/#TrimString"><code>TrimString</code></a>,
  843. which do ASCII-only trimming of leading and trailing spaces.
  844. </li>
  845. <li>
  846. The new method <a href="/pkg/os/#FileMode.IsRegular"><code>os.FileMode.IsRegular</code></a> makes it easy to ask if a file is a plain file.
  847. </li>
  848. <li>
  849. The <a href="/pkg/os/signal/"><code>os/signal</code></a> package has a new function,
  850. <a href="/pkg/os/signal/#Stop"><code>Stop</code></a>, which stops the package delivering
  851. any further signals to the channel.
  852. </li>
  853. <li>
  854. The <a href="/pkg/regexp/"><code>regexp</code></a> package
  855. now supports Unix-original leftmost-longest matches through the
  856. <a href="/pkg/regexp/#Regexp.Longest"><code>Regexp.Longest</code></a>
  857. method, while
  858. <a href="/pkg/regexp/#Regexp.Split"><code>Regexp.Split</code></a> slices
  859. strings into pieces based on separators defined by the regular expression.
  860. </li>
  861. <li>
  862. The <a href="/pkg/runtime/debug/"><code>runtime/debug</code></a> package
  863. has three new functions regarding memory usage.
  864. The <a href="/pkg/runtime/debug/#FreeOSMemory"><code>FreeOSMemory</code></a>
  865. function triggers a run of the garbage collector and then attempts to return unused
  866. memory to the operating system;
  867. the <a href="/pkg/runtime/debug/#ReadGCStats"><code>ReadGCStats</code></a>
  868. function retrieves statistics about the collector; and
  869. <a href="/pkg/runtime/debug/#SetGCPercent"><code>SetGCPercent</code></a>
  870. provides a programmatic way to control how often the collector runs,
  871. including disabling it altogether.
  872. </li>
  873. <li>
  874. The <a href="/pkg/sort/"><code>sort</code></a> package has a new function,
  875. <a href="/pkg/sort/#Reverse"><code>Reverse</code></a>.
  876. Wrapping the argument of a call to
  877. <a href="/pkg/sort/#Sort"><code>sort.Sort</code></a>
  878. with a call to <code>Reverse</code> causes the sort order to be reversed.
  879. </li>
  880. <li>
  881. The <a href="/pkg/strings/"><code>strings</code></a> package has two new functions,
  882. <a href="/pkg/strings/#TrimPrefix"><code>TrimPrefix</code></a>
  883. and
  884. <a href="/pkg/strings/#TrimSuffix"><code>TrimSuffix</code></a>
  885. with self-evident properties, and the new method
  886. <a href="/pkg/strings/#Reader.WriteTo"><code>Reader.WriteTo</code></a> so the
  887. <a href="/pkg/strings/#Reader"><code>Reader</code></a>
  888. type now implements the
  889. <a href="/pkg/io/#WriterTo"><code>io.WriterTo</code></a> interface.
  890. </li>
  891. <li>
  892. The <a href="/pkg/syscall/"><code>syscall</code></a> package's
  893. <a href="/pkg/syscall/#Fchflags"><code>Fchflags</code></a> function on various BSDs
  894. (including Darwin) has changed signature.
  895. It now takes an int as the first parameter instead of a string.
  896. Since this API change fixes a bug, it is permitted by the Go 1 compatibility rules.
  897. </li>
  898. <li>
  899. The <a href="/pkg/syscall/"><code>syscall</code></a> package also has received many updates
  900. to make it more inclusive of constants and system calls for each supported operating system.
  901. </li>
  902. <li>
  903. The <a href="/pkg/testing/"><code>testing</code></a> package now automates the generation of allocation
  904. statistics in tests and benchmarks using the new
  905. <a href="/pkg/testing/#AllocsPerRun"><code>AllocsPerRun</code></a> function. And the
  906. <a href="/pkg/testing/#B.ReportAllocs"><code>ReportAllocs</code></a>
  907. method on <a href="/pkg/testing/#B"><code>testing.B</code></a> will enable printing of
  908. memory allocation statistics for the calling benchmark. It also introduces the
  909. <a href="/pkg/testing/#BenchmarkResult.AllocsPerOp"><code>AllocsPerOp</code></a> method of
  910. <a href="/pkg/testing/#BenchmarkResult"><code>BenchmarkResult</code></a>.
  911. There is also a new
  912. <a href="/pkg/testing/#Verbose"><code>Verbose</code></a> function to test the state of the <code>-v</code>
  913. command-line flag,
  914. and a new
  915. <a href="/pkg/testing/#B.Skip"><code>Skip</code></a> method of
  916. <a href="/pkg/testing/#B"><code>testing.B</code></a> and
  917. <a href="/pkg/testing/#T"><code>testing.T</code></a>
  918. to simplify skipping an inappropriate test.
  919. </li>
  920. <li>
  921. In the <a href="/pkg/text/template/"><code>text/template</code></a>
  922. and
  923. <a href="/pkg/html/template/"><code>html/template</code></a> packages,
  924. templates can now use parentheses to group the elements of pipelines, simplifying the construction of complex pipelines.
  925. Also, as part of the new parser, the
  926. <a href="/pkg/text/template/parse/#Node"><code>Node</code></a> interface got two new methods to provide
  927. better error reporting.
  928. Although this violates the Go 1 compatibility rules,
  929. no existing code should be affected because this interface is explicitly intended only to be used
  930. by the
  931. <a href="/pkg/text/template/"><code>text/template</code></a>
  932. and
  933. <a href="/pkg/html/template/"><code>html/template</code></a>
  934. packages and there are safeguards to guarantee that.
  935. </li>
  936. <li>
  937. The implementation of the <a href="/pkg/unicode/"><code>unicode</code></a> package has been updated to Unicode version 6.2.0.
  938. </li>
  939. <li>
  940. In the <a href="/pkg/unicode/utf8/"><code>unicode/utf8</code></a> package,
  941. the new function <a href="/pkg/unicode/utf8/#ValidRune"><code>ValidRune</code></a> reports whether the rune is a valid Unicode code point.
  942. To be valid, a rune must be in range and not be a surrogate half.
  943. </li>
  944. </ul>