github.com/alash3al/go@v0.0.0-20150827002835-d497eeb00540/doc/go1.5.html (about)

     1  <!--{
     2  	"Title": "Go 1.5 Release Notes",
     3  	"Path":  "/doc/go1.5",
     4  	"Template": true
     5  }-->
     6  
     7  
     8  <h2 id="introduction">Introduction to Go 1.5</h2>
     9  
    10  <p>
    11  The latest Go release, version 1.5,
    12  is a significant release, including major architectural changes to the implementation.
    13  Despite that, we expect almost all Go programs to continue to compile and run as before,
    14  because the release still maintains the Go 1 <a href="/doc/go1compat.html">promise
    15  of compatibility</a>.
    16  </p>
    17  
    18  <p>
    19  The biggest developments in the implementation are:
    20  </p>
    21  
    22  <ul>
    23  
    24  <li>
    25  The compiler and runtime are now written entirely in Go (with a little assembler).
    26  C is no longer involved in the implementation, and so the C compiler that was
    27  once necessary for building the distribution is gone.
    28  </li>
    29  
    30  <li>
    31  The garbage collector is now <a href="https://golang.org/s/go14gc">concurrent</a> and provides dramatically lower
    32  pause times by running, when possible, in parallel with other goroutines.
    33  </li>
    34  
    35  <li>
    36  By default, Go programs run with <code>GOMAXPROCS</code> set to the
    37  number of cores available; in prior releases it defaulted to 1.
    38  </li>
    39  
    40  <li>
    41  Support for <a href="https://golang.org/s/go14internal">internal packages</a>
    42  is now provided for all repositories, not just the Go core.
    43  </li>
    44  
    45  <li>
    46  The <code>go</code> command now provides <a href="https://golang.org/s/go15vendor">experimental
    47  support</a> for "vendoring" external dependencies.
    48  </li>
    49  
    50  <li>
    51  A new <code>go tool trace</code> command supports fine-grained
    52  tracing of program execution.
    53  </li>
    54  
    55  <li>
    56  A new <code>go doc</code> command (distinct from <code>godoc</code>)
    57  is customized for command-line use.
    58  </li>
    59  
    60  </ul>
    61  
    62  <p>
    63  These and a number of other changes to the implementation and tools
    64  are discussed below.
    65  </p>
    66  
    67  <p>
    68  The release also contains one small language change involving map literals.
    69  </p>
    70  
    71  <p>
    72  Finally, the timing of the <a href="https://golang.org/s/releasesched">release</a>
    73  strays from the usual six-month interval,
    74  both to provide more time to prepare this major release and to shift the schedule thereafter to
    75  time the release dates more conveniently.
    76  </p>
    77  
    78  <h2 id="language">Changes to the language</h2>
    79  
    80  <h3 id="map_literals">Map literals</h3>
    81  
    82  <p>
    83  Due to an oversight, the rule that allowed the element type to be elided from slice literals was not
    84  applied to map keys.
    85  This has been <a href="/cl/2591">corrected</a> in Go 1.5.
    86  An example will make this clear.
    87  As of Go 1.5, this map literal,
    88  </p>
    89  
    90  <pre>
    91  m := map[Point]string{
    92      Point{29.935523, 52.891566}:   "Persepolis",
    93      Point{-25.352594, 131.034361}: "Uluru",
    94      Point{37.422455, -122.084306}: "Googleplex",
    95  }
    96  </pre>
    97  
    98  <p>
    99  may be written as follows, without the <code>Point</code> type listed explicitly:
   100  </p>
   101  
   102  <pre>
   103  m := map[Point]string{
   104      {29.935523, 52.891566}:   "Persepolis",
   105      {-25.352594, 131.034361}: "Uluru",
   106      {37.422455, -122.084306}: "Googleplex",
   107  }
   108  </pre>
   109  
   110  <h2 id="implementation">The Implementation</h2>
   111  
   112  <h3 id="c">No more C</h3>
   113  
   114  <p>
   115  The compiler and runtime are now implemented in Go and assembler, without C.
   116  The only C source left in the tree is related to testing or to <code>cgo</code>.
   117  There was a C compiler in the tree in 1.4 and earlier.
   118  It was used to build the runtime; a custom compiler was necessary in part to
   119  guarantee the C code would work with the stack management of goroutines.
   120  Since the runtime is in Go now, there is no need for this C compiler and it is gone.
   121  Details of the process to eliminate C are discussed <a href="https://golang.org/s/go13compiler">elsewhere</a>.
   122  </p>
   123  
   124  <p>
   125  The conversion from C was done with the help of custom tools created for the job.
   126  Most important, the compiler was actually moved by automatic translation of
   127  the C code into Go.
   128  It is in effect the same program in a different language.
   129  It is not a new implementation
   130  of the compiler so we expect the process will not have introduced new compiler
   131  bugs.
   132  An overview of this process is available in the slides for
   133  <a href="https://talks.golang.org/2015/gogo.slide">this presentation</a>.
   134  </p>
   135  
   136  <h3 id="compiler_and_tools">Compiler and tools</h3>
   137  
   138  <p>
   139  Independent of but encouraged by the move to Go, the names of the tools have changed.
   140  The old names <code>6g</code>, <code>8g</code> and so on are gone; instead there
   141  is just one binary, accessible as <code>go</code> <code>tool</code> <code>compile</code>,
   142  that compiles Go source into binaries suitable for the architecture and operating system
   143  specified by <code>$GOARCH</code> and <code>$GOOS</code>.
   144  Similarly, there is now one linker (<code>go</code> <code>tool</code> <code>link</code>)
   145  and one assembler (<code>go</code> <code>tool</code> <code>asm</code>).
   146  The linker was translated automatically from the old C implementation,
   147  but the assembler is a new native Go implementation discussed
   148  in more detail below.
   149  </p>
   150  
   151  <p>
   152  Similar to the drop of the names <code>6g</code>, <code>8g</code>, and so on,
   153  the output of the compiler and assembler are now given a plain <code>.o</code> suffix
   154  rather than <code>.8</code>, <code>.6</code>, etc.
   155  </p>
   156  
   157  
   158  <h3 id="gc">Garbage collector</h3>
   159  
   160  <p>
   161  The garbage collector has been re-engineered for 1.5 as part of the development
   162  outlined in the <a href="https://golang.org/s/go14gc">design document</a>.
   163  Expected latencies are much lower than with the collector
   164  in prior releases, through a combination of advanced algorithms,
   165  better <a href="https://golang.org/s/go15gcpacing">scheduling</a> of the collector,
   166  and running more of the collection in parallel with the user program.
   167  The "stop the world" phase of the collector
   168  will almost always be under 10 milliseconds and usually much less.
   169  </p>
   170  
   171  <p>
   172  For systems that benefit from low latency, such as user-responsive web sites,
   173  the drop in expected latency with the new collector may be important.
   174  </p>
   175  
   176  <p>
   177  Details of the new collector were presented in a
   178  <a href="https://talks.golang.org/2015/go-gc.pdf">talk</a> at GopherCon 2015.
   179  </p>
   180  
   181  <h3 id="runtime">Runtime</h3>
   182  
   183  <p>
   184  In Go 1.5, the order in which goroutines are scheduled has been changed.
   185  The properties of the scheduler were never defined by the language,
   186  but programs that depend on the scheduling order may be broken
   187  by this change.
   188  We have seen a few (erroneous) programs affected by this change.
   189  If you have programs that implicitly depend on the scheduling
   190  order, you will need to update them.
   191  </p>
   192  
   193  <p>
   194  Another potentially breaking change is that the runtime now
   195  sets the default number of threads to run simultaneously,
   196  defined by <code>GOMAXPROCS</code>, to the number
   197  of cores available on the CPU.
   198  In prior releases the default was 1.
   199  Programs that do not expect to run with multiple cores may
   200  break inadvertently.
   201  They can be updated by removing the restriction or by setting
   202  <code>GOMAXPROCS</code> explicitly.
   203  For a more detailed discussion of this change, see
   204  the <a href="https://golang.org/s/go15gomaxprocs">design document</a>.
   205  </p>
   206  
   207  <h3 id="build">Build</h3>
   208  
   209  <p>
   210  Now that the Go compiler and runtime are implemented in Go, a Go compiler
   211  must be available to compile the distribution from source.
   212  Thus, to build the Go core, a working Go distribution must already be in place.
   213  (Go programmers who do not work on the core are unaffected by this change.)
   214  Any Go 1.4 or later distribution (including <code>gccgo</code>) will serve.
   215  For details, see the <a href="https://golang.org/s/go15bootstrap">design document</a>.
   216  </p>
   217  
   218  <h2 id="ports">Ports</h2>
   219  
   220  <p>
   221  Due mostly to the industry's move away from the 32-bit x86 architecture,
   222  the set of binary downloads provided is reduced in 1.5.
   223  A distribution for the OS X operating system is provided only for the
   224  <code>amd64</code> architecture, not <code>386</code>.
   225  Similarly, the ports for Snow Leopard (Apple OS X 10.6) still work but are no
   226  longer released as a download or maintained since Apple no longer maintains that version
   227  of the operating system.
   228  Also, the <code>dragonfly/386</code> port is no longer supported at all
   229  because DragonflyBSD itself no longer supports the 32-bit 386 architecture.
   230  </p>
   231  
   232  <p>
   233  There are however several new ports available to be built from source.
   234  These include <code>darwin/arm</code> and <code>darwin/arm64</code>.
   235  The new port <code>linux/arm64</code> is mostly in place, but <code>cgo</code>
   236  is only supported using external linking.
   237  </p>
   238  
   239  <p>
   240  Also available as experiments are <code>ppc64</code>
   241  and <code>ppc64le</code> (64-bit PowerPC, big- and little-endian).
   242  Both these ports support <code>cgo</code> but
   243  only with internal linking.
   244  </p>
   245  
   246  <p>
   247  On FreeBSD, Go 1.5 requires FreeBSD 8-STABLE+ because of its new use of the <code>SYSCALL</code> instruction.
   248  </p>
   249  
   250  <p>
   251  On NaCl, Go 1.5 requires SDK version pepper-41. Later pepper versions are not
   252  compatible due to the removal of the sRPC subsystem from the NaCl runtime.
   253  </p>
   254  
   255  <p>
   256  On Darwin, the use of the system X.509 certificate interface can be disabled
   257  with the <code>ios</code> build tag.
   258  </p>
   259  
   260  <p>
   261  The Solaris port now has full support for cgo and the packages
   262  <a href="/pkg/net/"><code>net</code></a> and
   263  <a href="/pkg/crypto/x509/"><code>crypto/x509</code></a>,
   264  as well as a number of other fixes and improvements.
   265  </p>
   266  
   267  <h2 id="tools">Tools</h2>
   268  
   269  <h3 id="translate">Translating</h3>
   270  
   271  <p>
   272  As part of the process to eliminate C from the tree, the compiler and
   273  linker were translated from C to Go.
   274  It was a genuine (machine assisted) translation, so the new programs are essentially
   275  the old programs translated rather than new ones with new bugs.
   276  We are confident the translation process has introduced few if any new bugs,
   277  and in fact uncovered a number of previously unknown bugs, now fixed.
   278  </p>
   279  
   280  <p>
   281  The assembler is a new program, however; it is described below.
   282  </p>
   283  
   284  <h3 id="rename">Renaming</h3>
   285  
   286  <p>
   287  The suites of programs that were the compilers (<code>6g</code>, <code>8g</code>, etc.),
   288  the assemblers (<code>6a</code>, <code>8a</code>, etc.),
   289  and the linkers (<code>6l</code>, <code>8l</code>, etc.)
   290  have each been consolidated into a single tool that is configured
   291  by the environment variables <code>GOOS</code> and <code>GOARCH</code>.
   292  The old names are gone; the new tools are available through the <code>go</code> <code>tool</code>
   293  mechanism as <code>go tool compile</code>,
   294  <code>go tool asm</code>,
   295  <code>and go tool link</code>.
   296  Also, the file suffixes <code>.6</code>, <code>.8</code>, etc. for the
   297  intermediate object files are also gone; now they are just plain <code>.o</code> files.
   298  </p>
   299  
   300  <p>
   301  For example, to build and link a program on amd64 for Darwin
   302  using the tools directly, rather than through <code>go build</code>,
   303  one would run:
   304  </p>
   305  
   306  <pre>
   307  $ export GOOS=darwin GOARCH=amd64
   308  $ go tool compile program.go
   309  $ go tool link program.o
   310  </pre>
   311  
   312  <h3 id="moving">Moving</h3>
   313  
   314  <p>
   315  Because the <a href="/pkg/go/types/"><code>go/types</code></a> package
   316  has now moved into the main repository (see below),
   317  the <a href="/cmd/vet"><code>vet</code></a> and
   318  <a href="/cmd/cover"><code>cover</code></a>
   319  tools have also been moved.
   320  They are no longer maintained in the external <code>golang.org/x/tools</code> repository,
   321  although (deprecated) source still resides there for compatibility with old releases.
   322  </p>
   323  
   324  <h3 id="compiler">Compiler</h3>
   325  
   326  <p>
   327  As described above, the compiler in Go 1.5 is a single Go program,
   328  translated from the old C source, that replaces <code>6g</code>, <code>8g</code>,
   329  and so on.
   330  Its target is configured by the environment variables <code>GOOS</code> and <code>GOARCH</code>.
   331  </p>
   332  
   333  <p>
   334  The 1.5 compiler is mostly equivalent to the old,
   335  but some internal details have changed.
   336  One significant change is that evaluation of constants now uses
   337  the <a href="/pkg/math/big/"><code>math/big</code></a> package
   338  rather than a custom (and less well tested) implementation of high precision
   339  arithmetic.
   340  We do not expect this to affect the results.
   341  </p>
   342  
   343  <p>
   344  For the amd64 architecture only, the compiler has a new option, <code>-dynlink</code>,
   345  that assists dynamic linking by supporting references to Go symbols
   346  defined in external shared libraries.
   347  </p>
   348  
   349  <h3 id="assembler">Assembler</h3>
   350  
   351  <p>
   352  Like the compiler and linker, the assembler in Go 1.5 is a single program
   353  that replaces the suite of assemblers (<code>6a</code>,
   354  <code>8a</code>, etc.) and the environment variables
   355  <code>GOARCH</code> and <code>GOOS</code>
   356  configure the architecture and operating system.
   357  Unlike the other programs, the assembler is a wholly new program
   358  written in Go.
   359  </p>
   360  
   361   <p>
   362  The new assembler is very nearly compatible with the previous
   363  ones, but there are a few changes that may affect some
   364  assembler source files.
   365  See the updated <a href="/doc/asm">assembler guide</a>
   366  for more specific information about these changes. In summary:
   367  
   368  </p>
   369  
   370  <p>
   371  First, the expression evaluation used for constants is a little
   372  different.
   373  It now uses unsigned 64-bit arithmetic and the precedence
   374  of operators (<code>+</code>, <code>-</code>, <code><<</code>, etc.)
   375  comes from Go, not C.
   376  We expect these changes to affect very few programs but
   377  manual verification may be required.
   378  </p>
   379  
   380  <p>
   381  Perhaps more important is that on machines where
   382  <code>SP</code> or <code>PC</code> is only an alias
   383  for a numbered register,
   384  such as <code>R13</code> for the stack pointer and
   385  <code>R15</code> for the hardware program counter
   386  on ARM,
   387  a reference to such a register that does not include a symbol
   388  is now illegal.
   389  For example, <code>SP</code> and <code>4(SP)</code> are
   390  illegal but <code>sym+4(SP)</code> is fine.
   391  On such machines, to refer to the hardware register use its
   392  true <code>R</code> name.
   393  </p>
   394  
   395  <p>
   396  One minor change is that some of the old assemblers
   397  permitted the notation
   398  </p>
   399  
   400  <pre>
   401  constant=value
   402  </pre>
   403  
   404  <p>
   405  to define a named constant.
   406  Since this is always possible to do with the traditional
   407  C-like <code>#define</code> notation, which is still
   408  supported (the assembler includes an implementation
   409  of a simplified C preprocessor), the feature was removed.
   410  </p>
   411  
   412  <h3 id="link">Linker</h3>
   413  
   414  <p>
   415  The linker in Go 1.5 is now one Go program,
   416  that replaces <code>6l</code>, <code>8l</code>, etc.
   417  Its operating system and instruction set are specified
   418  by the environment variables <code>GOOS</code> and <code>GOARCH</code>.
   419  </p>
   420  
   421  <p>
   422  There are several other changes.
   423  The most significant is the addition of a <code>-buildmode</code> option that
   424  expands the style of linking; it now supports
   425  situations such as building shared libraries and allowing other languages
   426  to call into Go libraries.
   427  Some of these were outlined in a <a href="https://golang.org/s/execmodes">design document</a>.
   428  For a list of the available build modes and their use, run
   429  </p>
   430  
   431  <pre>
   432  $ go help buildmode
   433  </pre>
   434  
   435  <p>
   436  Another minor change is that the linker no longer records build time stamps in
   437  the header of Windows executables.
   438  Also, although this may be fixed, Windows cgo executables are missing some
   439  DWARF information.
   440  </p>
   441  
   442  <p>
   443  Finally, the <code>-X</code> flag, which takes two arguments,
   444  as in
   445  </p>
   446  
   447  <pre>
   448  -X importpath.name value
   449  </pre>
   450  
   451  <p>
   452  now also accepts a more common Go flag style with a single argument
   453  that is itself a <code>name=value</code> pair:
   454  </p>
   455  
   456  <pre>
   457  -X importpath.name=value
   458  </pre>
   459  
   460  <p>
   461  Although the old syntax still works, it is recommended that uses of this
   462  flag in scripts and the like be updated to the new form.
   463  </p>
   464  
   465  <h3 id="go_command">Go command</h3>
   466  
   467  <p>
   468  The <a href="/cmd/go"><code>go</code></a> command's basic operation
   469  is unchanged, but there are a number of changes worth noting.
   470  </p>
   471  
   472  <p>
   473  The previous release introduced the idea of a directory internal to a package
   474  being unimportable through the <code>go</code> command.
   475  In 1.4, it was tested with the introduction of some internal elements
   476  in the core repository.
   477  As suggested in the <a href="https://golang.org/s/go14internal">design document</a>,
   478  that change is now being made available to all repositories.
   479  The rules are explained in the design document, but in summary any
   480  package in or under a directory named <code>internal</code> may
   481  be imported by packages rooted in the same subtree.
   482  Existing packages with directory elements named <code>internal</code> may be
   483  inadvertently broken by this change, which was why it was advertised
   484  in the last release.
   485  </p>
   486  
   487  <p>
   488  Another change in how packages are handled is the experimental
   489  addition of support for "vendoring".
   490  For details, see the documentation for the <a href="/cmd/go/#hdr-Vendor_Directories"><code>go</code> command</a>
   491  and the <a href="https://golang.org/s/go15vendor">design document</a>.
   492  </p>
   493  
   494  <p>
   495  There have also been several minor changes.
   496  Read the <a href="/cmd/go">documentation</a> for full details.
   497  </p>
   498  
   499  <ul>
   500  
   501  <li>
   502  SWIG support has been updated such that
   503  <code>.swig</code> and <code>.swigcxx</code>
   504  now require SWIG 3.0.6 or later.
   505  </li>
   506  
   507  <li>
   508  The <code>std</code> (standard library) wildcard package name
   509  now excludes commands.
   510  A new <code>cmd</code> wildcard covers the commands.
   511  </li>
   512  
   513  <li>
   514  A new <code>-asmflags</code> build option
   515  sets flags to pass to the assembler.
   516  However,
   517  the <code>-ccflags</code> build option has been dropped;
   518  it was specific to the old, now deleted C compiler .
   519  </li>
   520  
   521  <li>
   522  A new <code>-buildmode</code> build option
   523  sets the build mode, described above.
   524  </li>
   525  
   526  <li>
   527  A new <code>-pkgdir</code> build option
   528  sets the location of installed package archives,
   529  to help isolate custom builds.
   530  </li>
   531  
   532  <li>
   533  A new <code>-toolexec</code> build option
   534  allows substitution of a different command to invoke
   535  the compiler and so on.
   536  This acts as a custom replacement for <code>go tool</code>.
   537  </li>
   538  
   539  <li>
   540  The <code>test</code> subcommand now has a <code>-count</code>
   541  flag to specify how many times to run each test and benchmark.
   542  The <a href="/pkg/testing/"><code>testing</code></a> package
   543  does the work here, through the <code>-test.count</code> flag.
   544  </li>
   545  
   546  <li>
   547  The <code>generate</code> subcommand has a couple of new features.
   548  The <code>-run</code> option specifies a regular expression to select which directives
   549  to execute; this was proposed but never implemented in 1.4.
   550  The executing pattern now has access to two new environment variables:
   551  <code>$GOLINE</code> returns the source line number of the directive
   552  and <code>$DOLLAR</code> expands to a dollar sign.
   553  </li>
   554  
   555  <li>
   556  The <code>get</code> subcommand now has a <code>-insecure</code>
   557  flag that must be enabled if fetching from an insecure repository, one that
   558  does not encrypt the connection.
   559  </li>
   560  
   561  </ul>
   562  
   563  <h3 id="vet_command">Go vet command</h3>
   564  
   565  <p>
   566  The <a href="/cmd/vet"><code>go tool vet</code></a> command now does
   567  more thorough validation of struct tags.
   568  </p>
   569  
   570  <h3 id="trace_command">Trace command</h3>
   571  
   572  <p>
   573  A new tool is available for dynamic execution tracing of Go programs.
   574  The usage is analogous to how the test coverage tool works.
   575  Generation of traces is integrated into <code>go test</code>,
   576  and then a separate execution of the tracing tool itself analyzes the results:
   577  </p>
   578  
   579  <pre>
   580  $ go test -trace=trace.out path/to/package
   581  $ go tool trace [flags] pkg.test trace.out
   582  </pre>
   583  
   584  <p>
   585  The flags enable the output to be displayed in a browser window.
   586  For details, run <code>go tool trace -help</code>.
   587  There is also a description of the tracing facility in this
   588  <a href="https://talks.golang.org/2015/dynamic-tools.slide">talk</a>
   589  from GopherCon 2015.
   590  </p>
   591  
   592  <h3 id="doc_command">Go doc command</h3>
   593  
   594  <p>
   595  A few releases back, the <code>go doc</code>
   596  command was deleted as being unnecessary.
   597  One could always run "<code>godoc .</code>" instead.
   598  The 1.5 release introduces a new <a href="/cmd/doc"><code>go doc</code></a>
   599  command with a more convenient command-line interface than
   600  <code>godoc</code>'s.
   601  It is designed for command-line usage specifically, and provides a more
   602  compact and focused presentation of the documentation for a package
   603  or its elements, according to the invocation.
   604  It also provides case-insensitive matching and
   605  support for showing the documentation for unexported symbols.
   606  For details run "<code>go help doc</code>".
   607  </p>
   608  
   609  <h3 id="cgo">Cgo</h3>
   610  
   611  <p>
   612  When parsing <code>#cgo</code> lines,
   613  the invocation <code>${SRCDIR}</code> is now
   614  expanded into the path to the source directory.
   615  This allows options to be passed to the
   616  compiler and linker that involve file paths relative to the
   617  source code directory. Without the expansion the paths would be
   618  invalid when the current working directory changes.
   619  </p>
   620  
   621  <p>
   622  Solaris now has full cgo support.
   623  </p>
   624  
   625  <p>
   626  On Windows, cgo now uses external linking by default.
   627  </p>
   628  
   629  <p>
   630  When a C struct ends with a zero-sized field, but the struct itself is
   631  not zero-sized, Go code can no longer refer to the zero-sized field.
   632  Any such references will have to be rewritten.
   633  </p>
   634  
   635  <h2 id="performance">Performance</h2>
   636  
   637  <p>
   638  As always, the changes are so general and varied that precise statements
   639  about performance are difficult to make.
   640  The changes are even broader ranging than usual in this release, which
   641  includes a new garbage collector and a conversion of the runtime to Go.
   642  Some programs may run faster, some slower.
   643  On average the programs in the Go 1 benchmark suite run a few percent faster in Go 1.5
   644  than they did in Go 1.4,
   645  while as mentioned above the garbage collector's pauses are
   646  dramatically shorter, and almost always under 10 milliseconds.
   647  </p>
   648  
   649  <p>
   650  Builds in Go 1.5 will be slower by a factor of about two.
   651  The automatic translation of the compiler and linker from C to Go resulted in
   652  unidiomatic Go code that performs poorly compared to well-written Go.
   653  Analysis tools and refactoring helped to improve the code, but much remains to be done.
   654  Further profiling and optimization will continue in Go 1.6 and future releases.
   655  For more details, see these <a href="https://talks.golang.org/2015/gogo.slide">slides</a>
   656  and associated <a href="https://www.youtube.com/watch?v=cF1zJYkBW4A">video</a>.
   657  </p>
   658  
   659  <h2 id="library">Core library</h2>
   660  
   661  <h3 id="flag">Flag</h3>
   662  
   663  <p>
   664  The flag package's
   665  <a href="/pkg/flag/#PrintDefaults"><code>PrintDefaults</code></a>
   666  function, and method on <a href="/pkg/flag/#FlagSet"><code>FlagSet</code></a>,
   667  have been modified to create nicer usage messages.
   668  The format has been changed to be more human-friendly and in the usage
   669  messages a word quoted with `backquotes` is taken to be the name of the
   670  flag's operand to display in the usage message.
   671  For instance, a flag created with the invocation,
   672  </p>
   673  
   674  <pre>
   675  cpuFlag = flag.Int("cpu", 1, "run `N` processes in parallel")
   676  </pre>
   677  
   678  <p>
   679  will show the help message,
   680  </p>
   681  
   682  <pre>
   683  -cpu N
   684      	run N processes in parallel (default 1)
   685  </pre>
   686  
   687  <p>
   688  Also, the default is now listed only when it is not the zero value for the type.
   689  </p>
   690  
   691  <h3 id="math_big">Floats in math/big</h3>
   692  
   693  <p>
   694  The <a href="/pkg/math/big/"><code>math/big</code></a> package
   695  has a new, fundamental data type,
   696  <a href="/pkg/math/big/#Float"><code>Float</code></a>,
   697  which implements arbitrary-precision floating-point numbers.
   698  A <code>Float</code> value is represented by a boolean sign,
   699  a variable-length mantissa, and a 32-bit fixed-size signed exponent.
   700  The precision of a <code>Float</code> (the mantissa size in bits)
   701  can be specified explicitly or is otherwise determined by the first
   702  operation that creates the value.
   703  Once created, the size of a <code>Float</code>'s mantissa may be modified with the
   704  <a href="/pkg/math/big/#Float.SetPrec"><code>SetPrec</code></a> method.
   705  <code>Floats</code> support the concept of infinities, such as are created by
   706  overflow, but values that would lead to the equivalent of IEEE 754 NaNs
   707  trigger a panic.
   708  <code>Float</code> operations support all IEEE-754 rounding modes.
   709  When the precision is set to 24 (53) bits,
   710  operations that stay within the range of normalized <code>float32</code>
   711  (<code>float64</code>)
   712  values produce the same results as the corresponding IEEE-754
   713  arithmetic on those values.
   714  </p>
   715  
   716  <h3 id="go_types">Go types</h3>
   717  
   718  <p>
   719  The <a href="/pkg/go/types/"><code>go/types</code></a> package
   720  up to now has been maintained in the <code>golang.org/x</code>
   721  repository; as of Go 1.5 it has been relocated to the main repository.
   722  The code at the old location is now deprecated.
   723  There is also a modest API change in the package, discussed below.
   724  </p>
   725  
   726  <p>
   727  Associated with this move, the
   728  <a href="/pkg/go/constant/"><code>go/constant</code></a>
   729  package also moved to the main repository;
   730  it was <code>golang.org/x/tools/exact</code> before.
   731  The <a href="/pkg/go/importer/"><code>go/importer</code></a> package
   732  also moved to the main repository,
   733  as well as some tools described above.
   734  </p>
   735  
   736  <h3 id="net">Net</h3>
   737  
   738  <p>
   739  The DNS resolver in the net package has almost always used <code>cgo</code> to access
   740  the system interface.
   741  A change in Go 1.5 means that on most Unix systems DNS resolution
   742  will no longer require <code>cgo</code>, which simplifies execution
   743  on those platforms.
   744  Now, if the system's networking configuration permits, the native Go resolver
   745  will suffice.
   746  The important effect of this change is that each DNS resolution occupies a goroutine
   747  rather than a thread,
   748  so a program with multiple outstanding DNS requests will consume fewer operating
   749  system resources.
   750  </p>
   751  
   752  <p>
   753  The decision of how to run the resolver applies at run time, not build time.
   754  The <code>netgo</code> build tag that has been used to enforce the use
   755  of the Go resolver is no longer necessary, although it still works.
   756  A new <code>netcgo</code> build tag forces the use of the <code>cgo</code> resolver at
   757  build time.
   758  To force <code>cgo</code> resolution at run time set
   759  <code>GODEBUG=netdns=cgo</code> in the environment.
   760  More debug options are documented <a href="https://golang.org/cl/11584">here</a>.
   761  </p>
   762  
   763  <p>
   764  This change applies to Unix systems only.
   765  Windows, Mac OS X, and Plan 9 systems behave as before.
   766  </p>
   767  
   768  <h3 id="reflect">Reflect</h3>
   769  
   770  <p>
   771  The <a href="/pkg/reflect/"><code>reflect</code></a> package
   772  has two new functions: <a href="/pkg/reflect/#ArrayOf"><code>ArrayOf</code></a>
   773  and <a href="/pkg/reflect/#FuncOf"><code>FuncOf</code></a>.
   774  These functions, analogous to the extant
   775  <a href="/pkg/reflect/#SliceOf"><code>SliceOf</code></a> function,
   776  create new types at runtime to describe arrays and functions.
   777  </p>
   778  
   779  <h3 id="hardening">Hardening</h3>
   780  
   781  <p>
   782  Several dozen bugs were found in the standard library
   783  through randomized testing with the
   784  <a href="https://github.com/dvyukov/go-fuzz"><code>go-fuzz</code></a> tool.
   785  Bugs were fixed in the
   786  <a href="/pkg/archive/tar/"><code>archive/tar</code></a>,
   787  <a href="/pkg/archive/zip/"><code>archive/zip</code></a>,
   788  <a href="/pkg/compress/flate/"><code>compress/flate</code></a>,
   789  <a href="/pkg/encoding/gob/"><code>encoding/gob</code></a>,
   790  <a href="/pkg/fmt/"><code>fmt</code></a>,
   791  <a href="/pkg/html/template/"><code>html/template</code></a>,
   792  <a href="/pkg/image/gif/"><code>image/gif</code></a>,
   793  <a href="/pkg/image/jpeg/"><code>image/jpeg</code></a>,
   794  <a href="/pkg/image/png/"><code>image/png</code></a>, and
   795  <a href="/pkg/text/template/"><code>text/template</code></a>,
   796  packages.
   797  The fixes harden the implementation against incorrect and malicious inputs.
   798  </p>
   799  
   800  <h3 id="minor_library_changes">Minor changes to the library</h3>
   801  
   802  <ul>
   803  
   804  <li>
   805  The <a href="/pkg/archive/zip/"><code>archive/zip</code></a> package's
   806  <a href="/pkg/archive/zip/#Writer"><code>Writer</code></a> type now has a
   807  <a href="/pkg/archive/zip/#Writer.SetOffset"><code>SetOffset</code></a>
   808  method to specify the location within the output stream at which to write the archive.
   809  </li>
   810  
   811  <li>
   812  The <a href="/pkg/bufio/#Reader"><code>Reader</code></a> in the
   813  <a href="/pkg/bufio/"><code>bufio</code></a> package now has a
   814  <a href="/pkg/bufio/#Reader.Discard"><code>Discard</code></a>
   815  method to discard data from the input.
   816  </li>
   817  
   818  <li>
   819  In the <a href="/pkg/bytes/"><code>bytes</code></a> package,
   820  the <a href="/pkg/bytes/#Buffer"><code>Buffer</code></a> type
   821  now has a <a href="/pkg/bytes/#Buffer.Cap"><code>Cap</code></a> method
   822  that reports the number of bytes allocated within the buffer.
   823  Similarly, in both the <a href="/pkg/bytes/"><code>bytes</code></a>
   824  and <a href="/pkg/strings/"><code>strings</code></a> packages,
   825  the <a href="/pkg/bytes/#Reader"><code>Reader</code></a>
   826  type now has a <a href="/pkg/bytes/#Reader.Size"><code>Size</code></a>
   827  method that reports the original length of the underlying slice or string.
   828  </li>
   829  
   830  <li>
   831  Both the <a href="/pkg/bytes/"><code>bytes</code></a> and
   832  <a href="/pkg/strings/"><code>strings</code></a> packages
   833  also now have a <a href="/pkg/bytes/#LastIndexByte"><code>LastIndexByte</code></a>
   834  function that locates the rightmost byte with that value in the argument.
   835  </li>
   836  
   837  <li>
   838  The <a href="/pkg/crypto/"><code>crypto</code></a> package
   839  has a new interface, <a href="/pkg/crypto/#Decrypter"><code>Decrypter</code></a>,
   840  that abstracts the behavior of a private key used in asymmetric decryption.
   841  </li>
   842  
   843  <li>
   844  In the <a href="/pkg/crypto/cipher/"><code>crypto/cipher</code></a> package,
   845  the documentation for the <a href="/pkg/crypto/cipher/#Stream"><code>Stream</code></a>
   846  interface has been clarified regarding the behavior when the source and destination are
   847  different lengths.
   848  If the destination is shorter than the source, the method will panic.
   849  This is not a change in the implementation, only the documentation.
   850  </li>
   851  
   852  <li>
   853  Also in the <a href="/pkg/crypto/cipher/"><code>crypto/cipher</code></a> package,
   854  there is now support for nonce lengths other than 96 bytes in AES's Galois/Counter mode (GCM),
   855  which some protocols require.
   856  </li>
   857  
   858  <li>
   859  In the <a href="/pkg/crypto/elliptic/"><code>crypto/elliptic</code></a> package,
   860  there is now a <code>Name</code> field in the
   861  <a href="/pkg/crypto/elliptic/#CurveParams"><code>CurveParams</code></a> struct,
   862  and the curves implemented in the package have been given names.
   863  These names provide a safer way to select a curve, as opposed to
   864  selecting its bit size, for cryptographic systems that are curve-dependent.
   865  </li>
   866  
   867  <li>
   868  Also in the <a href="/pkg/crypto/elliptic/"><code>crypto/elliptic</code></a> package,
   869  the <a href="/pkg/crypto/elliptic/#Unmarshal"><code>Unmarshal</code></a> function
   870  now verifies that the point is actually on the curve.
   871  (If it is not, the function returns nils).
   872  This change guards against certain attacks.
   873  </li>
   874  
   875  <li>
   876  The <a href="/pkg/crypto/sha512/"><code>crypto/sha512</code></a>
   877  package now has support for the two truncated versions of
   878  the SHA-512 hash algorithm, SHA-512/224 and SHA-512/256.
   879  </li>
   880  
   881  <li>
   882  The <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> package
   883  minimum protocol version now defaults to TLS 1.0.
   884  The old default, SSLv3, is still available through <a href="/pkg/crypto/tls/#Config"><code>Config</code></a> if needed.
   885  </li>
   886  
   887  <li>
   888  The <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> package
   889  now supports Signed Certificate Timestamps (SCTs) as specified in RFC 6962.
   890  The server serves them if they are listed in the
   891  <a href="/pkg/crypto/tls/#Certificate"><code>Certificate</code></a> struct,
   892  and the client requests them and exposes them, if present,
   893  in its <a href="/pkg/crypto/tls/#ConnectionState"><code>ConnectionState</code></a> struct.
   894  
   895  <li>
   896  The stapled OCSP response to a <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> client connection,
   897  previously only available via the
   898  <a href="/pkg/crypto/tls/#Conn.OCSPResponse"><code>OCSPResponse</code></a> method,
   899  is now exposed in the <a href="/pkg/crypto/tls/#ConnectionState"><code>ConnectionState</code></a> struct.
   900  </li>
   901  
   902  <li>
   903  The <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> server implementation
   904  will now always call the
   905  <code>GetCertificate</code> function in
   906  the <a href="/pkg/crypto/tls/#Config"><code>Config</code></a> struct
   907  to select a certificate for the connection when none is supplied.
   908  </li>
   909  
   910  <li>
   911  Finally, the session ticket keys in the
   912  <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> package
   913  can now be changed while the server is running.
   914  This is done through the new
   915  <a href="/pkg/crypto/tls/#Config.SetSessionTicketKeys"><code>SetSessionTicketKeys</code></a>
   916  method of the
   917  <a href="/pkg/crypto/tls/#Config"><code>Config</code></a> type.
   918  </li>
   919  
   920  <li>
   921  In the <a href="/pkg/crypto/x509/"><code>crypto/x509</code></a> package,
   922  wildcards are now accepted only in the leftmost label as defined in
   923  <a href="https://tools.ietf.org/html/rfc6125#section-6.4.3">the specification</a>.
   924  </li>
   925  
   926  <li>
   927  Also in the <a href="/pkg/crypto/x509/"><code>crypto/x509</code></a> package,
   928  the handling of unknown critical extensions has been changed.
   929  They used to cause parse errors but now they are parsed and caused errors only
   930  in <a href="/pkg/crypto/x509/#Certificate.Verify"><code>Verify</code></a>.
   931  The new field <code>UnhandledCriticalExtensions</code> of
   932  <a href="/pkg/crypto/x509/#Certificate"><code>Certificate</code></a> records these extensions.
   933  </li>
   934  
   935  <li>
   936  The <a href="/pkg/database/sql/#DB"><code>DB</code></a> type of the
   937  <a href="/pkg/database/sql/"><code>database/sql</code></a> package
   938  now has a <a href="/pkg/database/sql/#DB.Stats"><code>Stats</code></a> method
   939  to retrieve database statistics.
   940  </li>
   941  
   942  <li>
   943  The <a href="/pkg/debug/dwarf/"><code>debug/dwarf</code></a>
   944  package has extensive additions to better support DWARF version 4.
   945  See for example the definition of the new type
   946  <a href="/pkg/debug/dwarf/#Class"><code>Class</code></a>.
   947  </li>
   948  
   949  <li>
   950  The <a href="/pkg/debug/dwarf/"><code>debug/dwarf</code></a> package
   951  also now supports decoding of DWARF line tables.
   952  </li>
   953  
   954  <li>
   955  The <a href="/pkg/debug/elf/"><code>debug/elf</code></a>
   956  package now has support for the 64-bit PowerPC architecture.
   957  </li>
   958  
   959  <li>
   960  The <a href="/pkg/encoding/base64/"><code>encoding/base64</code></a> package
   961  now supports unpadded encodings through two new encoding variables,
   962  <a href="/pkg/encoding/base64/#RawStdEncoding"><code>RawStdEncoding</code></a> and
   963  <a href="/pkg/encoding/base64/#RawURLEncoding"><code>RawURLEncoding</code></a>.
   964  </li>
   965  
   966  <li>
   967  The <a href="/pkg/encoding/json/"><code>encoding/json</code></a> package
   968  now returns an <a href="/pkg/encoding/json/#UnmarshalTypeError"><code>UnmarshalTypeError</code></a>
   969  if a JSON value is not appropriate for the target variable or component
   970  to which it is being unmarshaled.
   971  </li>
   972  
   973  <li>
   974  The <code>encoding/json</code>'s
   975  <a href="/pkg/encoding/json/#Decoder"><code>Decoder</code></a>
   976  type has a new method that provides a streaming interface for decoding
   977  a JSON document:
   978  <a href="/pkg/encoding/json/#Decoder.Token"><code>Token</code></a>.
   979  It also interoperates with the existing functionality of <code>Decode</code>,
   980  which will continue a decode operation already started with <code>Decoder.Token</code>.
   981  </li>
   982  
   983  <li>
   984  The <a href="/pkg/flag/"><code>flag</code></a> package
   985  has a new function, <a href="/pkg/flag/#UnquoteUsage"><code>UnquoteUsage</code></a>,
   986  to assist in the creation of usage messages using the new convention
   987  described above.
   988  </li>
   989  
   990  <li>
   991  In the <a href="/pkg/fmt/"><code>fmt</code></a> package,
   992  a value of type <a href="/pkg/reflect/#Value"><code>Value</code></a> now
   993  prints what it holds, rather than use the <code>reflect.Value</code>'s <code>Stringer</code>
   994  method, which produces things like <code>&lt;int Value&gt;</code>.
   995  </li>
   996  
   997  <li>
   998  The <a href="/pkg/ast/#EmptyStmt"><code>EmptyStmt</code></a> type
   999  in the <a href="/pkg/go/ast/"><code>go/ast</code></a> package now
  1000  has a boolean <code>Implicit</code> field that records whether the
  1001  semicolon was implicitly added or was present in the source.
  1002  </li>
  1003  
  1004  <li>
  1005  For forward compatibility the <a href="/pkg/go/build/"><code>go/build</code></a> package
  1006  reserves <code>GOARCH</code> values for  a number of architectures that Go might support one day.
  1007  This is not a promise that it will.
  1008  Also, the <a href="/pkg/go/build/#Package"><code>Package</code></a> struct
  1009  now has a <code>PkgTargetRoot</code> field that stores the
  1010  architecture-dependent root directory in which to install, if known.
  1011  </li>
  1012  
  1013  <li>
  1014  The (newly migrated) <a href="/pkg/go/types/"><code>go/types</code></a>
  1015  package allows one to control the prefix attached to package-level names using
  1016  the new <a href="/pkg/go/types/#Qualifier"><code>Qualifier</code></a>
  1017  function type as an argument to several functions. This is an API change for
  1018  the package, but since it is new to the core, it is not breaking the Go 1 compatibility
  1019  rules since code that uses the package must explicitly ask for it at its new location.
  1020  To update, run
  1021  <a href="https://golang.org/cmd/go/#hdr-Run_go_tool_fix_on_packages"><code>go fix</code></a> on your package.
  1022  </li>
  1023  
  1024  <li>
  1025  In the <a href="/pkg/image/"><code>image</code></a> package,
  1026  the <a href="/pkg/image/#Rectangle"><code>Rectangle</code></a> type
  1027  now implements the <a href="/pkg/image/#Image"><code>Image</code></a> interface,
  1028  so a <code>Rectangle</code> can serve as a mask when drawing.
  1029  </li>
  1030  
  1031  <li>
  1032  Also in the <a href="/pkg/image/"><code>image</code></a> package,
  1033  to assist in the handling of some JPEG images,
  1034  there is now support for 4:1:1 and 4:1:0 YCbCr subsampling and basic
  1035  CMYK support, represented by the new <code>image.CMYK</code> struct.
  1036  </li>
  1037  
  1038  <li>
  1039  The <a href="/pkg/image/color/"><code>image/color</code></a> package
  1040  adds basic CMYK support, through the new
  1041  <a href="/pkg/image/color/#CMYK"><code>CMYK</code></a> struct,
  1042  the <a href="/pkg/image/color/#CMYKModel"><code>CMYKModel</code></a> color model, and the
  1043  <a href="/pkg/image/color/#CMYKToRGB"><code>CMYKToRGB</code></a> function, as
  1044  needed by some JPEG images.
  1045  </li>
  1046  
  1047  <li>
  1048  Also in the <a href="/pkg/image/color/"><code>image/color</code></a> package,
  1049  the conversion of a <a href="/pkg/image/color/#YCbCr"><code>YCbCr</code></a>
  1050  value to <code>RGBA</code> has become more precise.
  1051  Previously, the low 8 bits were just an echo of the high 8 bits;
  1052  now they contain more accurate information.
  1053  Because of the echo property of the old code, the operation
  1054  <code>uint8(r)</code> to extract an 8-bit red value worked, but is incorrect.
  1055  In Go 1.5, that operation may yield a different value.
  1056  The correct code is, and always was, to select the high 8 bits:
  1057  <code>uint8(r&gt;&gt;8)</code>.
  1058  Incidentally, the <code>image/draw</code> package
  1059  provides better support for such conversions; see
  1060  <a href="https://blog.golang.org/go-imagedraw-package">this blog post</a>
  1061  for more information.
  1062  </li>
  1063  
  1064  <li>
  1065  Finally, as of Go 1.5 the closest match check in
  1066  <a href="/pkg/image/color/#Palette.Index"><code>Index</code></a>
  1067  now honors the alpha channel.
  1068  </li>
  1069  
  1070  <li>
  1071  The <a href="/pkg/image/gif/"><code>image/gif</code></a> package
  1072  includes a couple of generalizations.
  1073  A multiple-frame GIF file can now have an overall bounds different
  1074  from all the contained single frames' bounds.
  1075  Also, the <a href="/pkg/image/gif/#GIF"><code>GIF</code></a> struct
  1076  now has a <code>Disposal</code> field
  1077  that specifies the disposal method for each frame.
  1078  </li>
  1079  
  1080  <li>
  1081  The <a href="/pkg/io/"><code>io</code></a> package
  1082  adds a <a href="/pkg/io/#CopyBuffer"><code>CopyBuffer</code></a> function
  1083  that is like <a href="/pkg/io/#Copy"><code>Copy</code></a> but
  1084  uses a caller-provided buffer, permitting control of allocation and buffer size.
  1085  </li>
  1086  
  1087  <li>
  1088  The <a href="/pkg/log/"><code>log</code></a> package
  1089  has a new <a href="/pkg/log/#LUTC"><code>LUTC</code></a> flag
  1090  that causes time stamps to be printed in the UTC time zone.
  1091  It also adds a <a href="/pkg/log/#Logger.SetOutput"><code>SetOutput</code></a> method
  1092  for user-created loggers.
  1093  </li>
  1094  
  1095  <li>
  1096  In Go 1.4, <a href="/pkg/math/#Max"><code>Max</code></a> was not detecting all possible NaN bit patterns.
  1097  This is fixed in Go 1.5, so programs that use <code>math.Max</code> on data including NaNs may behave differently,
  1098  but now correctly according to the IEEE754 definition of NaNs.
  1099  </li>
  1100  
  1101  <li>
  1102  The <a href="/pkg/math/big/"><code>math/big</code></a> package
  1103  adds a new <a href="/pkg/math/big/#Jacobi"><code>Jacobi</code></a>
  1104  function for integers and a new
  1105  <a href="/pkg/math/big/#Int.ModSqrt"><code>ModSqrt</code></a>
  1106  method for the <a href="/pkg/math/big/#Int"><code>Int</code></a> type.
  1107  </li>
  1108  
  1109  <li>
  1110  The mime package
  1111  adds a new <a href="/pkg/mime/#WordDecoder"><code>WordDecoder</code></a> type
  1112  to decode MIME headers containing RFC 204-encoded words.
  1113  It also provides <a href="/pkg/mime/#BEncoding"><code>BEncoding</code></a> and
  1114  <a href="/pkg/mime/#QEncoding"><code>QEncoding</code></a>
  1115  as implementations of the encoding schemes of RFC 2045 and RFC 2047.
  1116  </li>
  1117  
  1118  <li>
  1119  The <a href="/pkg/mime/"><code>mime</code></a> package also adds an
  1120  <a href="/pkg/mime/#ExtensionsByType"><code>ExtensionsByType</code></a>
  1121  function that returns the MIME extensions know to be associated with a given MIME type.
  1122  </li>
  1123  
  1124  <li>
  1125  There is a new <a href="/pkg/mime/quotedprintable/"><code>mime/quotedprintable</code></a>
  1126  package that implements the quoted-printable encoding defined by RFC 2045.
  1127  </li>
  1128  
  1129  <li>
  1130  The <a href="/pkg/net/"><code>net</code></a> package will now
  1131  <a href="/pkg/net/#Dial"><code>Dial</code></a> hostnames by trying each
  1132  IP address in order until one succeeds.
  1133  The <code><a href="/pkg/net/#Dialer">Dialer</a>.DualStack</code>
  1134  mode now implements Happy Eyeballs
  1135  (<a href="https://tools.ietf.org/html/rfc6555">RFC 6555</a>) by giving the
  1136  first address family a 300ms head start; this value can be overridden by
  1137  the new <code>Dialer.FallbackDelay</code>.
  1138  </li>
  1139  
  1140  <li>
  1141  A number of inconsistencies in the types returned by errors in the
  1142  <a href="/pkg/net/"><code>net</code></a> package have been
  1143  tidied up.
  1144  Most now return an
  1145  <a href="/pkg/net/#OpError"><code>OpError</code></a> value
  1146  with more information than before.
  1147  Also, the <a href="/pkg/net/#OpError"><code>OpError</code></a>
  1148  type now includes a <code>Source</code> field that holds the local
  1149  network address.
  1150  </li>
  1151  
  1152  <li>
  1153  The <a href="/pkg/net/http/"><code>net/http</code></a> package now
  1154  has support for setting trailers from a server <a href="/pkg/net/http/#Handler"><code>Handler</code></a>.
  1155  For details, see the documentation for
  1156  <a href="/pkg/net/http/#ResponseWriter"><code>ResponseWriter</code></a>.
  1157  </li>
  1158  
  1159  <li>
  1160  There is a new method to cancel a <a href="/pkg/net/http/"><code>net/http</code></a>
  1161  <code>Request</code> by setting the new
  1162  <a href="/pkg/net/http/#Request"><code>Request.Cancel</code></a>
  1163  field.
  1164  It is supported by <code>http.Transport</code>.
  1165  The <code>Cancel</code> field's type is compatible with the
  1166  <a href="https://godoc.org/golang.org/x/net/context"><code>context.Context.Done</code></a>
  1167  return value.
  1168  </li>
  1169  
  1170  <li>
  1171  Also in the <a href="/pkg/net/http/"><code>net/http</code></a> package,
  1172  there is code to ignore the zero <a href="/pkg/time/#Time"><code>Time</code></a> value
  1173  in the <a href="/pkg/net/#ServeContent"><code>ServeContent</code></a> function.
  1174  As of Go 1.5, it now also ignores a time value equal to the Unix epoch.
  1175  </li>
  1176  
  1177  <li>
  1178  The <a href="/pkg/net/http/fcgi/"><code>net/http/fcgi</code></a> package
  1179  exports two new errors,
  1180  <a href="/pkg/net/http/fcgi/#ErrConnClosed"><code>ErrConnClosed</code></a> and
  1181  <a href="/pkg/net/http/fcgi/#ErrRequestAborted"><code>ErrRequestAborted</code></a>,
  1182  to report the corresponding error conditions.
  1183  </li>
  1184  
  1185  <li>
  1186  The <a href="/pkg/net/http/cgi/"><code>net/http/cgi</code></a> package
  1187  had a bug that mishandled the values of the environment variables
  1188  <code>REMOTE_ADDR</code> and <code>REMOTE_HOST</code>.
  1189  This has been fixed.
  1190  Also, starting with Go 1.5 the package sets the <code>REMOTE_PORT</code>
  1191  variable.
  1192  </li>
  1193  
  1194  <li>
  1195  The <a href="/pkg/net/mail/"><code>net/mail</code></a> package
  1196  adds an <a href="/pkg/net/mail/#AddressParser"><code>AddressParser</code></a>
  1197  type that can parse mail addresses.
  1198  </li>
  1199  
  1200  <li>
  1201  The <a href="/pkg/net/smtp/"><code>net/smtp</code></a> package
  1202  now has a <a href="/pkg/net/smtp/#Client.TLSConnectionState"><code>TLSConnectionState</code></a>
  1203  accessor to the <a href="/pkg/net/smtp/#Client"><code>Client</code></a>
  1204  type that returns the client's TLS state.
  1205  </li>
  1206  
  1207  <li>
  1208  The <a href="/pkg/os/"><code>os</code></a> package
  1209  has a new <a href="/pkg/os/#LookupEnv"><code>LookupEnv</code></a> function
  1210  that is similar to <a href="/pkg/os/#Getenv"><code>Getenv</code></a>
  1211  but can distinguish between an empty environment variable and a missing one.
  1212  </li>
  1213  
  1214  <li>
  1215  The <a href="/pkg/os/signal/"><code>os/signal</code></a> package
  1216  adds new <a href="/pkg/os/signal/#Ignore"><code>Ignore</code></a> and
  1217  <a href="/pkg/os/signal/#Reset"><code>Reset</code></a> functions.
  1218  </li>
  1219  
  1220  <li>
  1221  The <a href="/pkg/runtime/"><code>runtime</code></a>,
  1222  <a href="/pkg/runtime/trace/"><code>runtime/trace</code></a>,
  1223  and <a href="/pkg/net/http/pprof/"><code>net/http/pprof</code></a> packages
  1224  each have new functions to support the tracing facilities described above:
  1225  <a href="/pkg/runtime/#ReadTrace"><code>ReadTrace</code></a>,
  1226  <a href="/pkg/runtime/#StartTrace"><code>StartTrace</code></a>,
  1227  <a href="/pkg/runtime/#StopTrace"><code>StopTrace</code></a>,
  1228  <a href="/pkg/runtime/trace/#Start"><code>Start</code></a>,
  1229  <a href="/pkg/runtime/trace/#Stop"><code>Stop</code></a>, and
  1230  <a href="/pkg/net/http/pprof/#Trace"><code>Trace</code></a>.
  1231  See the respective documentation for details.
  1232  </li>
  1233  
  1234  <li>
  1235  The <a href="/pkg/runtime/pprof/"><code>runtime/pprof</code></a> package
  1236  by default now includes overall memory statistics in all memory profiles.
  1237  </li>
  1238  
  1239  <li>
  1240  The <a href="/pkg/strings/"><code>strings</code></a> package
  1241  has a new <a href="/pkg/strings/#Compare"><code>Compare</code></a> function.
  1242  This is present to provide symmetry with the <a href="/pkg/bytes/"><code>bytes</code></a> package
  1243  but is otherwise unnecessary as strings support comparison natively.
  1244  </li>
  1245  
  1246  <li>
  1247  The <a href="/pkg/sync/#WaitGroup"><code>WaitGroup</code></a> implementation in
  1248  package <a href="/pkg/sync/"><code>sync</code></a>
  1249  now diagnoses code that races a call to <a href="/pkg/sync/#WaitGroup.Add"><code>Add</code></a>
  1250  against a return from <a href="/pkg/sync/#WaitGroup.Wait"><code>Wait</code></a>.
  1251  If it detects this condition, the implementation panics.
  1252  </li>
  1253  
  1254  <li>
  1255  In the <a href="/pkg/syscall/"><code>syscall</code></a> package,
  1256  the Linux <code>SysProcAttr</code> struct now has a
  1257  <code>GidMappingsEnableSetgroups</code> field, made necessary
  1258  by security changes in Linux 3.19.
  1259  On all Unix systems, the struct also has new <code>Foreground</code> and <code>Pgid</code> fields
  1260  to provide more control when exec'ing.
  1261  On Darwin, there is now a <code>Syscall9</code> function
  1262  to support calls with too many arguments.
  1263  </li>
  1264  
  1265  <li>
  1266  The <a href="/pkg/testing/quick/"><code>testing/quick</code></a> will now
  1267  generate <code>nil</code> values for pointer types,
  1268  making it possible to use with recursive data structures.
  1269  Also, the package now supports generation of array types.
  1270  </li>
  1271  
  1272  <li>
  1273  In the <a href="/pkg/text/template/"><code>text/template</code></a> and
  1274  <a href="/pkg/html/template/"><code>html/template</code></a> packages,
  1275  integer constants too large to be represented as a Go integer now trigger a
  1276  parse error. Before, they were silently converted to floating point, losing
  1277  precision.
  1278  </li>
  1279  
  1280  <li>
  1281  Also in the <a href="/pkg/text/template/"><code>text/template</code></a> and
  1282  <a href="/pkg/html/template/"><code>html/template</code></a> packages,
  1283  a new <a href="/pkg/text/template/#Template.Option"><code>Option</code></a> method
  1284  allows customization of the behavior of the template during execution.
  1285  The sole implemented option allows control over how a missing key is
  1286  handled when indexing a map.
  1287  The default, which can now be overridden, is as before: to continue with an invalid value.
  1288  </li>
  1289  
  1290  <li>
  1291  The <a href="/pkg/time/"><code>time</code></a> package's
  1292  <code>Time</code> type has a new method
  1293  <a href="/pkg/time/#Time.AppendFormat"><code>AppendFormat</code></a>,
  1294  which can be used to avoid allocation when printing a time value.
  1295  </li>
  1296  
  1297  <li>
  1298  The <a href="/pkg/unicode/"><code>unicode</code></a> package and associated
  1299  support throughout the system has been upgraded from version 7.0 to
  1300  <a href="http://www.unicode.org/versions/Unicode8.0.0/">Unicode 8.0</a>.
  1301  </li>
  1302  
  1303  </ul>