github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/doc/devel/release.html (about)

     1  <!--{
     2  	"Title": "Release History"
     3  }-->
     4  
     5  <p>This page summarizes the changes between official stable releases of Go.
     6  The <a href="http://code.google.com/p/go/source/list">Mercurial change log</a>
     7  has the full details.</p>
     8  
     9  <p>To update to a specific release, use:</p>
    10  
    11  <pre>
    12  hg pull
    13  hg update <i>tag</i>
    14  </pre>
    15  
    16  <h2 id="go1">go1 (released 2012/03/28)</h2>
    17  
    18  <p>
    19  Go 1 is a major release of Go that will be stable in the long term.
    20  Read the <a href="/doc/go1.html">Go 1 Release Notes</a> for more information.
    21  </p>
    22  
    23  <p>
    24  It is intended that programs written for Go 1 will continue to compile and run
    25  correctly, unchanged, under future versions of Go 1.
    26  Read the <a href="/doc/go1compat.html">Go 1 compatibility document</a> for more
    27  about the future of Go 1.
    28  </p>
    29  
    30  <p>
    31  The go1 release corresponds to 
    32  <code><a href="weekly.html#2012-03-27">weekly.2012-03-27</a></code>.
    33  </p>
    34  
    35  <h3 id="go1.minor">Minor revisions</h3>
    36  
    37  <p>
    38  go1.0.1 (released 2012/04/25) was issued to
    39  <a href="https://code.google.com/p/go/source/detail?r=a890477d3dfb">fix</a> an
    40  <a href="https://code.google.com/p/go/issues/detail?id=3545">escape analysis
    41  bug</a> that can lead to memory corruption.
    42  It also includes several minor code and documentation fixes.
    43  </p>
    44  
    45  <p>
    46  go1.0.2 (released 2012/06/13) was issued to fix two bugs in the implementation
    47  of maps using struct or array keys: 
    48  <a href="http://code.google.com/p/go/issues/detail?id=3695">issue 3695</a> and
    49  <a href="http://code.google.com/p/go/issues/detail?id=3573">issue 3573</a>.
    50  It also includes many minor code and documentation fixes.
    51  </p>
    52  
    53  <p>
    54  go1.0.3 (released 2012/09/21) includes minor code and documentation fixes.
    55  </p>
    56  
    57  <p>
    58  See the <a href="http://code.google.com/p/go/source/list?name=release-branch.go1">go1 release branch history</a> for the complete list of changes.
    59  </p>
    60  
    61  <h2 id="r60">r60 (released 2011/09/07)</h2>
    62  
    63  <p>
    64  The r60 release corresponds to 
    65  <code><a href="weekly.html#2011-08-17">weekly.2011-08-17</a></code>.
    66  This section highlights the most significant changes in this release.
    67  For a more detailed summary, see the
    68  <a href="weekly.html#2011-08-17">weekly release notes</a>.
    69  For complete information, see the
    70  <a href="http://code.google.com/p/go/source/list?r=release-branch.r60">Mercurial change list</a>.
    71  </p>
    72  
    73  <h3 id="r60.lang">Language</h3>
    74  
    75  <p>
    76  An "else" block is now required to have braces except if the body of the "else"
    77  is another "if". Since gofmt always puts those braces in anyway,
    78  gofmt-formatted programs will not be affected.
    79  To fix other programs, run gofmt.
    80  </p>
    81  
    82  <h3 id="r60.pkg">Packages</h3>
    83  
    84  <p>
    85  <a href="/pkg/http/">Package http</a>'s URL parsing and query escaping code
    86  (such as <code>ParseURL</code> and <code>URLEscape</code>) has been moved to
    87  the new <a href="/pkg/url/">url package</a>, with several simplifications to
    88  the names. Client code can be updated automatically with gofix.
    89  </p>
    90  
    91  <p>
    92  <a href="/pkg/image/">Package image</a> has had significant changes made to the
    93  <code>Pix</code> field of struct types such as
    94  <a href="/pkg/image/#RGBA">image.RGBA</a> and
    95  <a href="/pkg/image/#NRGBA">image.NRGBA</a>.
    96  The <a href="/pkg/image/#Image">image.Image</a> interface type has not changed,
    97  though, and you should not need to change your code if you don't explicitly
    98  refer to <code>Pix</code> fields. For example, if you decode a number of images
    99  using the <a href="/pkg/image/jpeg/">image/jpeg</a> package, compose them using
   100  <a href="/pkg/image/draw/">image/draw</a>, and then encode the result using
   101  <a href="/pkg/img/png">image/png</a>, then your code should still work as
   102  before.
   103  If your code <i>does</i> refer to <code>Pix</code> fields see the 
   104  <a href="/doc/devel/weekly.html#2011-07-19">weekly.2011-07-19</a>
   105  snapshot notes for how to update your code.
   106  </p>
   107  
   108  <p>
   109  <a href="/pkg/template/">Package template</a> has been replaced with a new
   110  templating package (formerly <code>exp/template</code>). The original template
   111  package is still available as <a href="/pkg/old/template/">old/template</a>.
   112  The <code>old/template</code> package is deprecated and will be removed.
   113  The Go tree has been updated to use the new template package. We encourage
   114  users of the old template package to switch to the new one. Code that uses
   115  <code>template</code> or <code>exp/template</code> will need to change its
   116  import lines to <code>"old/template"</code> or <code>"template"</code>,
   117  respectively.
   118  </p>
   119  
   120  <h3 id="r60.cmd">Tools</h3>
   121  
   122  <p>
   123  <a href="/cmd/goinstall/">Goinstall</a> now uses a new tag selection scheme.
   124  When downloading or updating, goinstall looks for a tag or branch with the
   125  <code>"go."</code> prefix that corresponds to the local Go version. For Go
   126  <code>release.r58</code> it looks for <code>go.r58</code>. For
   127  <code>weekly.2011-06-03</code> it looks for <code>go.weekly.2011-06-03</code>.
   128  If the specific <code>go.X</code> tag or branch is not found, it chooses the
   129  closest earlier version. If an appropriate tag or branch is found, goinstall
   130  uses that version of the code. Otherwise it uses the default version selected
   131  by the version control system. Library authors are encouraged to use the
   132  appropriate tag or branch names in their repositories to make their libraries
   133  more accessible.
   134  </p>
   135  
   136  <h3 id="r60.minor">Minor revisions</h3>
   137  
   138  <p>
   139  r60.1 includes a 
   140  <a href="http://code.google.com/p/go/source/detail?r=1824581bf62d">linker
   141  fix</a>, a pair of
   142  <a href="http://code.google.com/p/go/source/detail?r=9ef4429c2c64">goplay</a>
   143  <a href="http://code.google.com/p/go/source/detail?r=d42ed8c3098e">fixes</a>,
   144  and a <code>json</code> package
   145  <a href="http://code.google.com/p/go/source/detail?r=d5e97874fe84">fix</a> and
   146  a new
   147  <a href="http://code.google.com/p/go/source/detail?r=4f0e6269213f">struct tag
   148  option</a>.
   149  </p>
   150  
   151  <p>
   152  r60.2
   153  <a href="http://code.google.com/p/go/source/detail?r=ff19536042ac">fixes</a>
   154  a memory leak involving maps.
   155  </p>
   156  
   157  <p>
   158  r60.3 fixes a
   159  <a href="http://code.google.com/p/go/source/detail?r=01fa62f5e4e5">reflect bug</a>.
   160  </p>
   161  
   162  <h2 id="r59">r59 (released 2011/08/01)</h2>
   163  
   164  <p>
   165  The r59 release corresponds to 
   166  <code><a href="weekly.html#2011-07-07">weekly.2011-07-07</a></code>.
   167  This section highlights the most significant changes in this release.
   168  For a more detailed summary, see the
   169  <a href="weekly.html#2011-07-07">weekly release notes</a>.
   170  For complete information, see the
   171  <a href="http://code.google.com/p/go/source/list?r=release-branch.r59">Mercurial change list</a>.
   172  </p>
   173  
   174  <h3 id="r59.lang">Language</h3>
   175  
   176  <p>
   177  This release includes a language change that restricts the use of
   178  <code>goto</code>.  In essence, a <code>goto</code> statement outside a block
   179  cannot jump to a label inside that block. Your code may require changes if it
   180  uses <code>goto</code>.
   181  See <a href="http://code.google.com/p/go/source/detail?r=dc6d3cf9279d">this
   182  changeset</a> for how the new rule affected the Go tree.
   183  </p>
   184  
   185  <h3 id="r59.pkg">Packages</h3>
   186  
   187  <p>
   188  As usual, <a href="/cmd/gofix/">gofix</a> will handle the bulk of the rewrites
   189  necessary for these changes to package APIs.
   190  </p>
   191  
   192  <p>
   193  <a href="/pkg/http">Package http</a> has a new
   194  <a href="/pkg/http/#FileSystem">FileSystem</a> interface that provides access
   195  to files. The <a href="/pkg/http/#FileServer">FileServer</a> helper now takes a
   196  <code>FileSystem</code> argument instead of an explicit file system root. By
   197  implementing your own <code>FileSystem</code> you can use the
   198  <code>FileServer</code> to serve arbitrary data.
   199  </p>
   200  
   201  <p>
   202  <a href="/pkg/os/">Package os</a>'s <code>ErrorString</code> type has been
   203  hidden. Most uses of <code>os.ErrorString</code> can be replaced with
   204  <a href="/pkg/os/#NewError">os.NewError</a>.
   205  </p>
   206  
   207  <p>
   208  <a href="/pkg/reflect/">Package reflect</a> supports a new struct tag scheme
   209  that enables sharing of struct tags between multiple packages.
   210  In this scheme, the tags must be of the form:
   211  </p>
   212  <pre>
   213  	`key:"value" key2:"value2"`
   214  </pre>
   215  <p>
   216  The <a href="/pkg/reflect/#StructField">StructField</a> type's Tag field now
   217  has type <a href="/pkg/reflect/#StructTag">StructTag</a>, which has a
   218  <code>Get</code> method. Clients of <a href="/pkg/json">json</a> and
   219  <a href="/pkg/xml">xml</a> will need to be updated. Code that says
   220  </p>
   221  <pre>
   222  	type T struct {
   223  		X int "name"
   224  	}
   225  </pre>
   226  <p>
   227  should become
   228  </p>
   229  <pre>
   230  	type T struct {
   231  		X int `json:"name"`  // or `xml:"name"`
   232  	}
   233  </pre>
   234  <p>
   235  Use <a href="/cmd/govet/">govet</a> to identify struct tags that need to be
   236  changed to use the new syntax.
   237  </p>
   238  
   239  <p>
   240  <a href="/pkg/sort/">Package sort</a>'s <code>IntArray</code> type has been
   241  renamed to <a href="/pkg/sort/#IntSlice">IntSlice</a>, and similarly for
   242  <a href="/pkg/sort/#Float64Slice">Float64Slice</a> and
   243  <a href="/pkg/sort/#StringSlice">StringSlice</a>.
   244  </p>
   245  
   246  <p>
   247  <a href="/pkg/strings/">Package strings</a>'s <code>Split</code> function has
   248  itself been split into <a href="/pkg/strings/#Split">Split</a> and
   249  <a href="/pkg/strings/#SplitN">SplitN</a>.
   250  <code>SplitN</code> is the same as the old <code>Split</code>.
   251  The new <code>Split</code> is equivalent to <code>SplitN</code> with a final
   252  argument of -1.
   253  </p>
   254  
   255  <a href="/pkg/image/draw/">Package image/draw</a>'s
   256  <a href="/pkg/image/draw/#Draw">Draw</a> function now takes an additional
   257  argument, a compositing operator.
   258  If in doubt, use <a href="/pkg/image/draw/#Op">draw.Over</a>.
   259  </p>
   260  
   261  <h3 id="r59.cmd">Tools</h3>
   262  
   263  <p>
   264  <a href="/cmd/goinstall/">Goinstall</a> now installs packages and commands from
   265  arbitrary remote repositories (not just Google Code, Github, and so on).
   266  See the <a href="/cmd/goinstall/">goinstall documentation</a> for details.
   267  </p>
   268  
   269  <h2 id="r58">r58 (released 2011/06/29)</h2>
   270  
   271  <p>
   272  The r58 release corresponds to 
   273  <code><a href="weekly.html#2011-06-09">weekly.2011-06-09</a></code>
   274  with additional bug fixes.
   275  This section highlights the most significant changes in this release.
   276  For a more detailed summary, see the
   277  <a href="weekly.html#2011-06-09">weekly release notes</a>.
   278  For complete information, see the
   279  <a href="http://code.google.com/p/go/source/list?r=release-branch.r58">Mercurial change list</a>.
   280  </p>
   281  
   282  <h3 id="r58.lang">Language</h3>
   283  
   284  <p>
   285  This release fixes a <a href="http://code.google.com/p/go/source/detail?r=b720749486e1">use of uninitialized memory in programs that misuse <code>goto</code></a>.
   286  </p>
   287  
   288  <h3 id="r58.pkg">Packages</h3>
   289  
   290  <p>
   291  As usual, <a href="/cmd/gofix/">gofix</a> will handle the bulk of the rewrites
   292  necessary for these changes to package APIs.
   293  </p>
   294  
   295  <p>
   296  <a href="/pkg/http/">Package http</a> drops the <code>finalURL</code> return
   297  value from the <a href="/pkg/http/#Client.Get">Client.Get</a> method. The value
   298  is now available via the new <code>Request</code> field on <a
   299  href="/pkg/http/#Response">http.Response</a>.
   300  Most instances of the type map[string][]string in have been
   301  replaced with the new <a href="/pkg/http/#Values">Values</a> type.
   302  </p>
   303  
   304  <p>
   305  <a href="/pkg/exec/">Package exec</a> has been redesigned with a more
   306  convenient and succinct API.
   307  </p>
   308  
   309  <p>
   310  <a href="/pkg/strconv/">Package strconv</a>'s <a href="/pkg/strconv/#Quote">Quote</a>
   311  function now escapes only those Unicode code points not classified as printable
   312  by <a href="/pkg/unicode/#IsPrint">unicode.IsPrint</a>.
   313  Previously Quote would escape all non-ASCII characters.
   314  This also affects the <a href="/pkg/fmt/">fmt</a> package's <code>"%q"</code>
   315  formatting directive. The previous quoting behavior is still available via
   316  strconv's new <a href="/pkg/strconv/#QuoteToASCII">QuoteToASCII</a> function.   
   317  </p>
   318  
   319  <p>
   320  <a href="/pkg/os/signal/">Package os/signal</a>'s
   321  <a href="/pkg/os/#Signal">Signal</a> and 
   322  <a href="/pkg/os/#UnixSignal">UnixSignal</a> types have been moved to the
   323  <a href="/pkg/os/">os</a> package.
   324  </p>
   325  
   326  <p>
   327  <a href="/pkg/image/draw/">Package image/draw</a> is the new name for
   328  <code>exp/draw</code>. The GUI-related code from <code>exp/draw</code> is now
   329  located in the <a href="/pkg/exp/gui/">exp/gui</a> package.
   330  </p>
   331  
   332  <h3 id="r58.cmd">Tools</h3>
   333  
   334  <p>
   335  <a href="/cmd/goinstall/">Goinstall</a> now observes the GOPATH environment
   336  variable to build and install your own code and external libraries outside of
   337  the Go tree (and avoid writing Makefiles).
   338  </p>
   339  
   340  
   341  <h3 id="r58.minor">Minor revisions</h3>
   342  
   343  <p>r58.1 adds 
   344  <a href="http://code.google.com/p/go/source/detail?r=293c25943586">build</a> and
   345  <a href="http://code.google.com/p/go/source/detail?r=bf17e96b6582">runtime</a>
   346  changes to make Go run on OS X 10.7 Lion.
   347  </p>
   348  
   349  <h2 id="r57">r57 (released 2011/05/03)</h2>
   350  
   351  <p>
   352  The r57 release corresponds to 
   353  <code><a href="weekly.html#2011-04-27">weekly.2011-04-27</a></code>
   354  with additional bug fixes.
   355  This section highlights the most significant changes in this release.
   356  For a more detailed summary, see the
   357  <a href="weekly.html#2011-04-27">weekly release notes</a>.
   358  For complete information, see the
   359  <a href="http://code.google.com/p/go/source/list?r=release-branch.r57">Mercurial change list</a>.
   360  </p>
   361  
   362  <p>The new <a href="/cmd/gofix">gofix</a> tool finds Go programs that use old APIs and rewrites them to use
   363  newer ones.  After you update to a new Go release, gofix helps make the
   364  necessary changes to your programs. Gofix will handle the http, os, and syscall
   365  package changes described below, and we will update the program to keep up with
   366  future changes to the libraries. 
   367  Gofix can’t
   368  handle all situations perfectly, so read and test the changes it makes before
   369  committing them.
   370  See <a href="http://blog.golang.org/2011/04/introducing-gofix.html">the gofix blog post</a> for more
   371  information.</p>
   372  
   373  <h3 id="r57.lang">Language</h3>
   374  
   375  <p>
   376  <a href="/doc/go_spec.html#Receive_operator">Multiple assignment syntax</a> replaces the <code>closed</code> function.
   377  The syntax for channel
   378  receives allows an optional second assigned value, a boolean value
   379  indicating whether the channel is closed. This code:
   380  </p>
   381  
   382  <pre>
   383  	v := &lt;-ch
   384  	if closed(ch) {
   385  		// channel is closed
   386  	}
   387  </pre>
   388  
   389  <p>should now be written as:</p>
   390  
   391  <pre>
   392  	v, ok := &lt;-ch
   393  	if !ok {
   394  		// channel is closed
   395  	}
   396  </pre>
   397  
   398  <p><a href="/doc/go_spec.html#Label_scopes">Unused labels are now illegal</a>, just as unused local variables are.</p>
   399  
   400  <h3 id="r57.pkg">Packages</h3>
   401  
   402  <p>
   403  <a href="/pkg/gob/">Package gob</a> will now encode and decode values of types that implement the
   404  <a href="/pkg/gob/#GobEncoder">GobEncoder</a> and
   405  <a href="/pkg/gob/#GobDecoder">GobDecoder</a> interfaces. This allows types with unexported
   406  fields to transmit self-consistent descriptions; examples include 
   407  <a href="/pkg/big/#Int.GobDecode">big.Int</a> and <a href="/pkg/big/#Rat.GobDecode">big.Rat</a>.
   408  </p>
   409  
   410  <p>
   411  <a href="/pkg/http/">Package http</a> has been redesigned.
   412  For clients, there are new
   413  <a href="/pkg/http/#Client">Client</a> and <a href="/pkg/http/#Transport">Transport</a>
   414  abstractions that give more control over HTTP details such as headers sent
   415  and redirections followed.  These abstractions make it easy to implement
   416  custom clients that add functionality such as <a href="http://code.google.com/p/goauth2/source/browse/oauth/oauth.go">OAuth2</a>.
   417  For servers, <a href="/pkg/http/#ResponseWriter">ResponseWriter</a>
   418  has dropped its non-essential methods.
   419  The Hijack and Flush methods are no longer required;
   420  code can test for them by checking whether a specific value implements
   421  <a href="/pkg/http/#Hijacker">Hijacker</a> or <a href="/pkg/http/#Flusher">Flusher</a>.
   422  The RemoteAddr and UsingTLS methods are replaced by <a href="/pkg/http/#Request">Request</a>'s
   423  RemoteAddr and TLS fields.
   424  The SetHeader method is replaced by a Header method;
   425  its result, of type <a href="/pkg/http/#Header">Header</a>,
   426  implements Set and other methods.
   427  </p>
   428  
   429  <p>
   430  <a href="/pkg/net/">Package net</a>
   431  drops the <code>laddr</code> argument from <a href="/pkg/net/#Conn.Dial">Dial</a>
   432  and drops the <code>cname</code> return value
   433  from <a href="/pkg/net/#LookupHost">LookupHost</a>.
   434  The implementation now uses <a href="/cmd/cgo/">cgo</a> to implement
   435  network name lookups using the C library getaddrinfo(3)
   436  function when possible.  This ensures that Go and C programs
   437  resolve names the same way and also avoids the OS X 
   438  application-level firewall.
   439  </p>
   440  
   441  <p>
   442  <a href="/pkg/os/">Package os</a>
   443  introduces simplified <a href="/pkg/os/#File.Open">Open</a>
   444  and <a href="/pkg/os/#File.Create">Create</a> functions.
   445  The original Open is now available as <a href="/pkg/os/#File.OpenFile">OpenFile</a>.
   446  The final three arguments to <a href="/pkg/os/#Process.StartProcess">StartProcess</a>
   447  have been replaced by a pointer to a <a href="/pkg/os/#ProcAttr">ProcAttr</a>.
   448  </p>
   449  
   450  <p>
   451  <a href="/pkg/reflect/">Package reflect</a> has been redesigned.
   452  <a href="/pkg/reflect/#Type">Type</a> is now an interface that implements
   453  all the possible type methods.
   454  Instead of a type switch on a Type <code>t</code>, switch on <code>t.Kind()</code>.
   455  <a href="/pkg/reflect/#Value">Value</a> is now a struct value that
   456  implements all the possible value methods.
   457  Instead of a type switch on a Value <code>v</code>, switch on <code>v.Kind()</code>.
   458  Typeof and NewValue are now called <a href="/pkg/reflect/#Type.TypeOf">TypeOf</a> and <a href="/pkg/reflect/#Value.ValueOf">ValueOf</a>
   459  To create a writable Value, use <code>New(t).Elem()</code> instead of <code>Zero(t)</code>.
   460  See <a href="http://code.google.com/p/go/source/detail?r=843855f3c026">the change description</a>
   461  for the full details.
   462  The new API allows a more efficient implementation of Value
   463  that avoids many of the allocations required by the previous API.
   464  </p>
   465  
   466  <p>
   467  Remember that gofix will handle the bulk of the rewrites
   468  necessary for these changes to package APIs.
   469  </p>
   470  
   471  <h3 id="r57.cmd">Tools</h3>
   472  
   473  <p><a href="/cmd/gofix/">Gofix</a>, a new command, is described above.</p>
   474  
   475  <p>
   476  <a href="/cmd/gotest/">Gotest</a> is now a Go program instead of a shell script.
   477  The new <code>-test.short</code> flag in combination with package testing's Short function
   478  allows you to write tests that can be run in normal or &ldquo;short&rdquo; mode;
   479  all.bash runs tests in short mode to reduce installation time.
   480  The Makefiles know about the flag: use <code>make testshort</code>.
   481  </p>
   482  
   483  <p>
   484  The run-time support now implements CPU and memory profiling.
   485  Gotest's new 
   486  <a href="/cmd/gotest/"><code>-test.cpuprofile</code> and
   487  <code>-test.memprofile</code> flags</a> make it easy to
   488  profile tests.
   489  To add profiling to your web server, see the <a href="/pkg/http/pprof/">http/pprof</a>
   490  documentation.
   491  For other uses, see the <a href="/pkg/runtime/pprof/">runtime/pprof</a> documentation.
   492  </p>
   493  
   494  <h3 id="r57.minor">Minor revisions</h3>
   495  
   496  <p>r57.1 fixes a <a href="http://code.google.com/p/go/source/detail?r=ff2bc62726e7145eb2ecc1e0f076998e4a8f86f0">nil pointer dereference in http.FormFile</a>.</p>
   497  <p>r57.2 fixes a <a href="http://code.google.com/p/go/source/detail?r=063b0ff67d8277df03c956208abc068076818dae">use of uninitialized memory in programs that misuse <code>goto</code></a>.</p>
   498  
   499  <h2 id="r56">r56 (released 2011/03/16)</h2>
   500  
   501  <p>
   502  The r56 release was the first stable release and corresponds to
   503  <code><a href="weekly.html#2011-03-07">weekly.2011-03-07.1</a></code>.
   504  The numbering starts at 56 because before this release,
   505  what we now consider weekly snapshots were called releases.
   506  </p>