github.com/sean-/go@v0.0.0-20151219100004-97f854cd7bb6/doc/go1.6.html (about)

     1  <!--{
     2  	"Title": "Go 1.6 Release Notes DRAFT",
     3  	"Path":  "/doc/go1.6",
     4  	"Template": true
     5  }-->
     6  
     7  <!--
     8  Edit .,s;^PKG:([a-z][A-Za-z0-9_/]+);<a href="/pkg/\1/"><code>\1</code></a>;g
     9  Edit .,s;^([a-z][A-Za-z0-9_/]+)\.([A-Z][A-Za-z0-9_]+\.)?([A-Z][A-Za-z0-9_]+)([ .',]|$);<a href="/pkg/\1/#\2\3"><code>\3</code></a>\4;g
    10  -->
    11  
    12  <style>
    13  ul li { margin: 0.5em 0; }
    14  </style>
    15  
    16  <p>
    17  <i>NOTE: This is a DRAFT of the Go 1.6 release notes, prepared for the Go 1.6 beta.
    18  Go 1.6 has NOT yet been released.
    19  By our regular schedule, it is expected some time in February 2016.
    20  </i>
    21  </p>
    22  
    23  <h2 id="introduction">Introduction to Go 1.6</h2>
    24  
    25  <p>
    26  The latest Go release, version 1.6, arrives six months after 1.5.
    27  Most of its changes are in the implementation of the language, runtime, and libraries.
    28  There are no changes to the language specification.
    29  As always, the release maintains the Go 1 <a href="/doc/go1compat.html">promise of compatibility</a>.
    30  We expect almost all Go programs to continue to compile and run as before.
    31  </p>
    32  
    33  <p>
    34  The release adds new ports to <a href="#ports">Linux on 64-bit MIPS and Android on 32-bit x86</a>;
    35  defined and enforced <a href="#cgo">rules for sharing Go pointers with C</a>;
    36  transparent, automatic <a href="#http2">support for HTTP/2</a>;
    37  and a new mechanism for <a href="#template">template reuse</a>.
    38  </p>
    39  
    40  <h2 id="language">Changes to the language</h2>
    41  
    42  <p>
    43  There are no language changes in this release.
    44  </p>
    45  
    46  <h2 id="ports">Ports</h2>
    47  
    48  <p>
    49  Go 1.6 adds experimental ports to
    50  Linux on 64-bit MIPS (<code>linux/mips64</code> and <code>linux/mips64le</code>).
    51  These ports support <code>cgo</code> but only with internal linking.
    52  </p>
    53  
    54  <p>
    55  Go 1.6 also adds an experimental port to Android on 32-bit x86 (<code>android/386</code>).
    56  </p>
    57  
    58  <p>
    59  On FreeBSD, Go 1.6 defaults to using <code>clang</code>, not <code>gcc</code>, as the external C compiler.
    60  </p>
    61  
    62  <p>
    63  On Linux on little-endian 64-bit PowerPC (<code>linux/ppc64le</code>),
    64  Go 1.6 now supports <code>cgo</code> with external linking and
    65  is roughly feature complete.
    66  </p>
    67  
    68  <p>
    69  On NaCl, Go 1.5 required SDK version pepper-41.
    70  Go 1.6 adds support for later SDK versions.
    71  </p>
    72  
    73  <pre>
    74  TODO: CX no longer available on 386 assembly? (https://golang.org/cl/16386)
    75  </pre>
    76  
    77  <h2 id="tools">Tools</h2>
    78  
    79  <h3 id="cgo">Cgo</h3>
    80  
    81  <p>
    82  There is one major change to <a href="/cmd/cgo/"><code>cgo</code></a>, along with one minor change.
    83  </p>
    84  
    85  <p>
    86  The major change is the definition of rules for sharing Go pointers with C code,
    87  to ensure that such C code can coexist with Go's garbage collector.
    88  Briefly, Go and C may share memory allocated by Go
    89  when a pointer to that memory is passed to C as part of a <code>cgo</code> call,
    90  provided that the memory itself contains no pointers to Go-allocated memory,
    91  and provided that C does not retain the pointer after the call returns.
    92  These rules are checked by the runtime during program execution:
    93  if the runtime detects a violation, it prints a diagnosis and crashes the program.
    94  The checks can be disabled by setting the environment variable
    95  <code>GODEBUG=cgocheck=0</code>, but note that the vast majority of
    96  code identified by the checks is subtly incompatible with garbage collection
    97  in one way or another.
    98  Disabling the checks will typically only lead to more mysterious failure modes.
    99  Fixing the code in question should be strongly preferred
   100  over turning off the checks.
   101  See the <a href="/cmd/cgo/#hdr-Passing_pointers"><code>cgo</code> documentation</a> for more details.
   102  </p>
   103  
   104  <p>
   105  The minor change is
   106  the addition of explicit <code>C.complexfloat</code> and <code>C.complexdouble</code> types,
   107  separate from Go's <code>complex64</code> and <code>complex128</code>.
   108  Matching the other numeric types, C's complex types and Go's complex type are
   109  no longer interchangeable.
   110  </p>
   111  
   112  <h3 id="compiler">Compiler Toolchain</h3>
   113  
   114  <p>
   115  The compiler toolchain is mostly unchanged.
   116  Internally, the most significant change is that the parser is now hand-written
   117  instead of generated from <a href="/cmd/yacc/">yacc</a>.
   118  </p>
   119  
   120  <p>
   121  The compiler, linker, and <code>go</code> command have new flag <code>-msan</code>,
   122  analogous to <code>-race</code> and only available on linux/amd64,
   123  that enables interoperation with the <a href="http://clang.llvm.org/docs/MemorySanitizer.html">Clang MemorySanitizer</a>.
   124  Such interoperation useful mainly for testing a program containing suspect C or C++ code.
   125  </p>
   126  
   127  <p>
   128  The linker has a new option <code>-libgcc</code> to set the expected location
   129  of the C compiler support library when linking <a href="/cmd/cgo/"><code>cgo</code></a> code.
   130  The option is only consulted when using <code>-linkmode=internal</code>,
   131  and it may be set to <code>none</code> to disable the use of a support library.
   132  </p>
   133  
   134  <p>
   135  TODO: Something about build modes.
   136  </p>
   137  
   138  <p>
   139  As a reminder, the linker's <code>-X</code> flag changed in Go 1.5.
   140  In Go 1.4 and earlier, it took two arguments, as in
   141  </p>
   142  
   143  <pre>
   144  -X importpath.name value
   145  </pre>
   146  
   147  <p>
   148  Go 1.5 added an alternative syntax using a single argument
   149  that is itself a <code>name=value</code> pair:
   150  </p>
   151  
   152  <pre>
   153  -X importpath.name=value
   154  </pre>
   155  
   156  <p>
   157  In Go 1.5 the old syntax was still accepted, after printing a warning
   158  suggesting use of the new syntax instead.
   159  Go 1.6 continues to accept the old syntax and print the warning.
   160  Go 1.7 will remove support for the old syntax.
   161  </p>
   162  
   163  <h3 id="gccgo">Gccgo</h3>
   164  
   165  <p>
   166  The release schedules for the GCC and Go projects do not coincide.
   167  GCC release 5 contains the Go 1.4 version of gccgo.
   168  The next release, GCC 6, will have the Go 1.5 version of gccgo.
   169  Due to release scheduling, it is likely that
   170  Go 1.6 will not be in a GCC release until GCC 7.
   171  </p>
   172  
   173  <h3 id="go_command">Go command</h3>
   174  
   175  <p>
   176  The <a href="/cmd/go"><code>go</code></a> command's basic operation
   177  is unchanged, but there are a number of changes worth noting.
   178  </p>
   179  
   180  <p>
   181  Go 1.5 introduced experimental support for vendoring,
   182  enabled by setting the <code>GO15VENDOREXPERIMENT</code> environment variable to <code>1</code>.
   183  Go 1.6 keeps the vendoring support, no longer considered experimental,
   184  and enables it by default.
   185  It can be disabled explicitly by setting
   186  the <code>GO15VENDOREXPERIMENT</code> environment variable to <code>0</code>.
   187  Go 1.7 will remove support for the environment variable.
   188  </p>
   189  
   190  <p>
   191  The most likely problem caused by enabling vendoring by default happens
   192  in source trees containing an existing directory named <code>vendor</code> that
   193  does not expect to be interpreted according to new vendoring semantics.
   194  In this case, the simplest fix is to rename the directory to anything other
   195  than <code>vendor</code> and update any affected import paths.
   196  </p>
   197  
   198  <p>
   199  For details about vendoring,
   200  see the documentation for the <a href="/cmd/go/#hdr-Vendor_Directories"><code>go</code> command</a>
   201  and the <a href="https://golang.org/s/go15vendor">design document</a>.
   202  </p>
   203  
   204  <p>
   205  There is a new build flag, <code>-msan</code>,
   206  that compiles Go with support for the LLVM memory sanitizer.
   207  This is intended mainly for use when linking against C or C++ code
   208  that is being checked with the memory sanitizer.
   209  </p>
   210  
   211  <h3 id="doc_command">Go doc command</h3>
   212  
   213  <p>
   214  Go 1.5 introduced the
   215  <a href="/cmd/go/#hdr-Show_documentation_for_package_or_symbol"><code>go doc</code></a> command,
   216  which allows references to packages using only the package name, as in
   217  <code>go</code> <code>doc</code> <code>http</code>.
   218  In the event of ambiguity, the Go 1.5 behavior was to use the package
   219  with the lexicographically earliest import path.
   220  In Go 1.6, ambiguity is resolved by preferring import paths with
   221  fewer elements, breaking ties using lexicographic comparison.
   222  An important effect of this change is that original copies of packages
   223  are now preferred over vendored copies.
   224  Successful searches also tend to run faster.
   225  </p>
   226  
   227  <h3 id="vet_command">Go vet command</h3>
   228  
   229  <p>
   230  The <a href="/cmd/vet"><code>go vet</code></a> command now diagnoses
   231  passing function or method values as arguments to <code>Printf</code>,
   232  such as when passing <code>f</code> where <code>f()</code> was intended.
   233  </p>
   234  
   235  <h2 id="performance">Performance</h2>
   236  
   237  <p>
   238  As always, the changes are so general and varied that precise statements
   239  about performance are difficult to make.
   240  Some programs may run faster, some slower.
   241  On average the programs in the Go 1 benchmark suite run a few percent faster in Go 1.6
   242  than they did in Go 1.5.
   243  The garbage collector's pauses are even lower than in Go 1.5,
   244  although the effect is likely only noticeable for programs using
   245  a large amount of memory.
   246  </p>
   247  
   248  <p>
   249  There have been significant optimizations bringing more than 10% improvements
   250  to implementations of the
   251  <a href="/pkg/compress/bzip2/"><code>compress/bzip2</code></a>,
   252  <a href="/pkg/compress/gzip/"><code>compress/gzip</code></a>,
   253  <a href="/pkg/crypto/aes/"><code>crypto/aes</code></a>,
   254  <a href="/pkg/crypto/elliptic/"><code>crypto/elliptic</code></a>,
   255  <a href="/pkg/crypto/ecdsa/"><code>crypto/ecdsa</code></a>, and
   256  <a href="/pkg/sort/"><code>sort</code></a> packages.
   257  </p>
   258  
   259  <h2 id="library">Core library</h2>
   260  
   261  <h3 id="http2">HTTP/2</h3>
   262  
   263  <p>
   264  Go 1.6 adds transparent support in the
   265  <a href="/pkg/net/http/"><code>net/http</code></a> package
   266  for the new <a href="https://http2.github.io/">HTTP/2 protocol</a>.
   267  Go clients and servers will automatically use HTTP/2 as appropriate when using HTTPS.
   268  There is no exported API specific to details of the HTTP/2 protocol handling,
   269  just as there is no exported API specific to HTTP/1.1.
   270  </p>
   271  
   272  <p>
   273  Programs that must disable HTTP/2 can do so by setting
   274  <a href="/pkg/net/http/#Transport"><code>Transport.TLSNextProto</code></a> (for clients)
   275  or
   276  <a href="/pkg/net/http/#Server"><code>Server.TLSNextProto</code></a> (for servers)
   277  to a non-nil, empty map.
   278  </p>
   279  
   280  <p>
   281  Programs that must adjust HTTP/2 protocol-specific details can import and use
   282  <a href="https://golang.org/x/net/http2"><code>golang.org/x/net/http2</code></a>,
   283  in particular its
   284  <a href="https://godoc.org/golang.org/x/net/http2/#ConfigureServer">ConfigureServer</a>
   285  and
   286  <a href="https://godoc.org/golang.org/x/net/http2/#ConfigureTransport">ConfigureTransport</a>
   287  functions.
   288  </p>
   289  
   290  <h3 id="runtime">Runtime</h3>
   291  
   292  <p>
   293  The runtime has added lightweight, best-effort detection of concurrent misuse of maps.
   294  As always, if one goroutine is writing to a map, no other goroutine should be
   295  reading or writing the map concurrently.
   296  If the runtime detects this condition, it prints a diagnosis and crashes the program.
   297  The best way to find out more about the problem is to run the program
   298  under the
   299  <a href="https://blog.golang.org/race-detector">race detector</a>,
   300  which will more reliably identify the race
   301  and give more detail.
   302  </p>
   303  
   304  <p>
   305  For program-ending panics, the runtime now by default
   306  prints only the stack of the running goroutine,
   307  not all existing goroutines.
   308  Usually only the current goroutine is relevant to a panic,
   309  so omitting the others significantly reduces irrelevant output
   310  in a crash message.
   311  To see the stacks from all goroutines in crash messages, set the environment variable
   312  <code>GOTRACEBACK</code> to <code>all</code>
   313  or call
   314  <a href="/pkg/runtime/debug/#SetTraceback"><code>debug.SetTraceback</code></a>
   315  before the crash, and rerun the program.
   316  See the <a href="/pkg/runtime/#hdr-Environment_Variables">runtime documentation</a> for details.
   317  </p>
   318  
   319  <p>
   320  <em>Updating</em>:
   321  Uncaught panics intended to dump the state of the entire program,
   322  such as when a timeout is detected or when explicitly handling a received signal,
   323  should now call <code>debug.SetTraceback("all")</code> before panicking.
   324  Searching for uses of
   325  <a href="/pkg/os/signal/#Notify"><code>signal.Notify</code></a> may help identify such code.
   326  </p>
   327  
   328  <h3 id="reflect">Reflect</h3>
   329  
   330  <p>
   331  The
   332  <a href="/pkg/reflect/"><code>reflect</code></a> package has
   333  <a href="https://golang.org/issue/12367">resolved a long-standing incompatibility</a>
   334  between the gc and gccgo toolchains
   335  regarding embedded unexported struct types containing exported fields.
   336  Code that walks data structures using reflection, especially to implement
   337  serialization in the spirit
   338  of the
   339  <a href="/pkg/encoding/json/"><code>encoding/json</code></a> and
   340  <a href="/pkg/encoding/xml/"><code>encoding/xml</code></a> packages,
   341  may need to be updated.
   342  </p>
   343  
   344  <p>
   345  The problem arises when using reflection to walk through
   346  an embedded unexported struct-typed field
   347  into an exported field of that struct.
   348  In this case, <code>reflect</code> had incorrectly reported
   349  the embedded field as exported, by returning an empty <code>Field.PkgPath</code>.
   350  Now it correctly reports the field as unexported
   351  but ignores that fact when evaluating access to exported fields
   352  contained within the struct.
   353  </p>
   354  
   355  <p>
   356  <em>Updating</em>:
   357  Typically, code that previously walked over structs and used
   358  </p>
   359  
   360  <pre>
   361  f.PkgPath != ""
   362  </pre>
   363  
   364  <p>
   365  to exclude inaccessible fields
   366  should now use
   367  </p>
   368  
   369  <pre>
   370  f.PkgPath != "" &amp;&amp; !f.Anonymous
   371  </pre>
   372  
   373  <p>
   374  For example, see the changes to the implementations of
   375  <a href="https://go-review.googlesource.com/#/c/14011/2/src/encoding/json/encode.go"><code>encoding/json</code></a> and
   376  <a href="https://go-review.googlesource.com/#/c/14012/2/src/encoding/xml/typeinfo.go"><code>encoding/xml</code></a>.
   377  </p>
   378  
   379  <h3 id="sort">Sorting</h3>
   380  
   381  <p>
   382  In the
   383  <a href="/pkg/sort/"><code>sort</code></a>
   384  package,
   385  the implementation of
   386  <a href="/pkg/sort/#Sort"><code>Sort</code></a>
   387  has been rewritten to make about 10% fewer calls to the
   388  <a href="/pkg/sort/#Interface"><code>Interface</code></a>'s
   389  <code>Less</code> and <code>Swap</code>
   390  methods, with a corresponding overall time savings.
   391  The new algorithm does choose a different ordering than before
   392  for values that compare equal (those pairs for which <code>Less(i,</code> <code>j)</code> and <code>Less(j,</code> <code>i)</code> are false).
   393  </p>
   394  
   395  <p>
   396  <em>Updating</em>:
   397  The definition of <code>Sort</code> makes no guarantee about the final order of equal values,
   398  but the new behavior may still break programs that expect a specific order.
   399  Such programs should either refine their <code>Less</code> implementations
   400  to report the desired order
   401  or should switch to
   402  <a href="/pkg/sort/#Stable"><code>Stable</code></a>,
   403  which preserves the original input order
   404  of equal values.
   405  </p>
   406  
   407  <h3 id="template">Templates</h3>
   408  
   409  <p>
   410  In the
   411  <a href="/pkg/text/template/">text/template</a> package,
   412  there are two significant new features to make writing templates easier.
   413  </p>
   414  
   415  <p>
   416  First, it is now possible to <a href="/pkg/text/template/#hdr-Text_and_spaces">trim spaces around template actions</a>,
   417  which can make template definitions more readable.
   418  A minus sign at the beginning of an action says to trim space before the action,
   419  and a minus sign at the end of an action says to trim space after the action.
   420  For example, the template
   421  </p>
   422  
   423  <pre>
   424  {{"{{"}}23 -}}
   425     &lt;
   426  {{"{{"}}- 45}}
   427  </pre>
   428  
   429  <p>
   430  formats as <code>23&lt;45</code>.
   431  </p>
   432  
   433  <p>
   434  Second, the new <a href="/pkg/text/template/#hdr-Actions"><code>{{"{{"}}block}}</code> action</a>,
   435  combined with allowing redefinition of named templates,
   436  provides a simple way to define pieces of a template that
   437  can be replaced in different instantiations.
   438  For example, the template
   439  </p>
   440  
   441  <pre>
   442  &lt;title&gt;{{"{{"}}block "title"}}Page Title{{"{{"}}end}}&lt;/title&gt;
   443  &lt;body&gt;
   444  &lt;h1&gt;{{"{{"}}template "title"}}&lt;/h1&gt;
   445  {{"{{"}}block "page"}}Main text{{"{{"}}end}}
   446  </pre>
   447  
   448  <p>
   449  defines the basic formatting of a web page. A program can then
   450  overlay that template with new definitions for the <code>"title"</code>
   451  and <code>"page"</code> blocks to reuse the formatting for another page.
   452  </p>
   453  
   454  <h3 id="minor_library_changes">Minor changes to the library</h3>
   455  
   456  <ul>
   457  
   458  <li>
   459  In the <a href="/pkg/archive/zip/"><code>archive/zip</code></a> package, the
   460  <a href="/pkg/archive/zip/#Reader"><code>Reader</code></a> type now has a
   461  <a href="/pkg/archive/zip/#Reader.RegisterDecompressor"><code>RegisterDecompressor</code></a> method,
   462  and the
   463  <a href="/pkg/archive/zip/#Writer"><code>Writer</code></a> type now has a
   464  <a href="/pkg/archive/zip/#Writer.RegisterCompressor"><code>RegisterCompressor</code></a> method,
   465  enabling control over compression options for individual zip files.
   466  These take precedence over the pre-existing global
   467  <a href="/pkg/archive/zip/#RegisterDecompressor"><code>RegisterDecompressor</code></a> and
   468  <a href="/pkg/archive/zip/#RegisterCompressor"><code>RegisterCompressor</code></a> functions.
   469  </li>
   470  
   471  <li>
   472  The <a href="/pkg/bufio/"><code>bufio</code></a> package's
   473  <a href="/pkg/bufio/#Scanner"><code>Scanner</code></a> type now has a
   474  <a href="/pkg/bufio/#Scanner.Buffer"><code>Buffer</code></a> method,
   475  to specify an initial buffer and maximum buffer size to use during scanning.
   476  This makes it possible, when needed, to scan tokens larger than
   477  <code>MaxScanTokenSize</code>.
   478  Also for the <code>Scanner</code>, the package now defines the
   479  <a href="/pkg/bufio/#ErrFinalToken"><code>ErrFinalToken</code></a> error value, for use by
   480  <a href="/pkg/bufio/#SplitFunc">split functions</a> to abort processing or to return a final empty token.
   481  </li>
   482  
   483  <li>
   484  The <a href="/pkg/compress/flate/"><code>compress/flate</code></a> package
   485  has deprecated its
   486  <a href="/pkg/compress/flate/#ReadError"><code>ReadError</code></a> and
   487  <a href="/pkg/compress/flate/#WriteError"><code>WriteError</code></a> error implementations.
   488  In Go 1.5 they were only rarely returned when an error was encountered;
   489  now they are never returned, although they remain defined for compatibility.
   490  </li>
   491  
   492  <li>
   493  The <a href="/pkg/compress/flate/"><code>compress/flate</code></a>,
   494  <a href="/pkg/compress/gzip/"><code>compress/gzip</code></a>, and
   495  <a href="/pkg/compress/zlib/"><code>compress/zlib</code></a> packages
   496  now report
   497  <a href="/pkg/io/#ErrUnexpectedEOF"><code>io.ErrUnexpectedEOF</code></a> for truncated input streams, instead of
   498  <a href="/pkg/io/#EOF"><code>io.EOF</code></a>.
   499  </li>
   500  
   501  <li>
   502  The <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> package
   503  has a variety of minor changes.
   504  It now allows
   505  <a href="/pkg/crypto/tls/#Listen"><code>Listen</code></a>
   506  to succeed when the
   507  <a href="/pkg/crypto/tls/#Config"><code>Config</code></a>
   508  has a nil <code>Certificates</code>, as long as the <code>GetCertificate</code> callback is set,
   509  it adds support for RSA with AES-GCM cipher suites,
   510  and
   511  it adds a
   512  <a href="/pkg/crypto/tls/#RecordHeaderError"><code>RecordHeaderError</code></a>
   513  to allow clients (in particular, the <a href="/pkg/net/http/"><code>net/http</code></a> package)
   514  to report a better error when attempting a TLS connection to a non-TLS server.
   515  </li>
   516  
   517  <li>
   518  The <a href="/pkg/crypto/x509/"><code>crypto/x509</code></a> package
   519  now permits certificates to contain negative serial numbers
   520  (technically an error, but unfortunately common in practice),
   521  and it defines a new
   522  <a href="/pkg/crypto/x509/#InsecureAlgorithmError"><code>InsecureAlgorithmError</code></a>
   523  to give a better error message when rejecting a certificate
   524  signed with an insecure algorithm like MD5.
   525  </li>
   526  
   527  <li>
   528  The <a href="/pkg/debug/dwarf"><code>debug/dwarf</code></a> and
   529  <a href="/pkg/debug/elf/"><code>debug/elf</code></a> packages
   530  together add support for compressed DWARF sections.
   531  User code needs no updating: the sections are decompressed automatically when read.
   532  </li>
   533  
   534  <li>
   535  The <a href="/pkg/debug/elf/"><code>debug/elf</code></a> package
   536  adds support for general compressed ELF sections.
   537  User code needs no updating: the sections are decompressed automatically when read.
   538  However, compressed
   539  <a href="/pkg/debug/elf/#Section"><code>Section</code></a>'s do not support random access:
   540  they have a nil <code>ReaderAt</code> field.
   541  </li>
   542  
   543  <li>
   544  The <a href="/pkg/encoding/asn1/"><code>encoding/asn1</code></a> package
   545  now exports
   546  <a href="/pkg/encoding/asn1/#pkg-constants">tag and class constants</a>
   547  useful for advanced parsing of ASN.1 structures.
   548  </li>
   549  
   550  <li>
   551  Also in the <a href="/pkg/encoding/asn1/"><code>encoding/asn1</code></a> package,
   552  <a href="/pkg/encoding/asn1/#Unmarshal"><code>Unmarshal</code></a> now rejects various non-standard integer and length encodings.
   553  </li>
   554  
   555  <li>
   556  The <a href="/pkg/encoding/json/"><code>encoding/json</code></a> package
   557  now checks the syntax of a
   558  <a href="/pkg/encoding/json/#Number"><code>Number</code></a>
   559  before marshaling it, requiring that it conforms to the JSON specification for numeric values.
   560  As in previous releases, the zero <code>Number</code> (an empty string) is marshaled as a literal 0 (zero).
   561  </li>
   562  
   563  <li>
   564  The <a href="/pkg/encoding/xml/"><code>encoding/xml</code></a> package's
   565  <a href="/pkg/encoding/xml/#Marshal"><code>Marshal</code></a>
   566  function now supports a <code>cdata</code> attribute, such as <code>chardata</code>
   567  but encoding its argument in one or more <code>&lt;![CDATA[ ... ]]&gt;</code> tags.
   568  </li>
   569  
   570  <li>
   571  Also in the <a href="/pkg/encoding/xml/"><code>encoding/xml</code></a> package,
   572  <a href="/pkg/encoding/xml/#Decoder"><code>Decoder</code></a>'s
   573  <a href="/pkg/encoding/xml/#Decoder.Token"><code>Token</code></a> method
   574  now reports an error when encountering EOF before seeing all open tags closed,
   575  consistent with its general requirement that tags in the input be properly matched.
   576  To avoid that requirement, use
   577  <a href="/pkg/encoding/xml/#Decoder.RawToken"><code>RawToken</code></a>.
   578  </li>
   579  
   580  <li>
   581  The <a href="/pkg/fmt/"><code>fmt</code></a> package now allows
   582  any integer type as an argument to
   583  <a href="/pkg/fmt/#Printf"><code>Printf</code></a>'s <code>*</code> width and precision specification.
   584  In previous releases, the argument to <code>*</code> was required to have type <code>int</code>.
   585  </li>
   586  
   587  <li>
   588  Also in the <a href="/pkg/fmt/"><code>fmt</code></a> package,
   589  <a href="/pkg/fmt/#Scanf"><code>Scanf</code></a> can now scan hexadecimal strings using %X, as an alias for %x.
   590  Both formats accept any mix of upper- and lower-case hexadecimal.
   591  <a href="golang.org/x/13585">TODO: Keep?</a>
   592  </li>
   593  
   594  <li>
   595  The <a href="/pkg/image/"><code>image</code></a>
   596  and
   597  The <a href="/pkg/image/color/"><code>image/color</code></a> packages
   598  add
   599  <a href="/pkg/image/#NYCbCrA"><code>NYCbCrA</code></a>
   600  and
   601  <a href="/pkg/color/#NYCbCrA"><code>NYCbCrA</code></a>
   602  types, to support Y'CbCr images with non-premultiplied alpha.
   603  </li>
   604  
   605  <li>
   606  The <a href="/pkg/io/"><code>io</code></a> package's
   607  <a href="/pkg/io/#MultiWriter"><code>MultiWriter</code></a>
   608  implementation now implements a <code>WriteString</code> method,
   609  for use by
   610  <a href="/pkg/io/#WriteString"><code>WriteString</code></a>.
   611  </li>
   612  
   613  <li>
   614  In the <a href="/pkg/math/big/"><code>math/big</code></a> package,
   615  <a href="/pkg/math/big/#Int"><code>Int</code></a> adds
   616  <a href="/pkg/math/big/#Int.Append"><code>Append</code></a>
   617  and
   618  <a href="/pkg/math/big/#Int.Text"><code>Text</code></a>
   619  methods to give more control over printing.
   620  </li>
   621  
   622  <li>
   623  Also in the <a href="/pkg/math/big/"><code>math/big</code></a> package,
   624  <a href="/pkg/math/big/#Float"><code>Float</code></a> now implements
   625  <a href="/pkg/encoding/#TextMarshaler"><code>encoding.TextMarshaler</code></a> and
   626  <a href="/pkg/encoding/#TextUnmarshaler"><code>encoding.TextUnmarshaler</code></a>,
   627  allowing it to be serialized in a natural form by the
   628  <a href="/pkg/encoding/json/"><code>encoding/json</code></a> and
   629  <a href="/pkg/encoding/xml/"><code>encoding/xml</code></a> packages.
   630  </li>
   631  
   632  <li>
   633  Also in the <a href="/pkg/math/big/"><code>math/big</code></a> package,
   634  <a href="/pkg/math/big/#Float"><code>Float</code></a>'s
   635  <a href="/pkg/math/big/#Float.Append"><code>Append</code></a> method now supports the special precision argument -1.
   636  As in
   637  <a href="/pkg/strconv/#ParseFloat"><code>strconv.ParseFloat</code></a>,
   638  precision -1 means to use the smallest number of digits necessary such that
   639  <a href="/pkg/math/big/#Float.Parse"><code>Parse</code></a>
   640  reading the result into a <code>Float</code> of the same precision
   641  will yield the original value.
   642  </li>
   643  
   644  <li>
   645  The <a href="/pkg/math/rand/"><code>math/rand</code></a> package
   646  adds a
   647  <a href="/pkg/math/rand/#Read"><code>Read</code></a>
   648  function, and likewise
   649  <a href="/pkg/math/rand/#Rand"><code>Rand</code></a> adds a
   650  <a href="/pkg/math/rand/#Rand.Read"><code>Read</code></a> method.
   651  These make it easier to generate pseudorandom test data.
   652  Note that, like the rest of the package,
   653  these should not be used in cryptographic settings;
   654  for such purposes, use the <a href="/pkg/crypto/rand/"><code>crypto/rand</code></a> package instead.
   655  </li>
   656  
   657  <li>
   658  The <a href="/pkg/net/"><code>net</code></a> package's
   659  <a href="/pkg/net/#ParseMAC"><code>ParseMAC</code></a> function now accepts 20-byte IP-over-InfiniBand (IPoIB) link-layer addresses.
   660  </li>
   661  
   662  
   663  <li>
   664  Also in the <a href="/pkg/net/"><code>net</code></a> package,
   665  there have been a few changes to DNS lookups.
   666  First, the
   667  <a href="/pkg/net/#DNSError"><code>DNSError</code></a> error implementation now implements
   668  <a href="/pkg/net/#Error"><code>Error</code></a>,
   669  and in particular its new
   670  <a href="/pkg/net/#DNSError.IsTemporary"><code>IsTemporary</code></a>
   671  method returns true for DNS server errors.
   672  Second, DNS lookup functions such as
   673  <a href="/pkg/net/#LookupAddr"><code>LookupAddr</code></a>
   674  now return rooted domain names (with a trailing dot)
   675  on Plan 9 and Windows, to match the behavior of Go on Unix systems.
   676  TODO: Third, lookups satisfied from /etc/hosts now add a trailing dot as well,
   677  so that looking up 127.0.0.1 typically now returns &ldquo;localhost.&rdquo; not &ldquo;localhost&rdquo;.
   678  This is arguably a mistake but is not yet fixed. See https://golang.org/issue/13564.
   679  </li>
   680  
   681  <li>
   682  The <a href="/pkg/net/http/"><code>net/http</code></a> package has
   683  a number of minor additions beyond the HTTP/2 support already discussed.
   684  First, the
   685  <a href="/pkg/http/#FileServer"><code>FileServer</code></a> now sorts its generated directory listings by file name.
   686  Second, the
   687  <a href="/pkg/http/#Client"><code>Client</code></a> now allows user code to set the
   688  <code>Expect:</code> <code>100-continue</code> header.
   689  Third, there are
   690  <a href="/pkg/net/http/#pkg-constants">four new error codes</a> from RFC 6585:
   691  <code>StatusPreconditionRequired</code> (428),
   692  <code>StatusTooManyRequests</code> (429),
   693  <code>StatusRequestHeaderFieldsTooLarge</code> (431),
   694  and
   695  <code>StatusNetworkAuthenticationRequired</code> (511).
   696  </li>
   697  
   698  <li>
   699  Also in the <a href="/pkg/net/http/"><code>net/http</code></a> package,
   700  there are a few changes related to the handling of a
   701  <a href="/pkg/http/#Request"><code>Request</code></a> data structure with its <code>Method</code> field set to the empty string.
   702  An empty <code>Method</code> field has always been documented as an alias for <code>"GET"</code>
   703  and it remains so.
   704  However, Go 1.6 fixes a few routines that did not treat an empty
   705  <code>Method</code> the same as an explicit <code>"GET"</code>.
   706  Most notably, in previous releases
   707  <a href="/pkg/http/#Client"><code>Client</code></a> followed redirects only with
   708  <code>Method</code> set explicitly to <code>"GET"</code>;
   709  in Go 1.6 <code>Client</code> also follows redirects for the empty <code>Method</code>.
   710  Finally,
   711  <a href="/pkg/http/#NewRequest"><code>NewRequest</code></a> accepts a <code>method</code> argument that has not been
   712  documented as allowed to be empty.
   713  In past releases, passing an empty <code>method</code> argument resulted
   714  in a <code>Request</code> with an empty <code>Method</code> field.
   715  In Go 1.6, the resulting <code>Request</code> always has an initialized
   716  <code>Method</code> field: if its argument is an empty string, <code>NewRequest</code>
   717  sets the <code>Method</code> field in the returned <code>Request</code> to <code>"GET"</code>.
   718  </li>
   719  
   720  <li>
   721  The <a href="/pkg/net/http/httptest/"><code>net/http/httptest</code></a> package's
   722  <a href="/pkg/net/http/httptest/#ResponseRecorder"><code>ResponseRecorder</code></a> now initializes a default Content-Type header
   723  using the same content-sniffing algorithm as in
   724  <a href="/pkg/net/http/#Server"><code>http.Server</code></a>.
   725  </li>
   726  
   727  <li>
   728  The <a href="/pkg/net/url/"><code>net/url</code></a> package's
   729  <a href="/pkg/net/url/#Parse"><code>Parse</code></a> is now stricter and more spec-compliant regarding the parsing
   730  of host names.
   731  For example, spaces in the host name are no longer accepted.
   732  </li>
   733  
   734  <li>
   735  Also in the <a href="/pkg/net/url/"><code>net/url</code></a> package,
   736  the <a href="/pkg/net/url/#Error"><code>Error</code></a> type now implements
   737  <a href="/pkg/net/#Error"><code>net.Error</code></a>.
   738  </li>
   739  
   740  <li>
   741  The <a href="/pkg/os/"><code>os</code></a> package's
   742  <a href="/pkg/os/#IsExist"><code>IsExist</code></a>,
   743  <a href="/pkg/os/#IsNotExist"><code>IsNotExist</code></a>,
   744  and
   745  <a href="/pkg/os/#IsPermission"><code>IsPermission</code></a>
   746  now return correct results when inquiring about an
   747  <a href="/pkg/os/#SyscallError"><code>SyscallError</code></a>.
   748  </li>
   749  
   750  <li>
   751  In the <a href="/pkg/os/exec/"><code>os/exec</code></a> package,
   752  <a href="/pkg/os/exec/#Cmd"><code>Cmd</code></a>'s
   753  <a href="/pkg/os/exec/#Cmd.Output"><code>Output</code></a> method continues to return an
   754  <a href="/pkg/os/exec/#ExitError"><code>ExitError</code></a> when a command exits with an unsuccessful status.
   755  If standard error would otherwise have been discarded,
   756  the returned <code>ExitError</code> now holds a prefix
   757  (currently 32 kB) of the failed command's standard error output,
   758  for debugging or for inclusion in error messages.
   759  The <code>ExitError</code>'s
   760  <a href="/pkg/os/exec/#ExitError.String"><code>String</code></a>
   761  method does not show the captured standard error;
   762  programs must retrieve it from the data structure
   763  separately.
   764  </li>
   765  
   766  <li>
   767  On Windows, the <a href="/pkg/path/filepath/"><code>path/filepath</code></a> package's
   768  <a href="/pkg/path/filepath/#Join"><code>Join</code></a> function now correctly handles the case when the base is a relative drive path.
   769  For example, <code>Join(`c:`,</code> <code>`a`)</code> now
   770  returns <code>`c:a`</code> instead of <code>`c:\a`</code> as in past releases.
   771  This may affect code that expects the incorrect result.
   772  </li>
   773  
   774  <li>
   775  In the <a href="/pkg/regexp/"><code>regexp</code></a> package,
   776  the
   777  <a href="/pkg/regexp/#Regexp"><code>Regexp</code></a> type has always been safe for use by
   778  concurrent goroutines.
   779  It uses a <a href="/pkg/sync/#Mutex"><code>sync.Mutex</code></a> to protect
   780  a cache of scratch spaces used during regular expression searches.
   781  Some high-concurrency servers using the same <code>Regexp</code> from many goroutines
   782  have seen degraded performance due to contention on that mutex.
   783  To help such servers, <code>Regexp</code> now has a
   784  <a href="/pkg/regexp/#Regexp.Copy"><code>Copy</code></a> method,
   785  which makes a copy of a <code>Regexp</code> that shares most of the structure
   786  of the original but has its own scratch space cache.
   787  Two goroutines can use different copies of a <code>Regexp</code>
   788  without mutex contention.
   789  A copy does have additional space overhead, so <code>Copy</code>
   790  should only be used when contention has been observed.
   791  </li>
   792  
   793  <li>
   794  The <a href="/pkg/strconv/"><code>strconv</code></a> package adds
   795  <a href="/pkg/strconv/#IsGraphic"><code>IsGraphic</code></a>,
   796  <a href="/pkg/strconv/#QuoteToGraphic"><code>QuoteToGraphic</code></a>,
   797  <a href="/pkg/strconv/#QuoteRuneToGraphic"><code>QuoteRuneToGraphic</code></a>,
   798  <a href="/pkg/strconv/#AppendQuoteToGraphic"><code>AppendQuoteToGraphic</code></a>,
   799  and
   800  <a href="/pkg/strconv/#AppendQuoteRuneToGraphic"><code>AppendQuoteRuneToGraphic</code></a>,
   801  analogous to
   802  <a href="/pkg/strconv/#IsPrint"><code>IsPrint</code></a>,
   803  <a href="/pkg/strconv/#QuoteToPrint"><code>QuoteToPrint</code></a>,
   804  and so on.
   805  The <code>Print</code> family escapes all space characters except ASCII space (U+0020).
   806  In contrast, the <code>Graphic</code> family does not escape any Unicode space characters (category Zs).
   807  </li>
   808  
   809  <li>
   810  In the <a href="/pkg/testing/"><code>testing</code></a> package,
   811  when a test calls
   812  <a href="/pkg/testing/#T.Parallel">t.Parallel</a>,
   813  that test is paused until all non-parallel tests complete, and then
   814  that test continues execution with all other parallel tests.
   815  Go 1.6 changes the time reported for such a test:
   816  previously the time counted only the parallel execution,
   817  but now it also counts the time from the start of testing
   818  until the call to <code>t.Parallel</code>.
   819  </li>
   820  
   821  <li>
   822  The <a href="/pkg/text/template/"><code>text/template</code></a> package
   823  contains two minor changes, in addition to the <a href="#template">major changes</a>
   824  described above.
   825  First, it adds a new
   826  <a href="/pkg/text/template/#ExecError"><code>ExecError</code></a> type
   827  returned for any error during
   828  <a href="/pkg/text/template/#Template.Execute"><code>Execute</code></a>
   829  that does not originate in a <code>Write</code> to the underlying writer.
   830  Callers can distinguish template usage errors from I/O errors by checking for
   831  <code>ExecError</code>.
   832  Second, the
   833  <a href="/pkg/text/template/#Template.Funcs"><code>Funcs</code></a> method
   834  now checks that the names used as keys in the
   835  <a href="/pkg/text/template/#FuncMap"><code>FuncMap</code></a>
   836  are identifiers that can appear in a template function invocation.
   837  If not, <code>Funcs</code> panics.
   838  </li>
   839  
   840  <li>
   841  The <a href="/pkg/time/"><code>time</code></a> package's
   842  <a href="/pkg/time/#Parse"><code>Parse</code></a> function has always rejected any day of month larger than 31,
   843  such as January 32.
   844  In Go 1.6, <code>Parse</code> now also rejects February 29 in non-leap years,
   845  February 30, February 31, April 31, June 31, September 31, and November 31.
   846  </li>
   847  
   848  </ul>
   849