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