github.com/razvanm/vanadium-go-1.3@v0.0.0-20160721203343-4a65068e5915/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  and contains only one tiny language change,
    12  a backwards-compatible simple form of <code>for</code>-<code>range</code> loop.
    13  The release focuses primarily on implementation work, improving the garbage collector
    14  and preparing the ground for a fully concurrent collector to be rolled out in the
    15  next few releases.
    16  Stacks are now contiguous, reallocated when necessary rather than linking on new
    17  "segments";
    18  this release therefore eliminates the notorious "hot stack split" problem.
    19  There are some new tools available including support in the <code>go</code> command
    20  for build-time source code generation
    21  and TODO.
    22  The release also adds support for TODO architecture and TODO operating systems.
    23  As always, Go 1.4 keeps the <a href="/doc/go1compat.html">promise
    24  of compatibility</a>,
    25  and almost everything 
    26  will continue to compile and run without change when moved to 1.4.
    27  </p>
    28  
    29  <h2 id="language">Changes to the language</h2>
    30  
    31  <h3 id="forrange">For-range loops</h3>
    32  <p>
    33  Up until Go 1.3, <code>for</code>-<code>range</code> loop had two forms
    34  </p>
    35  
    36  <pre>
    37  for k, v := range x {
    38  	...
    39  }
    40  </pre>
    41  
    42  <p>
    43  and
    44  </p>
    45  
    46  <pre>
    47  for k := range x {
    48  	...
    49  }
    50  </pre>
    51  
    52  <p>
    53  If one was not interested in the loop values, only the iteration itself, it was still
    54  necessary to mention a variable (probably the <a href="/ref/spec#Blank_identifier">blank identifier</a>, as in
    55  <code>for</code> <code>_</code> <code>=</code> <code>range</code> <code>x</code>), because
    56  the form
    57  </p>
    58  
    59  <pre>
    60  for range x {
    61  	...
    62  }
    63  </pre>
    64  
    65  <p>
    66  was not syntactically permitted.
    67  </p>
    68  
    69  <p>
    70  This situation seemed awkward, so as of Go 1.4 the variable-free form is now legal.
    71  The situation arises only rarely but the code can be cleaner when it does.
    72  </p>
    73  
    74  <p>
    75  <em>Updating</em>: The change is strictly backwards compatible to existing Go
    76  programs, but tools that analyze Go parse trees may need to be modified to accept
    77  this new form as the
    78  <code>Key</code> field of <a href="/pkg/go/ast/#RangeStmt"><code>RangeStmt</code></a>
    79  may now be <code>nil</code>.
    80  </p>
    81  
    82  <h2 id="os">Changes to the supported operating systems and architectures</h2>
    83  
    84  <h3 id="foobarblatz">FooBarBlatz</h3>
    85  
    86  <p>
    87  TODO news about foobarblatz
    88  </p>
    89  
    90  <h2 id="compatibility">Changes to the compatibility guidelines</h2>
    91  
    92  <p>
    93  The <a href="/pkg/unsafe/"><code>unsafe</code></a> package allows one
    94  to defeat Go's type system by exploiting internal details of the implementation
    95  or machine representation of data.
    96  It was never explicitly specified what use of <code>unsafe</code> meant
    97  with respect to compatibility as specified in the
    98  <a href="go1compat.html">Go compatibilty guidelines</a>.
    99  The answer, of course, is that we can make no promise of compatibility
   100  for code that does unsafe things.
   101  </p>
   102  
   103  <p>
   104  We have clarified this situation in the documentation included in the release.
   105  The <a href="go1compat.html">Go compatibilty guidelines</a> and the
   106  docs for the <a href="/pkg/unsafe/"><code>unsafe</code></a> package
   107  are now explicit that unsafe code is not guaranteed to remain compatible.
   108  </p>
   109    
   110  <p>
   111  <em>Updating</em>: Nothing technical has changed; this is just a clarification
   112  of the documentation.
   113  </p>
   114  
   115  
   116  <h2 id="impl">Changes to the implementations and tools</h2>
   117  
   118  <h3 id="runtime">Changes to the runtime</h3>
   119  
   120  <p>
   121  Up to Go 1.4, the runtime (garbage collector, concurrency support, interface management,
   122  maps, slices, strings, ...) was mostly written in C, with some assembler support.
   123  In 1.4, much of the code has been translated to Go so that the garbage collector can scan
   124  the stacks of programs in the runtime and get accurate information about what variables
   125  are active.
   126  This change was large but should have no semantic effect on programs.
   127  </p>
   128  
   129  <p>
   130  This rewrite allows the garbage collector in 1.4 to be fully precise,
   131  meaning that it is aware of the location of all active pointers in the program.
   132  This means the heap will be smaller as there will be no false positives keeping non-pointers alive.
   133  Other related changes also reduce the heap size, which is smaller by 10%-30% overall
   134  relative to the previous release.
   135  </p>
   136  
   137  <p>
   138  A consequence is that stacks are no longer segmented, eliminating the "hot split" problem.
   139  When a stack limit is reached, a new, larger stack is allocated, all active frames for
   140  the goroutine are copied there, and any pointers into the stack are updated.
   141  Performance can be noticeably better in some cases and is always more predictable.
   142  Details are available in <a href="/s/contigstacks">the design document</a>.
   143  </p>
   144  
   145  <p>
   146  The use of contiguous stacks means that stacks can start smaller without triggering performance issues,
   147  so the default starting size for a goroutine's stack in 1.4 has been reduced to 2048 bytes from 8192 bytes.
   148  TODO: It may be bumped to 4096 for the release.
   149  </p>
   150  
   151  <p>
   152  As preparation for the concurrent garbage collector scheduled for the 1.5 release,
   153  writes to pointer values in the heap are now done by a function call,
   154  called a write barrier, rather than directly from the function updating the value.
   155  In this next release, this will permit the garbage collector to mediate writes to the heap while it is running.
   156  This change has no semantic effect on programs in 1.4, but was
   157  included in the release to test the compiler and the resulting performance.
   158  </p>
   159  
   160  <p>
   161  The implementation of interface values has been modified.
   162  In earlier releases, the interface contained a word that was either a pointer or a one-word
   163  scalar value, depending on the type of the concrete object stored.
   164  This implementation was problematical for the garbage collector,
   165  so as of 1.4 interface values always hold a pointer.
   166  In running programs, most interface values were pointers anyway,
   167  so the effect is minimal, but programs that store integers (for example) in
   168  interfaces will see more allocations.
   169  </p>
   170  
   171  <h3 id="gccgo">Status of gccgo</h3>
   172  
   173  <p>
   174  TODO gccgo news
   175  </p>
   176  
   177  <h3 id="internalpackages">Internal packages</h3>
   178  <pre>
   179  TODO prose for these
   180  cmd/go: implement "internal" (CL 120600043)
   181  </pre>
   182  
   183  <h3 id="importcomments">Import comments</h3>
   184  
   185  <pre>
   186  TODO prose for these
   187  cmd/go: import comments (CL 124940043)
   188  </pre>
   189  
   190  <h3 id="gogenerate">The go generate subcommand</h3>
   191  
   192  <p>
   193  The <a href="/cmd/go/"><code>go</code></a> command has a new subcommand,
   194  <a href="/cmd/go/#hdr-Generate_Go_files_by_processing_source"><code>go generate</code></a>,
   195  to automate the running of tools to generate source code before compilation.
   196  For example, it can be used to run the <a href="http://en.wikipedia.org/wiki/Yacc"><code>yacc</code></a>
   197  compiler-compiler on a <code>.y</code> file to produce the Go source file implementing the grammar,
   198  or to automate the generation of <code>String</code> methods for typed constants using the new
   199  <a href="http://godoc.org/code.google.com/p/go.tools/cmd/stringer">stringer</a>
   200  tool in the <code>go.tools</code> repository.
   201  </p>
   202  
   203  <p>
   204  For more information, see the 
   205  <a href="http://golang.org/s/go1.4-generate">design document</a>.
   206  </p>
   207  
   208  <h3 id="filenames">Change to file name handling</h3>
   209  
   210  <p>
   211  Build constraints, also known as build tags, control compilation by including or excluding files
   212  (see the documentation <a href="/pkg/go/build/"><code>/go/build</code></a>).
   213  Compilation can also be controlled by the name of the file itself by "tagging" the file with
   214  a suffix (before the <code>.go</code> or <code>.s</code> extension) with an underscore
   215  and the name of the architecture or operating system.
   216  For instance, the file <code>gopher_arm.go</code> will only be compiled if the target
   217  processor is an ARM.
   218  </p>
   219  
   220  <p>
   221  Before Go 1.4, a file called just <code>arm.go</code> was similarly tagged, but this behavior
   222  can break sources when new architectures are added, causing files to suddenly become tagged.
   223  In 1.4, therefore, a file will be tagged in this manner only if the tag (architecture or operating
   224  system name) is preceded by an underscore.
   225  </p>
   226  
   227  <p>
   228  <em>Updating</em>: Packages that depend on the old behavior will no longer compile correctly.
   229  Files with names like <code>windows.go</code> or <code>arm64.go</code> should either
   230  have explicit build tags added to the source or be renamed to something like
   231  <code>os_windows.go</code> or <code>support_arm64.go</code>.
   232  </p>
   233  
   234  <h3 id="gocmd">Other changes to the go command</h3>
   235  
   236  <p>
   237  There were a number of minor changes to the
   238  <a href="/cmd/go/"><code>cmd/go</code></a>
   239  command worth noting.
   240  </p>
   241  
   242  <ul>
   243  
   244  <li>
   245  Unless <a href="/cmd/cgo/"><code>cgo</code></a> is being used to build the package,
   246  the <code>go</code> command now refuses to compile C source files,
   247  since the relevant C compilers
   248  (<a href="/cmd/6c/"><code>6c</code></a> etc.)
   249  are intended to be removed from the installation in some future release.
   250  (They are used today only to build part of the runtime.)
   251  It is difficult to use them correctly in any case, so any extant uses are likely incorrect,
   252  so we have disabled them.
   253  </li>
   254  
   255  <li>
   256  The <a href="/cmd/go/#hdr-Test_packages"><code>go</code> <code>test</code></a>
   257  subcommand has a new flag, <code>-o</code>, to set the name of the resulting binary,
   258  corresponding to the same flag in other subcommands.
   259  The non-functional <code>-file</code> flag has been removed.
   260  </li>
   261  
   262  <li>
   263  The <a href="/cmd/go/#hdr-Test_packages"><code>go</code> <code>test</code></a>
   264  will compile and link all <code>*_test.go</code> files in the package,
   265  even when there are no <code>Test</code> functions in them. 
   266  It previously ignored such files.
   267  </li>
   268  
   269  <li>
   270  The behavior of the
   271  <a href="/cmd/go/#hdr-Test_packages"><code>go</code> <code>build</code></a>'s
   272  <code>-a</code> flag has been changed for non-development installations.
   273  For installations running a released distribution, the <code>-a</code> flag will no longer
   274  rebuild the standard library and commands, to avoid overwriting the installation's files.
   275  </li>
   276  
   277  </ul>
   278  
   279  <h3 id="cgo">Changes to cgo</h3>
   280  
   281  <p>
   282  TODO cgo news
   283  </p>
   284  
   285  
   286  <h3 id="godoc">Changes to godoc</h3>
   287  <p>
   288  TODO godoc news
   289  </p>
   290  
   291  <h3 id="pkg">Changes to package source layout</h3>
   292  
   293  <p>
   294  In the main Go source repository, the source code for the packages was kept in
   295  the directory <code>src/pkg</code>, which made sense but differed from
   296  other repositories, including the Go sub-repositories such as <code>go.tools</code>.
   297  In Go 1.4, the<code> pkg</code> level of the source tree is now gone, so for example
   298  the <a href="/pkg/fmt/"><code>fmt</code></a> package's source, once kept in
   299  directory <code>src/pkg/fmt</code>, now lives one level higher in <code>src/fmt</code>.
   300  </p>
   301  
   302  <p>
   303  <em>Updating</em>: Tools like <code>godoc</code> that discover source code
   304  need to know about the new location. All tools and services maintained by the Go team
   305  have been updated.
   306  </p>
   307  
   308  <h3 id="misc">Miscellany</h3>
   309  
   310  <p>
   311  TODO misc news
   312  </p>
   313  
   314  <h2 id="performance">Performance</h2>
   315  
   316  <p>
   317  Most programs will run about the same speed or slightly faster in 1.4 than in 1.3;
   318  some will be slightly slower.
   319  There are many changes, making it hard to be precise about what to expect.
   320  </p>
   321  
   322  <p>
   323  As mentioned above, much of the runtime was translated to Go from C,
   324  which led to some reduction in heap sizes.
   325  It also improved performance slightly because the Go compiler is better
   326  at optimization, due to things like inlining, than the C compiler used to build
   327  the runtime.
   328  </p>
   329  
   330  <p>
   331  The garbage collector was sped up, leading to measurable improvements for
   332  garbage-heavy programs.
   333  On the other hand, the new write barriers slow things down again, typically
   334  by about the same amount but, depending on their behavior, some programs
   335  may be somewhat slower or faster.
   336  </p>
   337  
   338  <p>
   339  Library changes that affect performance are documented below.
   340  </p>
   341  
   342  <h2 id="library">Changes to the standard library</h2>
   343  
   344  <h3 id="new_packages">New packages</h3>
   345  
   346  <p>
   347  TODO new packages
   348  </p>
   349  
   350  <h3 id="major_library_changes">Major changes to the library</h3>
   351  
   352  <p>
   353  TODO major changes
   354  </p>
   355  
   356  <h3 id="minor_library_changes">Minor changes to the library</h3>
   357  
   358  <p>
   359  The following list summarizes a number of minor changes to the library, mostly additions.
   360  See the relevant package documentation for more information about each change.
   361  </p>
   362  
   363  <ul>
   364  
   365  <li> TODO changes
   366  </li>
   367  </ul>
   368  
   369  <pre>
   370  
   371  cmd/6l, liblink: use pc-relative addressing for all memory references, so that linking Go binaries at high addresses works (CL 125140043). This cuts the maximum size of a Go binary's text+data+bss from 4GB to 2GB.
   372  
   373  asm: make textflag.h available outside of cmd/ld (CL 128050043)
   374  bufio: handling of empty tokens at EOF changed, may require scanner change (CL 145390043)
   375  compress/flate, compress/gzip, compress/zlib: Reset support (https://codereview.appspot.com/97140043)
   376  crypto/tls: add support for ALPN (RFC 7301) (CL 108710046)
   377  crypto/tls: support programmatic selection of server certificates (CL 107400043)
   378  encoding/asn1: optional elements with a default value will now only be omitted if they have that value (CL 86960045)
   379  flag: it is now an error to set a flag multiple times (CL 156390043)
   380  fmt: print type *map[T]T as &amp;map[k:v] (CL 154870043)
   381  encoding/csv: do not quote empty strings, quote \. (CL 164760043)
   382  encoding/gob: remove unsafe (CL 102680045)
   383  misc: deleted editor support; refer to https://code.google.com/p/go-wiki/wiki/IDEsAndTextEditorPlugins instead (CL 105470043)
   384  net/http: add Request.BasicAuth method (CL 76540043)
   385  net/http: add Transport.DialTLS hook (CL 137940043)
   386  net/http/httputil: add ReverseProxy.ErrorLog (CL 132750043)
   387  os: implement symlink support for windows (CL 86160044)
   388  reflect: add type.Comparable (CL 144020043)
   389  reflect: Value is one word smaller
   390  runtime: implement monotonic clocks on windows (CL 108700045)
   391  runtime: MemStats.Mallocs now counts very small allocations missed in Go 1.3. This may break tests using runtime.ReadMemStats or testing.AllocsPerRun by giving a more accurate answer than Go 1.3 did (CL 143150043).
   392  runtime/race: freebsd is supported (CL 107270043)
   393  swig: Due to runtime changes Go 1.4 will require SWIG 3.0.3 (not yet released)
   394  sync/atomic: add Value (CL 136710045)
   395  syscall: Setuid, Setgid are disabled on linux platforms. On linux those syscalls operate on the calling thread, not the whole process. This does not match the semantics of other platforms, nor the expectations of the caller, so the operations have been disabled until issue 1435 is resolved (CL 106170043)
   396  syscall: now frozen (CL 129820043)
   397  testing: add Coverage (CL 98150043)
   398  testing: add TestMain support (CL 148770043)
   399  text/scanner: add IsIdentRune field of Scanner. (CL 108030044)
   400  text/template: allow comparison of signed and unsigned integers (CL 149780043)
   401  time: use the micro symbol (ยต (U+00B5)) to print microsecond duration (CL 105030046)
   402  unsafe: document the existing situation that unsafe programs are not go1-guaranteed (CL 162060043)
   403  
   404  go.sys subrepo created: http://golang.org/s/go1.4-syscall
   405  </pre>