github.com/shijuvar/go@v0.0.0-20141209052335-e8f13700b70c/doc/go1.4.html (about)

     1  <!--{
     2  	"Title": "Go 1.4 Release Notes",
     3  	"Path":  "/doc/go1.4",
     4  	"Template": true
     5  }-->
     6  
     7  <h2 id="introduction">Introduction to Go 1.4</h2>
     8  
     9  <p>
    10  The latest Go release, version 1.4, arrives as scheduled six months after 1.3.
    11  It contains only one tiny language change,
    12  in the form of a backwards-compatible simple variant of <code>for</code>-<code>range</code> loop,
    13  and a possibly breaking change to the compiler involving methods on pointers-to-pointers.
    14  The release focuses primarily on implementation work, improving the garbage collector
    15  and preparing the ground for a fully concurrent collector to be rolled out in the
    16  next few releases.
    17  Stacks are now contiguous, reallocated when necessary rather than linking on new
    18  "segments";
    19  this release therefore eliminates the notorious "hot stack split" problem.
    20  There are some new tools available including support in the <code>go</code> command
    21  for build-time source code generation.
    22  The release also adds support for ARM processors on Android and Native Client (NaCl)
    23  and for AMD64 on Plan 9.
    24  As always, Go 1.4 keeps the <a href="/doc/go1compat.html">promise
    25  of compatibility</a>,
    26  and almost everything 
    27  will continue to compile and run without change when moved to 1.4.
    28  </p>
    29  
    30  <h2 id="language">Changes to the language</h2>
    31  
    32  <h3 id="forrange">For-range loops</h3>
    33  <p>
    34  Up until Go 1.3, <code>for</code>-<code>range</code> loop had two forms
    35  </p>
    36  
    37  <pre>
    38  for k, v := range x {
    39  	...
    40  }
    41  </pre>
    42  
    43  <p>
    44  and
    45  </p>
    46  
    47  <pre>
    48  for k := range x {
    49  	...
    50  }
    51  </pre>
    52  
    53  <p>
    54  If one was not interested in the loop values, only the iteration itself, it was still
    55  necessary to mention a variable (probably the <a href="/ref/spec#Blank_identifier">blank identifier</a>, as in
    56  <code>for</code> <code>_</code> <code>=</code> <code>range</code> <code>x</code>), because
    57  the form
    58  </p>
    59  
    60  <pre>
    61  for range x {
    62  	...
    63  }
    64  </pre>
    65  
    66  <p>
    67  was not syntactically permitted.
    68  </p>
    69  
    70  <p>
    71  This situation seemed awkward, so as of Go 1.4 the variable-free form is now legal.
    72  The pattern arises rarely but the code can be cleaner when it does.
    73  </p>
    74  
    75  <p>
    76  <em>Updating</em>: The change is strictly backwards compatible to existing Go
    77  programs, but tools that analyze Go parse trees may need to be modified to accept
    78  this new form as the
    79  <code>Key</code> field of <a href="/pkg/go/ast/#RangeStmt"><code>RangeStmt</code></a>
    80  may now be <code>nil</code>.
    81  </p>
    82  
    83  <h3 id="methodonpointertopointer">Method calls on **T</h3>
    84  
    85  <p>
    86  Given these declarations,
    87  </p>
    88  
    89  <pre>
    90  type T int
    91  func (T) M() {}
    92  var x **T
    93  </pre>
    94  
    95  <p>
    96  both <code>gc</code> and <code>gccgo</code> accepted the method call
    97  </p>
    98  
    99  <pre>
   100  x.M()
   101  </pre>
   102  
   103  <p>
   104  which is a double dereference of the pointer-to-pointer <code>x</code>.
   105  The Go specification allows a single dereference to be inserted automatically,
   106  but not two, so this call is erroneous according to the language definition.
   107  It has therefore been disallowed in Go 1.4, which is a breaking change,
   108  although very few programs will be affected.
   109  </p>
   110  
   111  <p>
   112  <em>Updating</em>: Code that depends on the old, erroneous behavior will no longer
   113  compile but is easy to fix by adding an explicit dereference.
   114  </p>
   115  
   116  <h2 id="os">Changes to the supported operating systems and architectures</h2>
   117  
   118  <h3 id="android">Android</h3>
   119  
   120  <p>
   121  Go 1.4 can build binaries for ARM processors running the Android operating system.
   122  It can also build a <code>.so</code> library that can be loaded by an Android application
   123  using the supporting packages in the <a href="https://golang.org/x/mobile">mobile</a> subrepository.
   124  A brief description of the plans for this experimental port are available
   125  <a href="https://golang.org/s/go14android">here</a>.
   126  </p>
   127  
   128  <h3 id="naclarm">NaCl on ARM</h3>
   129  
   130  <p>
   131  The previous release introduced Native Client (NaCl) support for the 32-bit x86
   132  (<code>GOARCH=386</code>)
   133  and 64-bit x86 using 32-bit pointers (GOARCH=amd64p32).
   134  The 1.4 release adds NaCl support for ARM (GOARCH=arm).
   135  </p>
   136  
   137  <h3 id="plan9amd64">Plan9 on AMD64</h3>
   138  
   139  <p>
   140  This release adds support for the Plan 9 operating system on AMD64 processors,
   141  provided the kernel supports the <code>nsec</code> system call and uses 4K pages.
   142  </p>
   143  
   144  <h2 id="compatibility">Changes to the compatibility guidelines</h2>
   145  
   146  <p>
   147  The <a href="/pkg/unsafe/"><code>unsafe</code></a> package allows one
   148  to defeat Go's type system by exploiting internal details of the implementation
   149  or machine representation of data.
   150  It was never explicitly specified what use of <code>unsafe</code> meant
   151  with respect to compatibility as specified in the
   152  <a href="go1compat.html">Go compatibility guidelines</a>.
   153  The answer, of course, is that we can make no promise of compatibility
   154  for code that does unsafe things.
   155  </p>
   156  
   157  <p>
   158  We have clarified this situation in the documentation included in the release.
   159  The <a href="go1compat.html">Go compatibility guidelines</a> and the
   160  docs for the <a href="/pkg/unsafe/"><code>unsafe</code></a> package
   161  are now explicit that unsafe code is not guaranteed to remain compatible.
   162  </p>
   163    
   164  <p>
   165  <em>Updating</em>: Nothing technical has changed; this is just a clarification
   166  of the documentation.
   167  </p>
   168  
   169  
   170  <h2 id="impl">Changes to the implementations and tools</h2>
   171  
   172  <h3 id="runtime">Changes to the runtime</h3>
   173  
   174  <p>
   175  Up to Go 1.4, the runtime (garbage collector, concurrency support, interface management,
   176  maps, slices, strings, ...) was mostly written in C, with some assembler support.
   177  In 1.4, much of the code has been translated to Go so that the garbage collector can scan
   178  the stacks of programs in the runtime and get accurate information about what variables
   179  are active.
   180  This change was large but should have no semantic effect on programs.
   181  </p>
   182  
   183  <p>
   184  This rewrite allows the garbage collector in 1.4 to be fully precise,
   185  meaning that it is aware of the location of all active pointers in the program.
   186  This means the heap will be smaller as there will be no false positives keeping non-pointers alive.
   187  Other related changes also reduce the heap size, which is smaller by 10%-30% overall
   188  relative to the previous release.
   189  </p>
   190  
   191  <p>
   192  A consequence is that stacks are no longer segmented, eliminating the "hot split" problem.
   193  When a stack limit is reached, a new, larger stack is allocated, all active frames for
   194  the goroutine are copied there, and any pointers into the stack are updated.
   195  Performance can be noticeably better in some cases and is always more predictable.
   196  Details are available in <a href="https://golang.org/s/contigstacks">the design document</a>.
   197  </p>
   198  
   199  <p>
   200  The use of contiguous stacks means that stacks can start smaller without triggering performance issues,
   201  so the default starting size for a goroutine's stack in 1.4 has been reduced to 2048 bytes from 8192 bytes.
   202  </p>
   203  
   204  <p>
   205  As preparation for the concurrent garbage collector scheduled for the 1.5 release,
   206  writes to pointer values in the heap are now done by a function call,
   207  called a write barrier, rather than directly from the function updating the value.
   208  In this next release, this will permit the garbage collector to mediate writes to the heap while it is running.
   209  This change has no semantic effect on programs in 1.4, but was
   210  included in the release to test the compiler and the resulting performance.
   211  </p>
   212  
   213  <p>
   214  The implementation of interface values has been modified.
   215  In earlier releases, the interface contained a word that was either a pointer or a one-word
   216  scalar value, depending on the type of the concrete object stored.
   217  This implementation was problematical for the garbage collector,
   218  so as of 1.4 interface values always hold a pointer.
   219  In running programs, most interface values were pointers anyway,
   220  so the effect is minimal, but programs that store integers (for example) in
   221  interfaces will see more allocations.
   222  </p>
   223  
   224  <p>
   225  As of Go 1.3, the runtime crashes if it finds a memory word that should contain
   226  a valid pointer but instead contains an obviously invalid pointer (for example, the value 3).
   227  Programs that store integers in pointer values may run afoul of this check and crash.
   228  In Go 1.4, setting the <a href="/pkg/runtime/"><code>GODEBUG</code></a> variable
   229  <code>invalidptr=0</code> disables
   230  the crash as a workaround, but we cannot guarantee that future releases will be
   231  able to avoid the crash; the correct fix is to rewrite code not to alias integers and pointers.
   232  </p>
   233  
   234  <h3 id="asm">Assembly</h3>
   235  
   236  <p>
   237  The language accepted by the assemblers <code>cmd/5a</code>, <code>cmd/6a</code>
   238  and <code>cmd/8a</code> has had several changes,
   239  mostly to make it easier to deliver type information to the runtime.
   240  </p>
   241  
   242  <p>
   243  First, the <code>textflag.h</code> file that defines flags for <code>TEXT</code> directives
   244  has been copied from the linker source directory to a standard location so it can be
   245  included with the simple directive
   246  </p>
   247  
   248  <pre>
   249  #include "textflag.h"
   250  </pre>
   251  
   252  <p>
   253  The more important changes are in how assembler source can define the necessary
   254  type information.
   255  For most programs it will suffice to move data
   256  definitions (<code>DATA</code> and <code>GLOBL</code> directives)
   257  out of assembly into Go files
   258  and to write a Go declaration for each assembly function.
   259  The <a href="/doc/asm#runtime">assembly document</a> describes what to do.
   260  </p>
   261  
   262  <p>
   263  <em>Updating</em>:
   264  Assembly files that include <code>textflag.h</code> from its old
   265  location will still work, but should be updated.
   266  For the type information, most assembly routines will need no change,
   267  but all should be examined.
   268  Assembly source files that define data,
   269  functions with non-empty stack frames, or functions that return pointers
   270  need particular attention.
   271  A description of the necessary (but simple) changes
   272  is in the <a href="/doc/asm#runtime">assembly document</a>.
   273  </p>
   274  
   275  <p>
   276  More information about these changes is in the <a href="/doc/asm">assembly document</a>.
   277  </p>
   278  
   279  <h3 id="gccgo">Status of gccgo</h3>
   280  
   281  <p>
   282  The release schedules for the GCC and Go projects do not coincide.
   283  GCC release 4.9 contains the Go 1.2 version of gccgo.
   284  The next release, GCC 5, will likely have the Go 1.4 version of gccgo.
   285  </p>
   286  
   287  <h3 id="internalpackages">Internal packages</h3>
   288  
   289  <p>
   290  Go's package system makes it easy to structure programs into components with clean boundaries,
   291  but there are only two forms of access: local (unexported) and global (exported).
   292  Sometimes one wishes to have components that are not exported,
   293  for instance to avoid acquiring clients of interfaces to code that is part of a public repository
   294  but not intended for use outside the program to which it belongs.
   295  </p>
   296  
   297  <p>
   298  The Go language does not have the power to enforce this distinction, but as of Go 1.4 the
   299  <a href="/cmd/go/"><code>go</code></a> command introduces
   300  a mechanism to define "internal" packages that may not be imported by packages outside
   301  the source subtree in which they reside.
   302  </p>
   303  
   304  <p>
   305  To create such a package, place it in a directory named <code>internal</code> or in a subdirectory of a directory
   306  named internal.
   307  When the <code>go</code> command sees an import of a package with <code>internal</code> in its path,
   308  it verifies that the package doing the import
   309  is within the tree rooted at the parent of the <code>internal</code> directory.
   310  For example, a package <code>.../a/b/c/internal/d/e/f</code>
   311  can be imported only by code in the directory tree rooted at <code>.../a/b/c</code>.
   312  It cannot be imported by code in <code>.../a/b/g</code> or in any other repository.
   313  </p>
   314  
   315  <p>
   316  For Go 1.4, the internal package mechanism is enforced for the main Go repository;
   317  from 1.5 and onward it will be enforced for any repository.
   318  </p>
   319  
   320  <p>
   321  Full details of the mechanism are in
   322  <a href="https://golang.org/s/go14internal">the design document</a>.
   323  </p>
   324  
   325  <h3 id="canonicalimports">Canonical import paths</h3>
   326  
   327  <p>
   328  Code often lives in repositories hosted by public services such as <code>github.com</code>,
   329  meaning that the import paths for packages begin with the name of the hosting service,
   330  <code>github.com/rsc/pdf</code> for example.
   331  One can use
   332  <a href="/cmd/go/#hdr-Remote_import_paths">an existing mechanism</a>
   333  to provide a "custom" or "vanity" import path such as
   334  <code>rsc.io/pdf</code>, but
   335  that creates two valid import paths for the package.
   336  That is a problem: one may inadvertently import the package through the two
   337  distinct paths in a single program, which is wasteful;
   338  miss an update to a package because the path being used is not recognized to be
   339  out of date;
   340  or break clients using the old path by moving the package to a different hosting service.
   341  </p>
   342  
   343  <p>
   344  Go 1.4 introduces an annotation for package clauses in Go source that identify a canonical
   345  import path for the package.
   346  If an import is attempted using a path that is not canonical,
   347  the <a href="/cmd/go/"><code>go</code></a> command
   348  will refuse to compile the importing package.
   349  </p>
   350  
   351  <p>
   352  The syntax is simple: put an identifying comment on the package line.
   353  For our example, the package clause would read:
   354  </p>
   355  
   356  <pre>
   357  package pdf // import "rsc.io/pdf"
   358  </pre>
   359  
   360  <p>
   361  With this in place,
   362  the <code>go</code> command will
   363  refuse to compile a package that imports <code>github.com/rsc/pdf</code>, 
   364  ensuring that the code can be moved without breaking users.
   365  </p>
   366  
   367  <p>
   368  The check is at build time, not download time, so if <code>go</code> <code>get</code>
   369  fails because of this check, the mis-imported package has been copied to the local machine
   370  and should be removed manually.
   371  </p>
   372  
   373  <p>
   374  To complement this new feature, a check has been added at update time to verify
   375  that the local package's remote repository matches that of its custom import.
   376  The <code>go</code> <code>get</code> <code>-u</code> command will fail to
   377  update a package if its remote repository has changed since it was first
   378  downloaded.
   379  The new <code>-f</code> flag overrides this check.
   380  </p>
   381  
   382  <p>
   383  Further information is in
   384  <a href="https://golang.org/s/go14customimport">the design document</a>.
   385  </p>
   386  
   387  <h3 id="subrepo">Import paths for the subrepositories</h3>
   388  
   389  <p>
   390  The Go project subrepositories (<code>code.google.com/p/go.tools</code> and so on)
   391  are now available under custom import paths replacing <code>code.google.com/p/go.</code> with <code>golang.org/x/</code>,
   392  as in <code>golang.org/x/tools</code>.
   393  We will add canonical import comments to the code around June 1, 2015,
   394  at which point Go 1.4 and later will stop accepting the old <code>code.google.com</code> paths.
   395  </p>
   396  
   397  <p>
   398  <em>Updating</em>: All code that imports from subrepositories should change
   399  to use the new <code>golang.org</code> paths.
   400  Go 1.0 and later can resolve and import the new paths, so updating will not break
   401  compatibility with older releases.
   402  Code that has not updated will stop compiling with Go 1.4 around June 1, 2015.
   403  </p>
   404  
   405  <h3 id="gogenerate">The go generate subcommand</h3>
   406  
   407  <p>
   408  The <a href="/cmd/go/"><code>go</code></a> command has a new subcommand,
   409  <a href="/cmd/go/#hdr-Generate_Go_files_by_processing_source"><code>go generate</code></a>,
   410  to automate the running of tools to generate source code before compilation.
   411  For example, it can be used to run the <a href="/cmd/yacc"><code>yacc</code></a>
   412  compiler-compiler on a <code>.y</code> file to produce the Go source file implementing the grammar,
   413  or to automate the generation of <code>String</code> methods for typed constants using the new
   414  <a href="http://godoc.org/golang.org/x/tools/cmd/stringer">stringer</a>
   415  tool in the <code>golang.org/x/tools</code> subrepository.
   416  </p>
   417  
   418  <p>
   419  For more information, see the 
   420  <a href="https://golang.org/s/go1.4-generate">design document</a>.
   421  </p>
   422  
   423  <h3 id="filenames">Change to file name handling</h3>
   424  
   425  <p>
   426  Build constraints, also known as build tags, control compilation by including or excluding files
   427  (see the documentation <a href="/pkg/go/build/"><code>/go/build</code></a>).
   428  Compilation can also be controlled by the name of the file itself by "tagging" the file with
   429  a suffix (before the <code>.go</code> or <code>.s</code> extension) with an underscore
   430  and the name of the architecture or operating system.
   431  For instance, the file <code>gopher_arm.go</code> will only be compiled if the target
   432  processor is an ARM.
   433  </p>
   434  
   435  <p>
   436  Before Go 1.4, a file called just <code>arm.go</code> was similarly tagged, but this behavior
   437  can break sources when new architectures are added, causing files to suddenly become tagged.
   438  In 1.4, therefore, a file will be tagged in this manner only if the tag (architecture or operating
   439  system name) is preceded by an underscore.
   440  </p>
   441  
   442  <p>
   443  <em>Updating</em>: Packages that depend on the old behavior will no longer compile correctly.
   444  Files with names like <code>windows.go</code> or <code>amd64.go</code> should either
   445  have explicit build tags added to the source or be renamed to something like
   446  <code>os_windows.go</code> or <code>support_amd64.go</code>.
   447  </p>
   448  
   449  <h3 id="gocmd">Other changes to the go command</h3>
   450  
   451  <p>
   452  There were a number of minor changes to the
   453  <a href="/cmd/go/"><code>cmd/go</code></a>
   454  command worth noting.
   455  </p>
   456  
   457  <ul>
   458  
   459  <li>
   460  Unless <a href="/cmd/cgo/"><code>cgo</code></a> is being used to build the package,
   461  the <code>go</code> command now refuses to compile C source files,
   462  since the relevant C compilers
   463  (<a href="/cmd/6c/"><code>6c</code></a> etc.)
   464  are intended to be removed from the installation in some future release.
   465  (They are used today only to build part of the runtime.)
   466  It is difficult to use them correctly in any case, so any extant uses are likely incorrect,
   467  so we have disabled them.
   468  </li>
   469  
   470  <li>
   471  The <a href="/cmd/go/#hdr-Test_packages"><code>go</code> <code>test</code></a>
   472  subcommand has a new flag, <code>-o</code>, to set the name of the resulting binary,
   473  corresponding to the same flag in other subcommands.
   474  The non-functional <code>-file</code> flag has been removed.
   475  </li>
   476  
   477  <li>
   478  The <a href="/cmd/go/#hdr-Test_packages"><code>go</code> <code>test</code></a>
   479  subcommand will compile and link all <code>*_test.go</code> files in the package,
   480  even when there are no <code>Test</code> functions in them. 
   481  It previously ignored such files.
   482  </li>
   483  
   484  <li>
   485  The behavior of the
   486  <a href="/cmd/go/#hdr-Test_packages"><code>go</code> <code>build</code></a>
   487  subcommand's
   488  <code>-a</code> flag has been changed for non-development installations.
   489  For installations running a released distribution, the <code>-a</code> flag will no longer
   490  rebuild the standard library and commands, to avoid overwriting the installation's files.
   491  </li>
   492  
   493  </ul>
   494  
   495  <h3 id="pkg">Changes to package source layout</h3>
   496  
   497  <p>
   498  In the main Go source repository, the source code for the packages was kept in
   499  the directory <code>src/pkg</code>, which made sense but differed from
   500  other repositories, including the Go subrepositories.
   501  In Go 1.4, the<code> pkg</code> level of the source tree is now gone, so for example
   502  the <a href="/pkg/fmt/"><code>fmt</code></a> package's source, once kept in
   503  directory <code>src/pkg/fmt</code>, now lives one level higher in <code>src/fmt</code>.
   504  </p>
   505  
   506  <p>
   507  <em>Updating</em>: Tools like <code>godoc</code> that discover source code
   508  need to know about the new location. All tools and services maintained by the Go team
   509  have been updated.
   510  </p>
   511  
   512  
   513  <h3 id="swig">SWIG</h3>
   514  
   515  <p>
   516  Due to the runtime changes in this release, Go 1.4 will require SWIG 3.0.3.
   517  At time of writing that has not yet been released, but we expect it to be by
   518  Go 1.4's release date.
   519  TODO
   520  </p>
   521  
   522  <h3 id="misc">Miscellany</h3>
   523  
   524  <p>
   525  The standard repository's top-level <code>misc</code> directory used to contain
   526  Go support for editors and IDEs: plugins, initialization scripts and so on.
   527  Maintaining these was becoming time-consuming
   528  and needed external help because many of the editors listed were not used by
   529  members of the core team.
   530  It also required us to make decisions about which plugin was best for a given
   531  editor, even for editors we do not use.
   532  </p>
   533  
   534  <p>
   535  The Go community at large is much better suited to managing this information.
   536  In Go 1.4, therefore, this support has been removed from the repository.
   537  Instead, there is a curated, informative list of what's available on
   538  a <a href="https://code.google.com/p/go-wiki/wiki/IDEsAndTextEditorPlugins">wiki page</a>.
   539  </p>
   540  
   541  <h2 id="performance">Performance</h2>
   542  
   543  <p>
   544  Most programs will run about the same speed or slightly faster in 1.4 than in 1.3;
   545  some will be slightly slower.
   546  There are many changes, making it hard to be precise about what to expect.
   547  </p>
   548  
   549  <p>
   550  As mentioned above, much of the runtime was translated to Go from C,
   551  which led to some reduction in heap sizes.
   552  It also improved performance slightly because the Go compiler is better
   553  at optimization, due to things like inlining, than the C compiler used to build
   554  the runtime.
   555  </p>
   556  
   557  <p>
   558  The garbage collector was sped up, leading to measurable improvements for
   559  garbage-heavy programs.
   560  On the other hand, the new write barriers slow things down again, typically
   561  by about the same amount but, depending on their behavior, some programs
   562  may be somewhat slower or faster.
   563  </p>
   564  
   565  <p>
   566  Library changes that affect performance are documented below.
   567  </p>
   568  
   569  <h2 id="library">Changes to the standard library</h2>
   570  
   571  <h3 id="new_packages">New packages</h3>
   572  
   573  <p>
   574  There are no new packages in this release.
   575  </p>
   576  
   577  <h3 id="major_library_changes">Major changes to the library</h3>
   578  
   579  <h4 id="scanner">bufio.Scanner</h4>
   580  
   581  <p>
   582  The <a href="/pkg/bufio/#Scanner"><code>Scanner</code></a> type in the
   583  <a href="/pkg/bufio/"><code>bufio</code></a> package
   584  has had a bug fixed that may require changes to custom
   585  <a href="/pkg/bufio/#SplitFunc"><code>split functions</code></a>. 
   586  The bug made it impossible to generate an empty token at EOF; the fix
   587  changes the end conditions seen by the split function.
   588  Previously, scanning stopped at EOF if there was no more data.
   589  As of 1.4, the split function will be called once at EOF after input is exhausted,
   590  so the split function can generate a final empty token
   591  as the documentation already promised.
   592  </p>
   593  
   594  <p>
   595  <em>Updating</em>: Custom split functions may need to be modified to
   596  handle empty tokens at EOF as desired.
   597  </p>
   598  
   599  <h4 id="syscall">syscall</h4>
   600  
   601  <p>
   602  The <a href="/pkg/syscall/"><code>syscall</code></a> package is now frozen except
   603  for changes needed to maintain the core repository.
   604  In particular, it will no longer be extended to support new or different system calls
   605  that are not used by the core.
   606  The reasons are described at length in <a href="https://golang.org/s/go1.4-syscall">a
   607  separate document</a>.
   608  </p>
   609  
   610  <p>
   611  A new subrepository, <a href="https://golang.org/x/sys">golang.org/x/sys</a>,
   612  has been created to serve as the location for new developments to support system
   613  calls on all kernels.
   614  It has a nicer structure, with three packages that each hold the implementation of
   615  system calls for one of
   616  <a href="http://godoc.org/golang.org/x/sys/unix">Unix</a>,
   617  <a href="http://godoc.org/golang.org/x/sys/windows">Windows</a> and
   618  <a href="http://godoc.org/golang.org/x/sys/plan9">Plan 9</a>.
   619  These packages will be curated more generously, accepting all reasonable changes
   620  that reflect kernel interfaces in those operating systems.
   621  See the documentation and the article mentioned above for more information.
   622  </p>
   623  
   624  <p>
   625  <em>Updating</em>: Existing programs are not affected as the <code>syscall</code>
   626  package is largely unchanged from the 1.3 release.
   627  Future development that requires system calls not in the <code>syscall</code> package
   628  should build on <code>golang.org/x/sys</code> instead.
   629  </p>
   630  
   631  <h3 id="minor_library_changes">Minor changes to the library</h3>
   632  
   633  <p>
   634  The following list summarizes a number of minor changes to the library, mostly additions.
   635  See the relevant package documentation for more information about each change.
   636  </p>
   637  
   638  <ul>
   639  
   640  <li>
   641  The <a href="/pkg/archive/zip/"><code>archive/zip</code></a> package's
   642  <a href="/pkg/archive/zip/#Writer"><code>Writer</code></a> now supports a
   643  <a href="/pkg/archive/zip/#Writer.Flush"><code>Flush</code></a> method.
   644  </li>
   645  
   646  <li>
   647  The <a href="/pkg/compress/flate/"><code>compress/flate</code></a>,
   648  <a href="/pkg/compress/gzip/"><code>compress/gzip</code></a>,
   649  and <a href="/pkg/compress/zlib/"><code>compress/zlib</code></a>
   650  packages now support a <code>Reset</code> method
   651  for the decompressors, allowing them to reuse buffers and improve performance.
   652  The <a href="/pkg/compress/gzip/"><code>compress/gzip</code></a> package also has a
   653  <a href="/pkg/compress/gzip/#Reader.Multistream"><code>Multistream</code></a> method to control support
   654  for multistream files.
   655  </li>
   656  
   657  <li>
   658  The <a href="/pkg/crypto/"><code>crypto</code></a> package now has a
   659  <a href="/pkg/crypto/#Signer"><code>Signer</code></a> interface, implemented by the
   660  <code>PrivateKey</code> types in
   661  <a href="/pkg/crypto/ecdsa"><code>crypto/ecdsa</code></a> and
   662  <a href="/pkg/crypto/rsa"><code>crypto/rsa</code></a>.
   663  </li>
   664  
   665  <li>
   666  The <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> package
   667  now supports ALPN as defined in <a href="http://tools.ietf.org/html/rfc7301">RFC 7301</a>.
   668  </li>
   669  
   670  <li>
   671  The <a href="/pkg/crypto/tls/"><code>crypto/tls</code></a> package
   672  now supports programmatic selection of server certificates
   673  through the new <a href="/pkg/crypto/tls/#Config.CertificateForName"><code>CertificateForName</code></a> function
   674  of the <a href="/pkg/crypo/tls/#Config"><code>Config</code></a> struct.
   675  </li>
   676  
   677  <li>
   678  Also in the crypto/tls package, the server now supports 
   679  <a href="https://tools.ietf.org/html/draft-ietf-tls-downgrade-scsv-00">TLS_FALLBACK_SCSV</a>
   680  to help clients detect fallback attacks.
   681  (The Go client does not support fallback at all, so it is not vulnerable to
   682  those attacks.)
   683  </li>
   684  
   685  <li>
   686  The <a href="/pkg/database/sql/"><code>database/sql</code></a> package can now list all registered
   687  <a href="/pkg/database/sql/#Drivers"><code>Drivers</code></a>.
   688  </li>
   689  
   690  <li>
   691  The <a href="/pkg/debug/dwarf/"><code>debug/dwarf</code></a> package now supports
   692  <a href="/pkg/debug/dwarf/#UnspecifiedType"><code>UnspecifiedType</code></a>s.
   693  </li>
   694  
   695  <li>
   696  In the <a href="/pkg/encoding/asn1/"><code>encoding/asn1</code></a> package,
   697  optional elements with a default value will now only be omitted if they have that value.
   698  </li>
   699  
   700  <li>
   701  The <a href="/pkg/encoding/csv/"><code>encoding/csv</code></a> package no longer
   702  quotes empty strings but does quote the end-of-data marker <code>\.</code> (backslash dot).
   703  This is permitted by the definition of CSV and allows it to work better with Postgres.
   704  </li>
   705  
   706  <li>
   707  The <a href="/pkg/encoding/gob/"><code>encoding/gob</code></a> package has been rewritten to eliminate
   708  the use of unsafe operations, allowing it to be used in environments that do not permit use of the
   709  <a href="/pkg/unsafe/"><code>unsafe</code></a> package.
   710  For typical uses it will be 10-30% slower, but the delta is dependent on the type of the data and
   711  in some cases, especially involving arrays, it can be faster.
   712  There is no functional change.
   713  </li>
   714  
   715  <li>
   716  The <a href="/pkg/encoding/xml/"><code>encoding/xml</code></a> package's
   717  <a href="/pkg/encoding/xml/#Decoder"><code>Decoder</code></a> can now report its input offset.
   718  </li>
   719  
   720  <li>
   721  In the <a href="/pkg/fmt/"><code>fmt</code></a> package,
   722  formatting of pointers to maps has changed to be consistent with that of pointers
   723  to structs, arrays, and so on.
   724  For instance, <code>&amp;map[string]int{"one":</code> <code>1}</code> now prints by default as
   725  <code>&amp;map[one:</code> <code>1]</code> rather than as a hexadecimal pointer value.
   726  </li>
   727  
   728  <li>
   729  The <a href="/pkg/image/"><code>image</code></a> package's
   730  <a href="/pkg/image/#Image"><code>Image</code></a>
   731  implementations like
   732  <a href="/pkg/image/#RGBA"><code>RGBA</code></a> and
   733  <a href="/pkg/image/#Gray"><code>Gray</code></a> have specialized
   734  <a href="/pkg/image/#RGBA.RGBAAt"><code>RGBAAt</code></a> and
   735  <a href="/pkg/image/#Gray.GrayAt"><code>GrayAt</code></a> methods alongside the general
   736  <a href="/pkg/image/#Image.At"><code>At</code></a> method.
   737  </li>
   738  
   739  <li>
   740  The <a href="/pkg/image/png/"><code>image/png</code></a> package now has an
   741  <a href="/pkg/image/png/#Encoder"><code>Encoder</code></a>
   742  type to control the compression level used for encoding.
   743  </li>
   744  
   745  <li>
   746  The <a href="/pkg/math/"><code>math</code></a> package now has a
   747  <a href="/pkg/math/#Nextafter32"><code>Nextafter32</code><a/> function.
   748  </li>
   749  
   750  <li>
   751  The <a href="/pkg/net/http/"><code>net/http</code></a> package's
   752  <a href="/pkg/net/http/#Request"><code>Request</code></a> type
   753  has a new <a href="/pkg/net/http/#Request.BasicAuth"><code>BasicAuth</code></a> method
   754  that returns the username and password from authenticated requests using the
   755  HTTP Basic Authentication
   756  Scheme.
   757  </li>
   758  
   759  <li>The <a href="/pkg/net/http/"><code>net/http</code></a> package's
   760  <a href="/pkg/net/http/#Request"><code>Transport</code></a> type
   761  has a new <a href="/pkg/net/http/#Transport.DialTLS"><code>DialTLS</code></a> hook
   762  that allows customizing the behavior of outbound TLS connections.
   763  </li>
   764  
   765  <li>
   766  The <a href="/pkg/net/http/httputil/"><code>net/http/httputil</code></a> package's
   767  <a href="/pkg/net/http/httputil/#ReverseProxy"><code>ReverseProxy</code></a> type
   768  has a new field,
   769  <a href="/pkg/net/http/#ReverseProxy.ErrorLog"><code>ErrorLog</code></a>, that
   770  provides user control of logging.
   771  </li>
   772  
   773  <li>
   774  The <a href="/pkg/os/"><code>os</code></a> package
   775  now implements symbolic links on the Windows operating system
   776  through the <a href="/pkg/os/#Symlink"><code>Symlink</code></a> function.
   777  Other operating systems already have this functionality.
   778  There is also a new <a href="/pkg/os/#Unsetenv"><code>Unsetenv</code></a> function.
   779  </li>
   780  
   781  <li>
   782  The <a href="/pkg/reflect/"><code>reflect</code></a> package's
   783  <a href="/pkg/reflect/#Type"><code>Type</code></a> interface
   784  has a new method, <a href="/pkg/reflect/#type.Comparable"><code>Comparable</code></a>,
   785  that reports whether the type implements general comparisons.
   786  </li>
   787  
   788  <li>
   789  Also in the <a href="/pkg/reflect/"><code>reflect</code></a> package, the
   790  <a href="/pkg/reflect/#Value"><code>Value</code></a> interface is now three instead of four words
   791  because of changes to the implementation of interfaces in the runtime.
   792  This saves memory but has no semantic effect.
   793  </li>
   794  
   795  <li>
   796  The <a href="/pkg/runtime/"><code>runtime</code></a> package
   797  now implements monotonic clocks on Windows,
   798  as it already did for the other systems.
   799  </li>
   800  
   801  <li>
   802  The <a href="/pkg/runtime/"><code>runtime</code></a> package's
   803  <a href="/pkg/runtime/#MemStats.Mallocs"><code>Mallocs</code></a> counter
   804  now counts very small allocations that were missed in Go 1.3.
   805  This may break tests using <a href="/pkg/runtime/#ReadMemStats"><code>ReadMemStats</code></a>
   806  or <a href="/pkg/testing/#AllocsPerRun"><code>AllocsPerRun</code></a>
   807  due to the more accurate answer.
   808  </li>
   809  
   810  <li>
   811  In the <a href="/pkg/runtime/"><code>runtime</code></a> package,
   812  an array <a href="/pkg/runtime/#MemStats.PauseEnd"><code>PauseEnd</code></a>
   813  has been added to the
   814  <a href="/pkg/runtime/#MemStats"><code>MemStats</code></a>
   815  and <a href="/pkg/runtime/#GCStats"><code>GCStats</code></a> structs.
   816  This array is a circular buffer of times when garbage collection pauses ended.
   817  The corresponding pause durations are already recorded in
   818  <a href="/pkg/runtime/#MemStats.PauseNs"><code>PauseNs</code></a>
   819  </li>
   820  
   821  <li>
   822  The <a href="/pkg/runtime/race/"><code>runtime/race</code></a> package
   823  now supports FreeBSD, which means the
   824  <a href="/pkg/cmd/go/"><code>go</code></a> command's <code>-race</code>
   825  flag now works on FreeBSD.
   826  </li>
   827  
   828  <li>
   829  The <a href="/pkg/sync/atomic/"><code>sync/atomic</code></a> package
   830  has a new type, <a href="/pkg/sync/atomic/#Value"><code>Value</code></a>.
   831  <code>Value</code> provides an efficient mechanism for atomic loads and
   832  stores of values of arbitrary type.
   833  </li>
   834  
   835  <li>
   836  In the <a href="/pkg/syscall/"><code>syscall</code></a> package's
   837  implementation on Linux, the
   838  <a href="/pkg/syscall/#Setuid"><code>Setuid</code></a>
   839  and <a href="/pkg/syscall/#Setgid"><code>Setgid</code></a> have been disabled
   840  because those system calls operate on the calling thread, not the whole process, which is
   841  different from other platforms and not the expected result.
   842  </li>
   843  
   844  <li>
   845  The <a href="/pkg/testing/"><code>testing</code></a> package
   846  has a new facility to provide more control over running a set of tests.
   847  If the test code contains a function
   848  <pre>
   849  func TestMain(m *<a href="/pkg/testing/#M"><code>testing.M</code></a>) 
   850  </pre>
   851  
   852  that function will be called instead of running the tests directly.
   853  The <code>M</code> struct contains methods to access and run the tests.
   854  </li>
   855  
   856  <li>
   857  Also in the <a href="/pkg/testing/"><code>testing</code></a> package,
   858  a new <a href="/pkg/testing/#Coverage"><code>Coverage</code></a>
   859  function reports the current test coverage fraction,
   860  enabling individual tests to report how much they are contributing to the
   861  overall coverage.
   862  </li>
   863  
   864  <li>
   865  The <a href="/pkg/text/scanner/"><code>text/scanner</code></a> package's
   866  <a href="/pkg/text/scanner/#Scanner"><code>Scanner</code></a> type
   867  has a new function,
   868  <a href="/pkg/text/scanner/#Scanner.IsIdentRune"><code>IsIdentRune</code></a>,
   869  allowing one to control the definition of an identifier when scanning.
   870  </li>
   871  
   872  <li>
   873  The <a href="/pkg/text/template/"><code>text/template</code></a> package's boolean
   874  functions <code>eq</code>, <code>lt</code>, and so on have been generalized to allow comparison
   875  of signed and unsigned integers, simplifying their use in practice.
   876  (Previously one could only compare values of the same signedness.)
   877  All negative values compare less than all unsigned values.
   878  </li>
   879  
   880  <li>
   881  The <code>time</code> package now uses the standard symbol for the micro prefix,
   882  the micro symbol (U+00B5 'ยต'), to print microsecond durations.
   883  <a href="/pkg/time/#ParseDuration"><code>ParseDuration</code></a> still accepts <code>us</code>
   884  but the package no longer prints microseconds as <code>us</code>.
   885  <br>
   886  <em>Updating</em>: Code that depends on the output format of durations
   887  but does not use ParseDuration will need to be updated.
   888  </li>
   889  
   890  </ul>