summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-04-26 09:55:32 +0200
committerOndřej Surý <ondrej@sury.org>2011-04-26 09:55:32 +0200
commit7b15ed9ef455b6b66c6b376898a88aef5d6a9970 (patch)
tree3ef530baa80cdf29436ba981f5783be6b4d2202b /doc
parent50104cc32a498f7517a51c8dc93106c51c7a54b4 (diff)
downloadgolang-7b15ed9ef455b6b66c6b376898a88aef5d6a9970.tar.gz
Imported Upstream version 2011.04.13upstream/2011.04.13
Diffstat (limited to 'doc')
-rw-r--r--doc/codelab/wiki/Makefile2
-rw-r--r--doc/codelab/wiki/final-noclosure.go2
-rw-r--r--doc/codelab/wiki/final-noerror.go4
-rw-r--r--doc/codelab/wiki/final-parsetemplate.go2
-rw-r--r--doc/codelab/wiki/final-template.go2
-rw-r--r--doc/codelab/wiki/index.html8
-rw-r--r--doc/codewalk/functions.xml115
-rw-r--r--doc/codewalk/pig.go124
-rw-r--r--doc/contrib.html47
-rw-r--r--doc/devel/release.html367
-rw-r--r--doc/devel/roadmap.html32
-rw-r--r--doc/effective_go.html81
-rw-r--r--doc/go_faq.html5
-rw-r--r--doc/go_spec.html69
-rw-r--r--doc/install.html27
15 files changed, 795 insertions, 92 deletions
diff --git a/doc/codelab/wiki/Makefile b/doc/codelab/wiki/Makefile
index 43f05b21d..09c3291a0 100644
--- a/doc/codelab/wiki/Makefile
+++ b/doc/codelab/wiki/Makefile
@@ -8,7 +8,7 @@ all: index.html
include ../../../src/Make.common
-CLEANFILES+=index.html srcextract.bin htmlify.bin
+CLEANFILES+=index.html srcextract.bin htmlify.bin get.bin
index.html: srcextract.bin htmlify.bin
PATH=.:$$PATH awk '/^!/{system(substr($$0,2)); next} {print}' < wiki.html | tr -d '\r' > index.html
diff --git a/doc/codelab/wiki/final-noclosure.go b/doc/codelab/wiki/final-noclosure.go
index 99121f298..d09a0d7ab 100644
--- a/doc/codelab/wiki/final-noclosure.go
+++ b/doc/codelab/wiki/final-noclosure.go
@@ -73,7 +73,7 @@ func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
http.Error(w, err.String(), http.StatusInternalServerError)
return
}
- err = t.Execute(p, w)
+ err = t.Execute(w, p)
if err != nil {
http.Error(w, err.String(), http.StatusInternalServerError)
}
diff --git a/doc/codelab/wiki/final-noerror.go b/doc/codelab/wiki/final-noerror.go
index 0f18912d2..5fcf1de76 100644
--- a/doc/codelab/wiki/final-noerror.go
+++ b/doc/codelab/wiki/final-noerror.go
@@ -35,14 +35,14 @@ func editHandler(w http.ResponseWriter, r *http.Request) {
p = &Page{Title: title}
}
t, _ := template.ParseFile("edit.html", nil)
- t.Execute(p, w)
+ t.Execute(w, p)
}
func viewHandler(w http.ResponseWriter, r *http.Request) {
title := r.URL.Path[lenPath:]
p, _ := loadPage(title)
t, _ := template.ParseFile("view.html", nil)
- t.Execute(p, w)
+ t.Execute(w, p)
}
func main() {
diff --git a/doc/codelab/wiki/final-parsetemplate.go b/doc/codelab/wiki/final-parsetemplate.go
index ea8977601..f25012eed 100644
--- a/doc/codelab/wiki/final-parsetemplate.go
+++ b/doc/codelab/wiki/final-parsetemplate.go
@@ -61,7 +61,7 @@ func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
http.Error(w, err.String(), http.StatusInternalServerError)
return
}
- err = t.Execute(p, w)
+ err = t.Execute(w, p)
if err != nil {
http.Error(w, err.String(), http.StatusInternalServerError)
}
diff --git a/doc/codelab/wiki/final-template.go b/doc/codelab/wiki/final-template.go
index 4d6a2cfab..aab536ee1 100644
--- a/doc/codelab/wiki/final-template.go
+++ b/doc/codelab/wiki/final-template.go
@@ -53,7 +53,7 @@ func saveHandler(w http.ResponseWriter, r *http.Request) {
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
t, _ := template.ParseFile(tmpl+".html", nil)
- t.Execute(p, w)
+ t.Execute(w, p)
}
func main() {
diff --git a/doc/codelab/wiki/index.html b/doc/codelab/wiki/index.html
index fc8c27bfa..d059fa027 100644
--- a/doc/codelab/wiki/index.html
+++ b/doc/codelab/wiki/index.html
@@ -475,7 +475,7 @@ func editHandler(w http.ResponseWriter, r *http.Request) {
p = &amp;Page{Title: title}
}
t, _ := template.ParseFile(&#34;edit.html&#34;, nil)
- t.Execute(p, w)
+ t.Execute(w, p)
}
</pre>
@@ -527,7 +527,7 @@ func viewHandler(w http.ResponseWriter, r *http.Request) {
title := r.URL.Path[lenPath:]
p, _ := loadPage(title)
t, _ := template.ParseFile(&#34;view.html&#34;, nil)
- t.Execute(p, w)
+ t.Execute(w, p)
}
</pre>
@@ -555,7 +555,7 @@ func editHandler(w http.ResponseWriter, r *http.Request) {
func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
t, _ := template.ParseFile(tmpl+&#34;.html&#34;, nil)
- t.Execute(p, w)
+ t.Execute(w, p)
}
</pre>
@@ -644,7 +644,7 @@ func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {
http.Error(w, err.String(), http.StatusInternalServerError)
return
}
- err = t.Execute(p, w)
+ err = t.Execute(w, p)
if err != nil {
http.Error(w, err.String(), http.StatusInternalServerError)
}
diff --git a/doc/codewalk/functions.xml b/doc/codewalk/functions.xml
new file mode 100644
index 000000000..986a017e1
--- /dev/null
+++ b/doc/codewalk/functions.xml
@@ -0,0 +1,115 @@
+<codewalk title="First-Class Functions in Go">
+
+<step title="Introduction" src="doc/codewalk/pig.go">
+ Go supports first class functions, higher-order functions, user-defined
+ function types, function literals, closures, and multiple return values.
+ <br/><br/>
+
+ This rich feature set supports a functional programming style in a strongly
+ typed language.
+ <br/><br/>
+
+ In this codewalk we will look at a simple program that simulates a dice game
+ called <a href="http://en.wikipedia.org/wiki/Pig_(dice)">Pig</a> and evaluates
+ basic strategies.
+</step>
+
+<step title="Game overview" src="doc/codewalk/pig.go:/\/\/ A score/,/thisTurn int\n}/">
+ Pig is a two-player game played with a 6-sided die. Each turn, you may roll or stay.
+ <ul>
+ <li> If you roll a 1, you lose all points for your turn and play passes to
+ your opponent. Any other roll adds its value to your turn score. </li>
+ <li> If you stay, your turn score is added to your total score, and play passes
+ to your opponent. </li>
+ </ul>
+
+ The first person to reach 100 total points wins.
+ <br/><br/>
+
+ The <code>score</code> type stores the scores of the current and opposing
+ players, in addition to the points accumulated during the current turn.
+</step>
+
+<step title="User-defined function types" src="doc/codewalk/pig.go:/\/\/ An action/,/bool\)/">
+ In Go, functions can be passed around just like any other value. A function's
+ type signature describes the types of its arguments and return values.
+ <br/><br/>
+
+ The <code>action</code> type is a function that takes a <code>score</code>
+ and returns the resulting <code>score</code> and whether the current turn is
+ over.
+ <br/><br/>
+
+ If the turn is over, the <code>player</code> and <code>opponent</code> fields
+ in the resulting <code>score</code> should be swapped, as it is now the other player's
+ turn.
+</step>
+
+<step title="Multiple return values" src="doc/codewalk/pig.go:/\/\/ roll returns/,/stay.*true\n}/">
+ Go functions can return multiple values.
+ <br/><br/>
+
+ The functions <code>roll</code> and <code>stay</code> each return a pair of
+ values. They also match the <code>action</code> type signature. These
+ <code>action</code> functions define the rules of Pig.
+</step>
+
+<step title="Higher-order functions" src="doc/codewalk/pig.go:/\/\/ A strategy/,/action\n/">
+ A function can use other functions as arguments and return values.
+ <br/><br/>
+
+ A <code>strategy</code> is a function that takes a <code>score</code> as input
+ and returns an <code>action</code> to perform. <br/>
+ (Remember, an <code>action</code> is itself a function.)
+</step>
+
+<step title="Function literals and closures" src="doc/codewalk/pig.go:/return func/,/return roll\n\t}/">
+ Anonymous functions can be declared in Go, as in this example. Function
+ literals are closures: they inherit the scope of the function in which they
+ are declared.
+ <br/><br/>
+
+ One basic strategy in Pig is to continue rolling until you have accumulated at
+ least k points in a turn, and then stay. The argument <code>k</code> is
+ enclosed by this function literal, which matches the <code>strategy</code> type
+ signature.
+</step>
+
+<step title="Simulating games" src="doc/codewalk/pig.go:/\/\/ play/,/currentPlayer\n}/">
+ We simulate a game of Pig by calling an <code>action</code> to update the
+ <code>score</code> until one player reaches 100 points. Each
+ <code>action</code> is selected by calling the <code>strategy</code> function
+ associated with the current player.
+</step>
+
+<step title="Comparing functions" src="doc/codewalk/pig.go:/if action/,/currentPlayer\)\)\n\t\t}/">
+ Functions can be compared for equality in Go. From the
+ <a href="http://golang.org/doc/go_spec.html#Comparison_operators">language specification</a>:
+ Function values are equal if they refer to the same function or if both are <code>nil</code>.
+ <br/><br/>
+
+ We enforce that a <code>strategy</code> function can only return a legal
+ <code>action</code>: either <code>roll</code> or <code>stay</code>.
+</step>
+
+<step title="Simulating a tournament" src="doc/codewalk/pig.go:/\/\/ roundRobin/,/gamesPerStrategy\n}/">
+ The <code>roundRobin</code> function simulates a tournament and tallies wins.
+ Each strategy plays each other strategy <code>gamesPerSeries</code> times.
+</step>
+
+<step title="Variadic function declarations" src="doc/codewalk/pig.go:/\/\/ ratioS/,/string {/">
+ Variadic functions like <code>ratioString</code> take a variable number of
+ arguments. These arguments are available as a slice inside the function.
+</step>
+
+<step title="Simulation results" src="doc/codewalk/pig.go:/func main/,/\n}/">
+ The <code>main</code> function defines 100 basic strategies, simulates a round
+ robin tournament, and then prints the win/loss record of each strategy.
+ <br/><br/>
+
+ Among these strategies, staying at 25 is best, but the <a
+ href="http://www.google.com/search?q=optimal+play+pig">optimal strategy for
+ Pig</a> is much more complex.
+</step>
+
+</codewalk>
diff --git a/doc/codewalk/pig.go b/doc/codewalk/pig.go
new file mode 100644
index 000000000..9e415f589
--- /dev/null
+++ b/doc/codewalk/pig.go
@@ -0,0 +1,124 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ "fmt"
+ "rand"
+)
+
+const (
+ win = 100 // The winning score in a game of Pig
+ gamesPerSeries = 10 // The number of games per series to simulate
+)
+
+// A score includes scores accumulated in previous turns for each player,
+// as well as the points scored by the current player in this turn.
+type score struct {
+ player, opponent, thisTurn int
+}
+
+// An action transitions stochastically to a resulting score.
+type action func(current score) (result score, turnIsOver bool)
+
+// roll returns the (result, turnIsOver) outcome of simulating a die roll.
+// If the roll value is 1, then thisTurn score is abandoned, and the players'
+// roles swap. Otherwise, the roll value is added to thisTurn.
+func roll(s score) (score, bool) {
+ outcome := rand.Intn(6) + 1 // A random int in [1, 6]
+ if outcome == 1 {
+ return score{s.opponent, s.player, 0}, true
+ }
+ return score{s.player, s.opponent, outcome + s.thisTurn}, false
+}
+
+// stay returns the (result, turnIsOver) outcome of staying.
+// thisTurn score is added to the player's score, and the players' roles swap.
+func stay(s score) (score, bool) {
+ return score{s.opponent, s.player + s.thisTurn, 0}, true
+}
+
+// A strategy chooses an action for any given score.
+type strategy func(score) action
+
+// stayAtK returns a strategy that rolls until thisTurn is at least k, then stays.
+func stayAtK(k int) strategy {
+ return func(s score) action {
+ if s.thisTurn >= k {
+ return stay
+ }
+ return roll
+ }
+}
+
+// play simulates a Pig game and returns the winner (0 or 1).
+func play(strategy0, strategy1 strategy) int {
+ strategies := []strategy{strategy0, strategy1}
+ var s score
+ var turnIsOver bool
+ currentPlayer := rand.Intn(2) // Randomly decide who plays first
+ for s.player+s.thisTurn < win {
+ action := strategies[currentPlayer](s)
+ if action != roll && action != stay {
+ panic(fmt.Sprintf("Player %d is cheating", currentPlayer))
+ }
+ s, turnIsOver = action(s)
+ if turnIsOver {
+ currentPlayer = (currentPlayer + 1) % 2
+ }
+ }
+ return currentPlayer
+}
+
+// roundRobin simulates a series of games between every pair of strategies.
+func roundRobin(strategies []strategy) ([]int, int) {
+ wins := make([]int, len(strategies))
+ for i := 0; i < len(strategies); i++ {
+ for j := i + 1; j < len(strategies); j++ {
+ for k := 0; k < gamesPerSeries; k++ {
+ winner := play(strategies[i], strategies[j])
+ if winner == 0 {
+ wins[i]++
+ } else {
+ wins[j]++
+ }
+ }
+ }
+ }
+ gamesPerStrategy := gamesPerSeries * (len(strategies) - 1) // no self play
+ return wins, gamesPerStrategy
+}
+
+// ratioString takes a list of integer values and returns a string that lists
+// each value and its percentage of the sum of all values.
+// e.g., ratios(1, 2, 3) = "1/6 (16.7%), 2/6 (33.3%), 3/6 (50.0%)"
+func ratioString(vals ...int) string {
+ total := 0
+ for _, val := range vals {
+ total += val
+ }
+ s := ""
+ for _, val := range vals {
+ if s != "" {
+ s += ", "
+ }
+ pct := 100 * float64(val) / float64(total)
+ s += fmt.Sprintf("%d/%d (%0.1f%%)", val, total, pct)
+ }
+ return s
+}
+
+func main() {
+ strategies := make([]strategy, win)
+ for k := range strategies {
+ strategies[k] = stayAtK(k + 1)
+ }
+ wins, games := roundRobin(strategies)
+
+ for k := range strategies {
+ fmt.Printf("Wins, losses staying at k =% 4d: %s\n",
+ k+1, ratioString(wins[k], games-wins[k]))
+ }
+}
diff --git a/doc/contrib.html b/doc/contrib.html
index 121cc45dc..9d0c42726 100644
--- a/doc/contrib.html
+++ b/doc/contrib.html
@@ -2,21 +2,38 @@
<div class="left-column">
-<h2 id="developer_info">Resources for Developers</h2>
+<h2 id="howto">How you can help</h2>
-<h3 id="issuetracker"><a href="http://code.google.com/p/go/issues">Issue Tracker</a></h3>
-<p>Having an issue with Go? Check the tracker to see if it's a known issue.</p>
-<p>If your issue is not listed, please file a <a
-href="http://code.google.com/p/go/issues/entry">bug report</a>.</p>
+<h3>Reporting issues</h3>
-<h3 id="build_status"><a href="http://godashboard.appspot.com/">Build Status</a></h3>
-<p>View the status of Go builds across the supported operating
-systems and architectures.</p>
+<p>
+If you spot bugs, mistakes, or inconsistencies in the Go project's code or
+documentation, please let us know by
+<a href="http://code.google.com/p/go/issues/entry">filing a ticket</a>
+on our <a href="http://code.google.com/p/go/issues">issue tracker</a>.
+(Of course, you should check it's not an existing issue before creating
+a new one.)
+</p>
+
+<p>
+We pride ourselves on being meticulous; no issue is too small.
+</p>
+
+<h3>Contributing code</h3>
-<h3 id="contibute"><a href="contribute.html">Contribution Guidelines</a></h3>
-<p>So, you want to contribute code to the Go project? That's great!</p>
-<p>The first step is to read these contributions guidelines for information on
-design, testing, and our code review process.</p>
+<p>
+Go is an open source project and we welcome contributions from the community.
+</p>
+<p>
+To get started, read these <a href="contribute.html">contribution
+guidelines</a> for information on design, testing, and our code review process.
+</p>
+<p>
+Check <a href="http://code.google.com/p/go/issues">the tracker</a> for
+open issues that interest you. Those labeled
+<a href="http://code.google.com/p/go/issues/list?q=status=HelpWanted">HelpWanted</a>
+are particularly in need of outside help.
+</p>
</div>
@@ -24,11 +41,15 @@ design, testing, and our code review process.</p>
<h2 id="">The Go Project</h2>
+<h3 id="build_status"><a href="http://godashboard.appspot.com/">Build Status</a></h3>
+<p>View the status of Go builds across the supported operating
+systems and architectures.</p>
+
<h3 id="roadmap"><a href="devel/roadmap.html">Roadmap</a></h3>
<p>Features and ideas being developed or discussed by the Go team.</p>
<h3 id="release"><a href="devel/release.html">Release History</a></h3>
-<p>A summarization of the changes between tagged releases of Go.</p>
+<p>A summary of the changes between tagged releases of Go.</p>
<h3 id="golang-dev"><a href="http://groups.google.com/group/golang-dev">Developer Mailing List</a></h3>
<p>The <a href="http://groups.google.com/group/golang-dev">golang-dev</a>
diff --git a/doc/devel/release.html b/doc/devel/release.html
index c7691c766..f75cbf24f 100644
--- a/doc/devel/release.html
+++ b/doc/devel/release.html
@@ -5,7 +5,368 @@
<p>This page summarizes the changes between tagged releases of Go.
For full details, see the <a href="http://code.google.com/p/go/source/list">Mercurial change log</a>.</p>
-<h3 id="2011-03-07">2011-03-07</h3>
+<h3 id="2011-04-13">2011-04-13</h3>
+
+<pre>
+weekly.2011-04-13
+
+This weekly snapshot includes major changes to the reflect package and the
+os.Open function. Code that uses reflect or os.Open will require updating,
+which can be done mechanically using the gofix tool.
+
+The reflect package's Type and Value types have changed. Type is now an
+interface that implements all the possible type methods. Instead of a type
+switch on a reflect.Type t, switch on t.Kind(). Value is now a struct value
+that implements all the possible value methods. Instead of a type switch on a
+reflect.Value v, switch on v.Kind(). See the change for the full details:
+ http://code.google.com/p/go/source/detail?r=843855f3c026
+
+The os package's Open function has been replaced by three functions:
+ OpenFile(name, flag, perm) // same as old Open
+ Open(name) // same as old Open(name, O_RDONLY, 0)
+ Create(name) // same as old Open(name, O_RDWR|O_TRUNC|O_CREAT, 0666)
+
+To update your code to use the new APIs, run "gofix path/to/code". Gofix can’t
+handle all situations perfectly, so read and test the changes it makes before
+committing them.
+
+Other changes:
+* archive/zip: add func OpenReader, type ReadCloser (thanks Dmitry Chestnykh).
+* asn1: Implement correct marshaling of length octets (thanks Luit van Drongelen).
+* big: don't crash when printing nil ints.
+* bufio: add ReadLine, to replace encoding/line.
+* build: make the build faster, quieter.
+* codereview: automatically port old diffs forward,
+ drop Author: line on self-clpatch,
+ recognize code URL without trailing slash.
+* crypto/block: remove deprecated package.
+* crypto/des: new package implementating DES and TDEA (thanks Yasuhiro Matsumoto).
+* crypto/ecdsa, crypto/rsa: use io.ReadFull to read from random source (thanks Dmitry Chestnykh).
+* crypto/rsa: add 3-prime support,
+ add support for precomputing CRT values,
+ flip the CRT code over so that it matches PKCS#1.
+* crypto/x509: expose complete DER data (thanks Mikkel Krautz).
+* doc: new "Functions" codewalk (thanks John DeNero).
+* doc/roadmap: add sections on tools, packages.
+* fmt: allow %U for unsigned integers.
+* gc: fixes and optimizations.
+* go/printer, gofmt: use blank to separate import rename from import path.
+* go/scanner: better TokenString output.
+* go/types: new Go type hierarchy implementation for AST.
+* godashboard: show packages at launchpad.net (thanks Gustavo Niemeyer).
+* gofix: add -diff, various fixes and helpers.
+* gotest: fix a bug in error handling,
+ fixes for [^.]_test file pattern (thanks Peter Mundy),
+ handle \r\n returned by gomake on Windows (thanks Alex Brainman).
+* gotype: use go/types GcImporter.
+* govet: make name-matching for printf etc. case-insensitive.
+* http: allow override of Content-Type for ServeFile,
+ client gzip support,
+ do not listen on 0.0.0.0 during test,
+ flesh out server Expect handling + tests.
+* image/ycbcr: new package.
+* image: allow "?" wildcards when registering image formats.
+* io: fixes for Read with n > 0, os.EOF (thanks Robert Hencke).
+* ld: correct Plan 9 compiler warnings (thanks Lucio De Re),
+ ELF header function declarations (thanks Lucio De Re),
+ fix Mach-O X86_64_RELOC_SIGNED relocations (thanks Mikkel Krautz),
+ fix Mach-O bss bug (thanks Mikkel Krautz),
+ fix dwarf decoding of strings for struct's fieldnames (thanks Luuk van Dijk),
+ fixes and optimizations (25% faster).
+* log: generalize getting and setting flags and prefix.
+* misc/cgo/life: enable build and test on Windows (thanks Alex Brainman).
+* misc/vim: add plugin with Fmt command (thanks Dmitry Chestnykh),
+ update type highlighting for new reflect package.
+* net: disable multicast tests by default (thanks Dave Cheney),
+ sort records returned by LookupMX (thanks Corey Thomasson).
+* openpgp: Fix improper := shadowing (thanks Gustavo Niemeyer).
+* os: rename Open to OpenFile, add new Open, Create,
+ fix Readdir in Plan 9 (thanks Fazlul Shahriar).
+* os/inotify: use _test for test files, not _obj.
+* pkg/path: enable tests on Windows (thanks Alex Brainman).
+* reflect: new Type and Value API.
+* src/pkg/Makefile: trim per-directory make output except on failure.
+* syscall: Add DT_* and MADV_* constants on Linux (thanks Albert Strasheim),
+ add Mmap, Munmap on Linux, FreeBSD, OS X,
+ fix StartProcess in Plan 9 (thanks Fazlul Shahriar),
+ fix Windows Signaled (thanks Alex Brainman).
+* test/bench: enable build and test on Windows (thanks Alex Brainman).
+</pre>
+
+<h3 id="2011-04-04">2011-04-04</h3>
+
+<pre>
+This release includes changes to the net package. Your code will require
+changes if it uses the Dial or LookupHost functions.
+
+The laddr argument has been removed from net.Dial, and the cname return value
+has been removed from net.LookupHost. The new net.LookupCNAME function can be
+used to find the canonical host for a given name. You can update your
+networking code with gofix.
+
+The gotest shell script has been replaced by a Go program, making testing
+significantly faster.
+
+Other changes:
+* asn1: extensions needed for parsing Kerberos.
+* bufio: Write and WriteString cleanup (thanks Evan Shaw).
+* bytes, strings: simplify Join (thanks Evan Shaw).
+* crypto/cipher: bad CTR IV length now triggers panic.
+* crypto/tls: extend NPN support to the client,
+ added X509KeyPair function to parse a Certificate from memory.
+* crypto/x509: parse Extended Key Usage extension (thanks Mikkel Krautz).
+* debug/gosym: remove need for gotest to run preparatory commands.
+* fmt: implement precision (length of input) values for %q: %.20q.
+* go/parser: fix scoping for local type declarations (thanks Roger Peppe),
+ package name must not be the blank identifier.
+* go/printer, gofmt: remove special case for multi-line raw strings.
+* gopack: add P flag to remove prefix from filename information.
+* gotest: add -test.timeout option,
+ replace the shell script with the compiled program written in go,
+ execute gomake properly on Windows (thanks Alex Brainman).
+* gotry: move into its own directory, separate from gotest.
+* gotype: support for more tests, added one new test.
+* http: add Transport.MaxIdleConnsPerHost,
+ use upper case hex in URL escaping (thanks Matt Jones).
+* httptest: add NewTLSServer.
+* misc/kate: reorganize, remove closed() (thanks Evan Shaw).
+* misc/notepadplus: support for notepad++ (thanks Anthony Starks).
+* net: implement non-blocking connect (thanks Alexey Borzenkov).
+* os: fix MkdirAll("/thisdoesnotexist") (thanks Albert Strasheim),
+ Plan 9 support (thanks Yuval Pavel Zholkover),
+ add a few missing Plan 9 errors (thanks Andrey Mirtchovski),
+ fix FileInfo.Name returned by Stat (thanks David Forsythe).
+* path/filepath.Glob: add an error return,
+ don't drop known matches on error.
+* path/filepath: add support for Plan 9 (thanks Andrey Mirtchovski).
+* scanner: treat line comments like in Go.
+* syscall: Plan 9 support (thanks Yuval Pavel Zholkover),
+ StartProcess Chroot and Credential (thanks Albert Strasheim),
+ add BPF support for freebsd/386, freebsd/amd64 (thanks Mikio Hara),
+ make [Raw]Syscall6 pass 6th arg on linux/386 (thanks Evan Shaw).
+</pre>
+
+<h3 id="2011-03-28">2011-03-28</h3>
+
+<pre>
+This weekly release includes improved support for testing.
+
+Memory and CPU profiling is now available via the gotest tool. Gotest will
+produce memory and CPU profiling data when invoked with the -test.memprofile
+and -test.cpuprofile flags. Run "godoc gotest" for details.
+
+We have also introduced a way for tests to run quickly when an exhaustive test
+is unnecessary. Gotest’s new -test.short flag in combination with the testing
+package’s new Short function allows you to write tests that can be run in
+normal or "short" mode; short mode is now used by all.bash to reduce
+installation time.
+The Makefiles know about the flag - you can just run "make testshort".
+
+Other changes:
+* .hgignore: Ignore all goinstalled packages (thanks Evan Shaw).
+* build: add all-qemu.bash, handful of arm fixes,
+ add support for SWIG, and add two SWIG examples,
+ diagnose Ubuntu's buggy copy of gold,
+ handle broken awk in version.bash (thanks Dave Cheney),
+ reenable clean.bash without gomake (thanks Gustavo Niemeyer).
+* cgo: fix index-out-of-bounds bug.
+* codereview: permit CLs of the form weekly.DATE
+* crypto/ecdsa: truncate hash values.
+* crypto/openpgp: add DSA signature support.
+* dashboard: remove old python/bash builder, update README.
+* doc: explain release and weekly tags in install.html.
+* exec: document dir option for Run (thanks Gustavo Niemeyer).
+* flag: document Nflag function (thanks Fazlul Shahriar).
+* gc: remove interim ... error which rejects valid code.
+* go/ast: implemented NewPackage,
+ merge CaseClause and TypeCaseClause.
+* go/parser: fix memory leak by making a copy of token literals,
+ resolve identifiers properly.
+* go/printer, gofmt: avoid exponential layout algorithm,
+ gofmt: simplify struct formatting and respect line breaks.
+* go/scanner: to interpret line comments with Windows filenames (thanks Alex Brainman).
+* go/token: use array instead of map for token->string table.
+* gob: optimizations to reduce allocations,
+ use pointers in bootstrapType so interfaces behave properly.
+* gobuilder: recognize CLs of the form weekly.DATE.
+* godefs: handle volatile.
+* godoc: add -template flag to specify custom templates,
+ fix path problem for windows (thanks Yasuhiro Matsumoto).
+* gofix: httpserver - rewrite rw.SetHeader to rw.Header.Set.
+* gofmt: add profiling flag.
+* gopprof: fix bug: do not rotate 180 degrees for large scrolls,
+ update list of memory allocation functions.
+* gotest: fix gofmt issue in generated _testmain.go.
+* http: add NewProxyClientConn,
+ avoid crash when asked for multiple file ranges,
+ don't chunk 304 responses,
+ export Transport, add keep-alive support.
+* ld: return > 0 exit code on unsafe import.
+* misc/bbedit: remove closed keyword (thanks Anthony Starks).
+* misc/emacs: gofmt: don't clobber the current buffer on failure.
+* misc/vim: remove 'closed' as a builtin function.
+* net: add FileConn, FilePacketConn, FileListener (thanks Albert Strasheim),
+ don't force epoll/kqueue to wake up in order to add new events,
+ let OS-specific AddFD routine wake up polling thread,
+ use preallocated buffer for epoll and kqueue/kevent.
+* path/filepath: add EvalSymlinks function,
+ fix TestEvalSymlinks when run under symlinked GOROOT.
+* path: work for windows (thanks Yasuhiro Matsumoto).
+* rpc: increase server_test timeout (thanks Gustavo Niemeyer),
+ optimizations to reduce allocations.
+* runtime: fix darwin/amd64 thread VM footprint (thanks Alexey Borzenkov),
+ fix gdb support for goroutines,
+ more stack split fixes,
+ os-specific types and code for setitimer,
+ update defs.h for freebsd-386 (thanks Devon H. O'Dell).
+* strings: Map: avoid allocation when string is unchanged.
+* syscall: GetsockoptInt (thanks Albert Strasheim),
+ StartProcess fixes for windows (thanks Alex Brainman),
+ permit non-blocking syscalls,
+ rename from .sh to .pl, because these files are in Perl.
+* test: enable tests using v, ok := <-ch syntax (thanks Robert Hencke).
+* time: give a helpful message when we can't set the time zone for testing.
+ isolate syscall reference in sys.go.
+</pre>
+
+<h3 id="2011-03-15">2011-03-15</h3>
+
+<pre>
+This week's release introduces a new release tagging scheme. We intend to
+continue with our weekly releases, but have renamed the existing tags from
+"release" to "weekly". The "release" tag will now be applied to one hand-picked
+stable release each month or two.
+
+The revision formerly tagged "release.2011-03-07.1" (now "weekly.2011-03-07.1")
+has been nominated our first stable release, and has been given the tag
+"release.r56". As we tag each stable release we will post an announcement to
+the new golang-announce mailing list:
+ http://groups.google.com/group/golang-announce
+
+You can continue to keep your Go installation updated using "hg update
+release", but now you should only need to update once we tag a new stable
+release, which we will announce here. If you wish to stay at the leading edge,
+you should switch to the weekly tag with "hg update weekly".
+
+
+This weekly release includes significant changes to the language spec and the
+http, os, and syscall packages. Your code may need to be changed. It also
+introduces the new gofix tool.
+
+The closed function has been removed from the language. The syntax for channel
+receives has been changed to return an optional second value, a boolean value
+indicating whether the channel is closed. This code:
+ v := <-ch
+ if closed(ch) {
+ // channel is closed
+ }
+should now be written as:
+ v, ok := <-ch
+ if !ok {
+ // channel is closed
+ }
+
+It is now illegal to declare unused labels, just as it is illegal to declare
+unused local variables.
+
+The new gofix tool finds Go programs that use old APIs and rewrites them to use
+newer ones. After you update to a new Go release, gofix helps make the
+necessary changes to your programs. Gofix will handle the http, os, and syscall
+package changes described below, and we will update the program to keep up with
+future changes to the libraries.
+
+The Hijack and Flush methods have been removed from the http.ResponseWriter
+interface and are accessible via the new http.Hijacker and http.Flusher
+interfaces. The RemoteAddr and UsingTLS methods have been moved from
+http.ResponseWriter to http.Request.
+
+The http.ResponseWriter interface's SetHeader method has been replaced by a
+Header() method that returns the response's http.Header. Caller code needs to
+change. This code:
+ rw.SetHeader("Content-Type", "text/plain")
+should now be written as:
+ rw.Header().Set("Content-Type", "text/plain")
+The os and syscall packages' StartProcess functions now take their final three
+arguments as an *os.ProcAttr and *syscall.ProcAttr values, respectively. This
+code:
+ os.StartProcess(bin, args, env, dir, fds)
+should now be written as:
+ os.StartProcess(bin, args, &os.ProcAttr{Files: fds, Dir: dir, Env: env})
+
+The gob package will now encode and decode values of types that implement the
+gob.GobEncoder and gob.GobDecoder interfaces. This allows types with unexported
+fields to transmit self-consistent descriptions; one instance is big.Int and
+big.Rat.
+
+Other changes:
+* 5l, 6l, 8l: reduce binary size about 40% by omitting symbols for type, string, go.string.
+* 5l, 8l: output missing section symbols (thanks Anthony Martin).
+* 6l, 8l: fix gdb crash.
+* Make.cmd: also clean _test* (thanks Gustavo Niemeyer).
+* big: implemented custom Gob(En/De)coder for Int type.
+* build: remove duplicate dependency in Make.cmd (thanks Robert Hencke),
+ run gotest in misc/cgo/test.
+* codereview.py: don't suggest change -d if user is not CL author (thanks Robert Hencke).
+* compress/lzw: benchmark a range of input sizes.
+* crypto/ecdsa: add package.
+* crypto/elliptic: add the N value of each curve.
+* crypto/openpgp: bug fixes and fix misnamed function.
+* crypto/tls: fix compile error (thanks Dave Cheney).
+* doc: Effective Go: some small cleanups,
+ update FAQ. hello, world is now 1.1MB, down from 1.8MB,
+ update codelab wiki to fix template.Execute argument order.
+* flag: visit the flags in sorted order, for nicer messages.
+* fmt: do not export EOF = -1.
+* fmt: make ScanState.Token more general (thanks Roger Peppe).
+* gc: diagnose unused labels,
+ fix handling of return values named _,
+ include all dependencies in export metadata,
+ make unsafe.Pointer its own kind of type, instead of an equivalent to *any.
+* go/ast, go/parser: populate identifier scopes at parse time.
+* go/ast: add FileSet parameter to ast.Print and ast.Fprint.
+* go/parser: first constant in a constant declaration must have a value.
+* gob: efficiency and reliability fixes.
+* gofmt: remove -trace and -ast flags.
+* goinstall: handle $(GOOS) and $(GOARCH) in filenames,
+ handle .c files with gc when cgo isn't used, and
+ handle .s files with gc (thanks Gustavo Niemeyer).
+* gopack: omit time stamps, makes output deterministic.
+* gotype: commandline tool to typecheck go programs.
+* govet: handle '*' in print format strings.
+* hash: new FNV-1a implementation (thanks Pascal S. de Kloe).
+* http/cgi: child support (e.g. Go CGI under Apache).
+* http: adapt Cookie code to follow IETF draft (thanks Petar Maymounkov),
+ add test for fixed HTTP/1.0 keep-alive issue,
+ don't hit external network in client_test.go,
+ fix transport crash when request URL is nil,
+ rename interface Transport to RoundTripper,
+ run tests even with DISABLE_NET_TESTS=1.
+* httptest: default the Recorder status code to 200 on a Write.
+* io/ioutil: clean-up of ReadAll and ReadFile.
+* ioutil: add NopCloser.
+* ld: preserve symbol sizes during data layout.
+* lib9, libmach: Change GOOS references to GOHOSTOS (thanks Evan Shaw).
+* libmach: correct string comparison to revive 6cov on darwin (thanks Dave Cheney).
+* misc/vim: Add indent script for Vim (thanks Ross Light).
+* net, os, syslog: fixes for Solaris support.
+* net: don't loop to drain wakeup pipe.
+* nm: document -S flag.
+* openpgp: add PublicKey KeyId string accessors.
+* rpc: optimizations, add benchmarks and memory profiling,
+ use httptest.Server for tests (thanks Robert Hencke).
+* runtime: reduce lock contention via wakeup on scheduler unlock,
+ scheduler, cgo reorganization,
+ split non-debugging malloc interface out of debug.go into mem.go.
+* spec: clarify return statement rules.
+* strings: add IndexRune tests, ASCII fast path,
+ better benchmark names; add BenchmarkIndex.
+* syscall: implement Mount and Unmount for linux,
+ implement Reboot for linux.
+* time: fix Time.ZoneOffset documentation (thanks Peter Mundy).
+* tls: move PeerCertificates to ConnectionState.
+</pre>
+
+<h3 id="2011-03-07">2011-03-07 (r56)</h3>
<pre>
This release includes changes to the reflect and path packages.
@@ -135,7 +496,7 @@ Other changes:
* netchan: allow use of arbitrary connections (thanks Roger Peppe).
* os: add ENODATA and ENOTCONN (thanks Albert Strasheim).
* reflect: add a couple of sentences explaining how Methods operate,
- add a secret method to ArrayOrSliceType to ensure it’s only implemented by arrays and slices,
+ add a secret method to ArrayOrSliceType to ensure it's only implemented by arrays and slices,
add pointer word to CommonType (placeholder for future work).
* runtime-gdb.py: gdb pretty printer for go strings properly handles length.
* runtime: various bug fixes, more complete stack traces,
@@ -186,7 +547,7 @@ Other changes:
fix spaces in GOROOT (thanks Christopher Nielsen).
* bytes: fix bug in buffer.ReadBytes (thanks Evan Shaw).
* 5g: better int64 code,
- don’t use MVN instruction.
+ don't use MVN instruction.
* cgo: don't run cgo when not compiling (thanks Gustavo Niemeyer),
fix _cgo_run timestamp file order (thanks Gustavo Niemeyer),
fix handling of signed enumerations (thanks Gustavo Niemeyer),
diff --git a/doc/devel/roadmap.html b/doc/devel/roadmap.html
index 97d8a08b8..a73ec6353 100644
--- a/doc/devel/roadmap.html
+++ b/doc/devel/roadmap.html
@@ -30,6 +30,8 @@ Generics. An active topic of discussion.
<li>
Methods for operators, to allow a type to use arithmetic notation for
expressions.
+<li>
+Possibly allow top-level packages to be given names other than main.
</ul>
<h3 id="Implementation_roadmap">
@@ -37,8 +39,7 @@ Implementation roadmap</h3>
<ul>
<li>
-Improved garbage collector, most likely a reference counting collector
-with a cycle detector running in a separate core.
+Improved garbage collector.
<li>
Debugger.
<li>
@@ -48,7 +49,7 @@ Improved CGO including some mechanism for calling back from C to Go.
<li>
Improved implementation documentation.
<li>
-Comprehensive support for internationalization.
+Faster, allocation-light reflection.
</ul>
<h4 id="Gc_roadmap">
@@ -77,6 +78,31 @@ Separate gcc interface from frontend proper.
Use escape analysis to keep more data on stack.
</ul>
+<h4 id="Tools_roadmap">
+Tools roadmap</h4>
+
+<ul>
+<li>
+Strengthen goinstall until it can displace make for most builds.
+</ul>
+
+<h4 id="Packages_roadmap">
+Packages roadmap</h4>
+
+<ul>
+<li>
+Faster, allocation-light reflection.
+<li>
+Faster, RE2-like regular expressions.
+<li>
+Comprehensive support for international text.
+<li>
+Support for international dates, times, etc.
+<li>
+Support for multilingual messages.
+</ul>
+
+
<h3 id="done">Done</h3>
<ul>
diff --git a/doc/effective_go.html b/doc/effective_go.html
index a32179298..27bfd1bf5 100644
--- a/doc/effective_go.html
+++ b/doc/effective_go.html
@@ -59,13 +59,14 @@ prescriptive style guide.
With Go we take an unusual
approach and let the machine
take care of most formatting issues.
-A program, <code>gofmt</code>, reads a Go program
+The <code>gofmt</code> tool reads a Go program
and emits the source in a standard style of indentation
and vertical alignment, retaining and if necessary
reformatting comments.
If you want to know how to handle some new layout
situation, run <code>gofmt</code>; if the answer doesn't
-seem right, fix the program (or file a bug), don't work around it.
+seem right, rearrange your program (or file a bug about <code>gofmt</code>),
+don't work around it.
</p>
<p>
@@ -94,7 +95,7 @@ type T struct {
</pre>
<p>
-All code in the libraries has been formatted with <code>gofmt</code>.
+All Go code in the standard packages has been formatted with <code>gofmt</code>.
</p>
@@ -304,7 +305,8 @@ not <code>container_vector</code> and not <code>containerVector</code>.
<p>
The importer of a package will use the name to refer to its contents
(the <code>import .</code> notation is intended mostly for tests and other
-unusual situations), so exported names in the package can use that fact
+unusual situations and should be avoided unless necessary),
+so exported names in the package can use that fact
to avoid stutter.
For instance, the buffered reader type in the <code>bufio</code> package is called <code>Reader</code>,
not <code>BufReader</code>, because users see it as <code>bufio.Reader</code>,
@@ -316,8 +318,8 @@ Similarly, the function to make new instances of <code>ring.Ring</code>&mdash;wh
is the definition of a <em>constructor</em> in Go&mdash;would
normally be called <code>NewRing</code>, but since
<code>Ring</code> is the only type exported by the package, and since the
-package is called <code>ring</code>, it's called just <code>New</code>.
-Clients of the package see that as <code>ring.New</code>.
+package is called <code>ring</code>, it's called just <code>New</code>,
+which clients of the package see as <code>ring.New</code>.
Use the package structure to help you choose good names.
</p>
@@ -331,6 +333,27 @@ to write a helpful doc comment than to attempt to put all the information
into the name.
</p>
+<h3 id="Getters">Getters</h3>
+
+<p>
+Go doesn't provide automatic support for getters and setters.
+There's nothing wrong with providing getters and setters yourself,
+and it's often appropriate to do so, but it's neither idiomatic nor necessary
+to put <code>Get</code> into the getter's name. If you have a field called
+<code>owner</code> (lower case, unexported), the getter method should be
+called <code>Owner</code> (upper case, exported), not <code>GetOwner</code>.
+The use of upper-case names for export provides the hook to discriminate
+the field from the method.
+A setter function, if needed, will likely be called <code>SetOwner</code>.
+Both names read well in practice:
+</p>
+<pre>
+owner := obj.Owner()
+if owner != user {
+ obj.SetOwner(user)
+}
+</pre>
+
<h3 id="interface-names">Interface names</h3>
<p>
@@ -489,8 +512,8 @@ codeUsing(f)
</pre>
<p>
-This is a example of a common situation where code must analyze a
-sequence of error possibilities. The code reads well if the
+This is an example of a common situation where code must guard against a
+sequence of error conditions. The code reads well if the
successful flow of control runs down the page, eliminating error cases
as they arise. Since error cases tend to end in <code>return</code>
statements, the resulting code needs no <code>else</code> statements.
@@ -553,8 +576,9 @@ for _, value := range m { // key is unused
<p>
For strings, the <code>range</code> does more work for you, breaking out individual
-Unicode characters by parsing the UTF-8 (erroneous encodings consume one byte and produce the
-replacement rune U+FFFD). The loop
+Unicode characters by parsing the UTF-8.
+Erroneous encodings consume one byte and produce the
+replacement rune U+FFFD. The loop
</p>
<pre>
for pos, char := range "日本語" {
@@ -571,8 +595,9 @@ character 語 starts at byte position 6
</pre>
<p>
-Finally, since Go has no comma operator and <code>++</code> and <code>--</code>
-are statements not expressions, if you want to run multiple variables in a <code>for</code>
+Finally, Go has no comma operator and <code>++</code> and <code>--</code>
+are statements not expressions.
+Thus if you want to run multiple variables in a <code>for</code>
you should use parallel assignment.
</p>
<pre>
@@ -676,7 +701,7 @@ case *int:
<p>
One of Go's unusual features is that functions and methods
-can return multiple values. This can be used to
+can return multiple values. This form can be used to
improve on a couple of clumsy idioms in C programs: in-band
error returns (such as <code>-1</code> for <code>EOF</code>)
and modifying an argument.
@@ -811,7 +836,7 @@ func Contents(filename string) (string, os.Error) {
</pre>
<p>
-Deferring a function like this has two advantages. First, it
+Deferring a call to a function such as <code>Close</code> has two advantages. First, it
guarantees that you will never forget to close the file, a mistake
that's easy to make if you later edit the function to add a new return
path. Second, it means that the close sits near the open,
@@ -903,8 +928,9 @@ leaving: b
For programmers accustomed to block-level resource management from
other languages, <code>defer</code> may seem peculiar, but its most
interesting and powerful applications come precisely from the fact
-that it's not block-based but function based. In the section on
-<code>panic</code> and <code>recover</code> we'll see an example.
+that it's not block-based but function-based. In the section on
+<code>panic</code> and <code>recover</code> we'll see another
+example of its possibilities.
</p>
<h2 id="data">Data</h2>
@@ -949,7 +975,7 @@ type SyncedBuffer struct {
<p>
Values of type <code>SyncedBuffer</code> are also ready to use immediately upon allocation
-or just declaration. In this snippet, both <code>p</code> and <code>v</code> will work
+or just declaration. In the next snippet, both <code>p</code> and <code>v</code> will work
correctly without further arrangement.
</p>
@@ -987,7 +1013,6 @@ an expression that creates a
new instance each time it is evaluated.
</p>
-
<pre>
func NewFile(fd int, name string) *File {
if fd &lt; 0 {
@@ -999,7 +1024,7 @@ func NewFile(fd int, name string) *File {
</pre>
<p>
-Note that it's perfectly OK to return the address of a local variable;
+Note that, unlike in C, it's perfectly OK to return the address of a local variable;
the storage associated with the variable survives after the function
returns.
In fact, taking the address of a composite literal
@@ -1053,7 +1078,7 @@ is that these three types are, under the covers, references to data structures t
must be initialized before use.
A slice, for example, is a three-item descriptor
containing a pointer to the data (inside an array), the length, and the
-capacity; until those items are initialized, the slice is <code>nil</code>.
+capacity, and until those items are initialized, the slice is <code>nil</code>.
For slices, maps, and channels,
<code>make</code> initializes the internal data structure and prepares
the value for use.
@@ -1273,7 +1298,21 @@ is not present in the map will return the zero value for the type
of the entries
in the map. For instance, if the map contains integers, looking
up a non-existent key will return <code>0</code>.
+A set can be implemented as a map with value type <code>bool</code>.
+Set the map entry to <code>true</code> to put the value in the set, and then
+test it by simple indexing.
</p>
+<pre>
+attended := map[string] bool {
+ "Ann": true,
+ "Joe": true,
+ ...
+}
+
+if attended[person] { // will be false if person is not in the map
+ fmt.Println(person, "was at the meeting")
+}
+</pre>
<p>
Sometimes you need to distinguish a missing entry from
a zero value. Is there an entry for <code>"UTC"</code>
@@ -1298,7 +1337,7 @@ func offset(tz string) int {
if seconds, ok := timeZone[tz]; ok {
return seconds
}
- log.Println("unknown time zone", tz)
+ log.Println("unknown time zone:", tz)
return 0
}
</pre>
diff --git a/doc/go_faq.html b/doc/go_faq.html
index 4be811068..5f92b0528 100644
--- a/doc/go_faq.html
+++ b/doc/go_faq.html
@@ -558,7 +558,8 @@ type Fooer interface {
<p>
A type must then implement the <code>ImplementsFooer</code> method to be a
-<code>Fooer</code>, clearly documenting the fact.
+<code>Fooer</code>, clearly documenting the fact and announcing it in
+<a href="/cmd/godoc/">godoc</a>'s output.
</p>
<pre>
@@ -1032,7 +1033,7 @@ type checks, reflection, and even panic-time stack traces.
<p>
A trivial C "hello, world" program compiled and linked statically using gcc
-on Linux is around 750 kB. An equivalent Go program is around 1.8 MB, but
+on Linux is around 750 kB. An equivalent Go program is around 1.1 MB, but
that includes more powerful run-time support. We believe that with some effort
the size of Go binaries can be reduced.
diff --git a/doc/go_spec.html b/doc/go_spec.html
index 85dfc44bd..f8fe5974a 100644
--- a/doc/go_spec.html
+++ b/doc/go_spec.html
@@ -1,5 +1,5 @@
<!-- title The Go Programming Language Specification -->
-<!-- subtitle Version of March 3, 2011 -->
+<!-- subtitle Version of Apr 5, 2011 -->
<!--
TODO
@@ -1235,8 +1235,11 @@ receiver are ready.
</p>
<p>
-A channel may be closed and tested for closure with the built-in functions
-<a href="#Close_and_closed"><code>close</code> and <code>closed</code></a>.
+A channel may be closed with the built-in function
+<a href="#Close"><code>close</code></a>; the
+multi-valued assignment form of the
+<a href="#Receive_operator">receive operator</a>
+tests whether a channel has been closed.
</p>
<h2 id="Properties_of_types_and_values">Properties of types and values</h2>
@@ -1469,6 +1472,7 @@ declarations.
Labels are declared by <a href="#Labeled_statements">labeled statements</a> and are
used in the <code>break</code>, <code>continue</code>, and <code>goto</code>
statements (§<a href="#Break_statements">Break statements</a>, §<a href="#Continue_statements">Continue statements</a>, §<a href="#Goto_statements">Goto statements</a>).
+It is illegal to define a label that is never used.
In contrast to other identifiers, labels are not block scoped and do
not conflict with identifiers that are not labels. The scope of a label
is the body of the function in which it is declared and excludes
@@ -1496,7 +1500,7 @@ Zero value:
nil
Functions:
- append cap close closed complex copy imag len
+ append cap close complex copy imag len
make new panic print println real recover
</pre>
@@ -3029,9 +3033,6 @@ f(&lt;-ch)
&lt;-strobe // wait until clock pulse and discard received value
</pre>
-<!--
- TODO(rsc): Add after a release or two without any x,ok := <-c.
-
<p>
A receive expression used in an assignment or initialization of the form
</p>
@@ -3049,7 +3050,6 @@ the received value was sent on the channel (<code>true</code>)
or is a <a href="#The_zero_value">zero value</a> returned
because the channel is closed and empty (<code>false</code>).
</p>
--->
<p>
Receiving from a <code>nil</code> channel causes a
@@ -4009,9 +4009,8 @@ iteration values for each entry will be produced at most once.
<li>
For channels, the iteration values produced are the successive values sent on
-the channel until the channel is closed; it does not produce the zero value sent
-before the channel is closed
-(§<a href="#Close_and_closed"><code>close</code> and <code>closed</code></a>).
+the channel until the channel is closed
+(§<a href="#Close"><code>close</code>).
</li>
</ol>
@@ -4086,12 +4085,9 @@ cases all referring to communication operations.
SelectStmt = "select" "{" { CommClause } "}" .
CommClause = CommCase ":" { Statement ";" } .
CommCase = "case" ( SendStmt | RecvStmt ) | "default" .
-RecvStmt = [ Expression ( "=" | ":=" ) ] RecvExpr .
+RecvStmt = [ Expression [ "," Expression ] ( "=" | ":=" ) ] RecvExpr .
RecvExpr = Expression .
</pre>
-<!-- TODO(rsc):
-RecvStmt = [ Expression [ "," Expression ] ( "=" | ":=" ) ] RecvExpr .
--->
<p>
RecvExpr must be a <a href="#Receive_operator">receive operation</a>.
@@ -4122,27 +4118,24 @@ in the "select" statement.
If multiple cases can proceed, a pseudo-random fair choice is made to decide
which single communication will execute.
<p>
-<!-- TODO(rsc): s/variable/& or &s/ -->
-The receive case may declare a new variable using a
+The receive case may declare one or two new variables using a
<a href="#Short_variable_declarations">short variable declaration</a>.
</p>
<pre>
-var c, c1, c2 chan int
+var c, c1, c2, c3 chan int
var i1, i2 int
select {
case i1 = &lt;-c1:
print("received ", i1, " from c1\n")
case c2 &lt;- i2:
print("sent ", i2, " to c2\n")
-<!-- TODO(rsc): add , c3 to channel list above too
case i3, ok := &lt;-c3:
if ok {
print("received ", i3, " from c3\n")
} else {
print("c3 is closed\n")
}
--->
default:
print("no communication\n")
}
@@ -4212,7 +4205,7 @@ func complex_f2() (re float64, im float64) {
</pre>
</li>
<li>The expression list may be empty if the function's result
- type specifies names for its result parameters (§<a href="#Function_Types">Function Types</a>).
+ type specifies names for its result parameters (§<a href="#Function_types">Function Types</a>).
The result parameters act as ordinary local variables
and the function may assign values to them as necessary.
The "return" statement returns the values of these variables.
@@ -4222,6 +4215,11 @@ func complex_f3() (re float64, im float64) {
im = 4.0
return
}
+
+func (devnull) Write(p []byte) (n int, _ os.Error) {
+ n = len(p)
+ return
+}
</pre>
</li>
</ol>
@@ -4259,11 +4257,13 @@ terminates
</p>
<pre>
-L: for i &lt; n {
- switch i {
- case 5: break L
+L:
+ for i &lt; n {
+ switch i {
+ case 5:
+ break L
+ }
}
-}
</pre>
<h3 id="Continue_statements">Continue statements</h3>
@@ -4305,8 +4305,8 @@ instance, this example:
</p>
<pre>
-goto L // BAD
-v := 3
+ goto L // BAD
+ v := 3
L:
</pre>
@@ -4396,8 +4396,7 @@ BuiltinCall = identifier "(" [ BuiltinArgs [ "," ] ] ")" .
BuiltinArgs = Type [ "," ExpressionList ] | ExpressionList .
</pre>
-<!-- TODO(rsc): s/.and.closed//g -->
-<h3 id="Close_and_closed">Close and closed</h3>
+<h3 id="Close">Close</h3>
<p>
For a channel <code>c</code>, the built-in function <code>close(c)</code>
@@ -4407,12 +4406,8 @@ After calling <code>close</code>, and after any previously
sent values have been received, receive operations will return
the zero value for the channel's type without blocking.
-<!-- TODO(rsc): delete next sentence, replace with
- The multi-valued <a href="#Receive_operator">receive operation</a>
- returns a received value along with an indication of whether the channel is closed.
--->
-After at least one such zero value has been
-received, <code>closed(c)</code> returns true.
+The multi-valued <a href="#Receive_operator">receive operation</a>
+returns a received value along with an indication of whether the channel is closed.
</p>
@@ -4700,7 +4695,7 @@ func protect(g func()) {
if x := recover(); x != nil {
log.Printf("run time panic: %v", x)
}
- }
+ }()
log.Println("start")
g()
}
@@ -5152,6 +5147,4 @@ The following minimal alignment properties are guaranteed:
<h2 id="Implementation_differences"><span class="alert">Implementation differences - TODO</span></h2>
<ul>
<li><span class="alert">Implementation does not honor the restriction on goto statements and targets (no intervening declarations).</span></li>
- <li><span class="alert">Gccgo: Method expressions are partially implemented.</span></li>
- <li><span class="alert">Gccgo: allows only one init() function per source file.</span></li>
</ul>
diff --git a/doc/install.html b/doc/install.html
index 816e6e654..843e0645f 100644
--- a/doc/install.html
+++ b/doc/install.html
@@ -91,7 +91,9 @@ installed as part of
<a href="http://developer.apple.com/TOOLS/Xcode/">Xcode</a>.
</p>
-<p>On Ubuntu/Debian, use <code>sudo apt-get install bison ed gawk gcc libc6-dev make</code>.
+<p>On Ubuntu/Debian, use <code>sudo apt-get install bison ed gawk gcc libc6-dev
+make</code>. If you want to build 32-bit binaries on a 64-bit system you'll
+also need the <code>libc6-dev-i386</code> package.
</p>
<h2 id="mercurial">Install Mercurial, if needed</h2>
@@ -275,7 +277,24 @@ For the full story, consult Go's extensive
<h2 id="releases">Keeping up with releases</h2>
-<p>New releases are announced on the <a href="http://groups.google.com/group/golang-nuts">Go Nuts</a> mailing list.
+<p>
+The Go project maintains two stable tags in its Mercurial repository:
+<code>release</code> and <code>weekly</code>.
+The <code>weekly</code> tag is updated about once a week, and should be used by
+those who want to track the project's development.
+The <code>release</code> tag is given, less often, to those weekly releases
+that have proven themselves to be robust.
+</p>
+
+<p>
+Most Go users will want to keep their Go installation at the latest
+<code>release</code> tag.
+New releases are announced on the
+<a href="http://groups.google.com/group/golang-announce">golang-announce</a>
+mailing list.
+</p>
+
+<p>
To update an existing tree to the latest release, you can run:
</p>
@@ -286,6 +305,10 @@ $ hg update release
$ ./all.bash
</pre>
+<p>
+To use the <code>weekly</code> tag run <code>hg update weekly</code> instead.
+</p>
+
<h2 id="community">Community resources</h2>
<p>