summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-04-20 15:44:41 +0200
committerOndřej Surý <ondrej@sury.org>2011-04-20 15:44:41 +0200
commit50104cc32a498f7517a51c8dc93106c51c7a54b4 (patch)
tree47af80be259cc7c45d0eaec7d42e61fa38c8e4fb /doc
parentc072558b90f1bbedc2022b0f30c8b1ac4712538e (diff)
downloadgolang-50104cc32a498f7517a51c8dc93106c51c7a54b4.tar.gz
Imported Upstream version 2011.03.07.1upstream/2011.03.07.1
Diffstat (limited to 'doc')
-rw-r--r--doc/code.html46
-rw-r--r--doc/codelab/wiki/Makefile2
-rwxr-xr-xdoc/codelab/wiki/test.sh2
-rw-r--r--doc/codelab/wiki/wiki.html70
-rw-r--r--doc/devel/release.html153
-rw-r--r--doc/devel/roadmap.html2
-rw-r--r--doc/effective_go.html6
-rw-r--r--doc/gccgo_contribute.html2
-rw-r--r--doc/gccgo_install.html2
-rw-r--r--doc/go_faq.html118
-rw-r--r--doc/go_for_cpp_programmers.html4
-rw-r--r--doc/go_spec.html36
-rw-r--r--doc/install.html9
-rw-r--r--doc/talks/go_talk-20091030.pdfbin247502 -> 0 bytes
14 files changed, 376 insertions, 76 deletions
diff --git a/doc/code.html b/doc/code.html
index 9236cf263..cdc60b071 100644
--- a/doc/code.html
+++ b/doc/code.html
@@ -229,7 +229,7 @@ run <code>gotest one_test.go</code>.
<p>
If your change affects performance, add a <code>Benchmark</code> function
(see the <a href="/cmd/gotest/">gotest command documentation</a>)
-and run it using <code>gotest -benchmarks=.</code>.
+and run it using <code>gotest -test.bench=.</code>.
</p>
<p>
@@ -322,3 +322,47 @@ reported.
See the <a href="/cmd/gotest/">gotest documentation</a> and the
<a href="/pkg/testing/">testing package</a> for more detail.
</p>
+
+<h2 id="arch_os_specific">Architecture- and operating system-specific code</h2>
+
+<p>First, a disclaimer: very few Go packages should need to know about the
+hardware and operating system they run on. In the vast majority of cases the
+language and standard library handle most portability issues. This section is
+a guide for experienced systems programmers who have a good reason to write
+platform-specific code, such as assembly-language support for fast
+trigonometric functions or code that implements a common interface above
+different operating systems.</p>
+
+<p>To compile such code, use the <code>$GOOS</code> and <code>$GOARCH</code>
+<a href="/doc/install.html#environment">environment variables</a> in your
+source file names and <code>Makefile</code>.</p>
+
+<p>For example, this <code>Makefile</code> describes a package that builds on
+different operating systems by parameterizing the file name with
+<code>$GOOS</code>.</p>
+
+<pre>
+include $(GOROOT)/src/Make.inc
+
+TARG=mypackage
+GOFILES=\
+ my.go\
+ my_$(GOOS).go\
+
+include $(GOROOT)/src/Make.pkg
+</pre>
+
+<p>The OS-specific code goes in <code>my_linux.go</code>,
+<code>my_darwin.go</code>, and so on.</p>
+
+<p>If you follow these conventional parameterizations, tools such as
+<a href="/cmd/goinstall/">goinstall</a> will work seamlessly with your package:
+</p>
+
+<pre>
+my_$(GOOS).go
+my_$(GOARCH).go
+my_$(GOOS)_$(GOARCH).go
+</pre>
+
+<p>The same holds for <code>.s</code> (assembly) files.</p>
diff --git a/doc/codelab/wiki/Makefile b/doc/codelab/wiki/Makefile
index 0d948ed4b..43f05b21d 100644
--- a/doc/codelab/wiki/Makefile
+++ b/doc/codelab/wiki/Makefile
@@ -11,7 +11,7 @@ include ../../../src/Make.common
CLEANFILES+=index.html srcextract.bin htmlify.bin
index.html: srcextract.bin htmlify.bin
- awk '/^!/{system(substr($$0,2)); next} {print}' "$$@" < wiki.html > index.html
+ PATH=.:$$PATH awk '/^!/{system(substr($$0,2)); next} {print}' < wiki.html | tr -d '\r' > index.html
test: get.bin
bash ./test.sh
diff --git a/doc/codelab/wiki/test.sh b/doc/codelab/wiki/test.sh
index 95ff145b9..ed63ff20f 100755
--- a/doc/codelab/wiki/test.sh
+++ b/doc/codelab/wiki/test.sh
@@ -12,7 +12,7 @@ gomake get.bin
addr=$(./get.bin -addr)
sed s/:8080/$addr/ < final.go > final-test.go
gomake final-test.bin
-./final-test.bin &
+(./final-test.bin) &
wiki_pid=$!
sleep 1
diff --git a/doc/codelab/wiki/wiki.html b/doc/codelab/wiki/wiki.html
index 7ef97b45b..3628eeb56 100644
--- a/doc/codelab/wiki/wiki.html
+++ b/doc/codelab/wiki/wiki.html
@@ -76,7 +76,7 @@ the title and body.
</p>
<pre>
-!./srcextract.bin -src=part1.go -name=Page
+!srcextract.bin -src=part1.go -name=Page
</pre>
<p>
@@ -95,7 +95,7 @@ But what about persistent storage? We can address that by creating a
</p>
<pre>
-!./srcextract.bin -src=part1.go -name=save
+!srcextract.bin -src=part1.go -name=save
</pre>
<p>
@@ -131,7 +131,7 @@ We will want to load pages, too:
</p>
<pre>
-!./srcextract.bin -src=part1-noerror.go -name=loadPage
+!srcextract.bin -src=part1-noerror.go -name=loadPage
</pre>
<p>
@@ -155,7 +155,7 @@ function to return <code>*Page</code> and <code>os.Error</code>.
</p>
<pre>
-!./srcextract.bin -src=part1.go -name=loadPage
+!srcextract.bin -src=part1.go -name=loadPage
</pre>
<p>
@@ -173,7 +173,7 @@ written:
</p>
<pre>
-!./srcextract.bin -src=part1.go -name=main
+!srcextract.bin -src=part1.go -name=main
</pre>
<p>
@@ -211,7 +211,7 @@ Here's a full working example of a simple web server:
</p>
<pre>
-!./htmlify.bin < http-sample.go
+!htmlify.bin < http-sample.go
</pre>
<p>
@@ -276,9 +276,9 @@ Let's create a handler to view a wiki page:
</p>
<pre>
-!./srcextract.bin -src=part2.go -name=lenPath
+!srcextract.bin -src=part2.go -name=lenPath
-!./srcextract.bin -src=part2.go -name=viewHandler
+!srcextract.bin -src=part2.go -name=viewHandler
</pre>
<p>
@@ -309,7 +309,7 @@ any requests under the path <code>/view/</code>.
</p>
<pre>
-!./srcextract.bin -src=part2.go -name=main
+!srcextract.bin -src=part2.go -name=main
</pre>
<p>
@@ -348,7 +348,7 @@ First, we add them to <code>main()</code>:
</p>
<pre>
-!./srcextract.bin -src=final-noclosure.go -name=main
+!srcextract.bin -src=final-noclosure.go -name=main
</pre>
<p>
@@ -358,7 +358,7 @@ and displays an HTML form.
</p>
<pre>
-!./srcextract.bin -src=notemplate.go -name=editHandler
+!srcextract.bin -src=notemplate.go -name=editHandler
</pre>
<p>
@@ -394,7 +394,7 @@ Open a new file named <code>edit.html</code>, and add the following lines:
</p>
<pre>
-!./htmlify.bin < edit.html
+!htmlify.bin < edit.html
</pre>
<p>
@@ -403,7 +403,7 @@ HTML:
</p>
<pre>
-!./srcextract.bin -src=final-noerror.go -name=editHandler
+!srcextract.bin -src=final-noerror.go -name=editHandler
</pre>
<p>
@@ -438,7 +438,7 @@ While we're working with templates, let's create a template for our
</p>
<pre>
-!./htmlify.bin < view.html
+!htmlify.bin < view.html
</pre>
<p>
@@ -446,7 +446,7 @@ Modify <code>viewHandler</code> accordingly:
</p>
<pre>
-!./srcextract.bin -src=final-noerror.go -name=viewHandler
+!srcextract.bin -src=final-noerror.go -name=viewHandler
</pre>
<p>
@@ -456,11 +456,11 @@ to its own function:
</p>
<pre>
-!./srcextract.bin -src=final-template.go -name=viewHandler
+!srcextract.bin -src=final-template.go -name=viewHandler
-!./srcextract.bin -src=final-template.go -name=editHandler
+!srcextract.bin -src=final-template.go -name=editHandler
-!./srcextract.bin -src=final-template.go -name=renderTemplate
+!srcextract.bin -src=final-template.go -name=renderTemplate
</pre>
<p>
@@ -477,7 +477,7 @@ redirect the client to the edit Page so the content may be created:
</p>
<pre>
-!./srcextract.bin -src=final-noclosure.go -name=viewHandler
+!srcextract.bin -src=final-noclosure.go -name=viewHandler
</pre>
<p>
@@ -493,7 +493,7 @@ The function <code>saveHandler</code> will handle the form submission.
</p>
<pre>
-!./srcextract.bin -src=final-template.go -name=saveHandler
+!srcextract.bin -src=final-template.go -name=saveHandler
</pre>
<p>
@@ -525,7 +525,7 @@ First, let's handle the errors in <code>renderTemplate</code>:
</p>
<pre>
-!./srcextract.bin -src=final-parsetemplate.go -name=renderTemplate
+!srcextract.bin -src=final-parsetemplate.go -name=renderTemplate
</pre>
<p>
@@ -539,7 +539,7 @@ Now let's fix up <code>saveHandler</code>:
</p>
<pre>
-!./srcextract.bin -src=final-noclosure.go -name=saveHandler
+!srcextract.bin -src=final-noclosure.go -name=saveHandler
</pre>
<p>
@@ -564,7 +564,7 @@ our <code>*Template</code> values, keyed by <code>string</code>
</p>
<pre>
-!./srcextract.bin -src=final.go -name=templates
+!srcextract.bin -src=final.go -name=templates
</pre>
<p>
@@ -577,7 +577,7 @@ be loaded the only sensible thing to do is exit the program.
</p>
<pre>
-!./srcextract.bin -src=final.go -name=init
+!srcextract.bin -src=final.go -name=init
</pre>
<p>
@@ -593,7 +593,7 @@ the <code>Execute</code> method on the appropriate <code>Template</code> from
<code>templates</code>:
<pre>
-!./srcextract.bin -src=final.go -name=renderTemplate
+!srcextract.bin -src=final.go -name=renderTemplate
</pre>
<h2>Validation</h2>
@@ -610,7 +610,7 @@ Then we can create a global variable to store our validation regexp:
</p>
<pre>
-!./srcextract.bin -src=final-noclosure.go -name=titleValidator
+!srcextract.bin -src=final-noclosure.go -name=titleValidator
</pre>
<p>
@@ -628,7 +628,7 @@ URL, and tests it against our <code>TitleValidator</code> expression:
</p>
<pre>
-!./srcextract.bin -src=final-noclosure.go -name=getTitle
+!srcextract.bin -src=final-noclosure.go -name=getTitle
</pre>
<p>
@@ -643,11 +643,11 @@ Let's put a call to <code>getTitle</code> in each of the handlers:
</p>
<pre>
-!./srcextract.bin -src=final-noclosure.go -name=viewHandler
+!srcextract.bin -src=final-noclosure.go -name=viewHandler
-!./srcextract.bin -src=final-noclosure.go -name=editHandler
+!srcextract.bin -src=final-noclosure.go -name=editHandler
-!./srcextract.bin -src=final-noclosure.go -name=saveHandler
+!srcextract.bin -src=final-noclosure.go -name=saveHandler
</pre>
<h2>Introducing Function Literals and Closures</h2>
@@ -700,7 +700,7 @@ Now we can take the code from <code>getTitle</code> and use it here
</p>
<pre>
-!./srcextract.bin -src=final.go -name=makeHandler
+!srcextract.bin -src=final.go -name=makeHandler
</pre>
<p>
@@ -723,7 +723,7 @@ package:
</p>
<pre>
-!./srcextract.bin -src=final.go -name=main
+!srcextract.bin -src=final.go -name=main
</pre>
<p>
@@ -732,11 +732,11 @@ making them much simpler:
</p>
<pre>
-!./srcextract.bin -src=final.go -name=viewHandler
+!srcextract.bin -src=final.go -name=viewHandler
-!./srcextract.bin -src=final.go -name=editHandler
+!srcextract.bin -src=final.go -name=editHandler
-!./srcextract.bin -src=final.go -name=saveHandler
+!srcextract.bin -src=final.go -name=saveHandler
</pre>
<h2>Try it out!</h2>
diff --git a/doc/devel/release.html b/doc/devel/release.html
index 57da6ca60..c7691c766 100644
--- a/doc/devel/release.html
+++ b/doc/devel/release.html
@@ -5,15 +5,164 @@
<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-02-01">2011-02-15</h3>
+<h3 id="2011-03-07">2011-03-07</h3>
<pre>
-This release includes changes to the io and template packages.
+This release includes changes to the reflect and path packages.
+Code that uses reflect or path may need to be updated.
+
+The reflect package's Value.Addr method has been renamed to Value.UnsafeAddr.
+Code that uses the Addr method will have to call UnsafeAddr instead.
+
+The path package has been split into two packages: path and path/filepath.
+Package path manipulates slash-separated paths, regardless of operating system.
+Package filepath implements the local operating system's native file paths.
+OS-specific functioanlity in pacakge path, such as Walk, moved to filepath.
+
+Other changes:
+* build: fixes and simplifications (thanks Dave Cheney),
+ move $GOBIN ahead of /bin, /usr/bin in build $PATH.
+* bzip2: speed up decompression.
+* cgo: fix dwarf type parsing (thanks Gustavo Niemeyer),
+ put temporary source files in _obj (thanks Roger Peppe),
+ fix bug involving 0-argument callbacks.
+* compress/lzw: optimizations.
+* doc: add FAQ about "implements",
+ add FAQ about large binaries ,
+ add FAQ about stack vs heap allocation,
+ add internationalization to roadmap,
+ describe platform-specific conventions in code.html.
+* fmt: allow recursive calls to Fscan etc (thanks Roger Peppe),
+ make %#p suppress leading 0x.
+* gc, gopack: add some missing flags to the docs.
+* gc: fix init of packages named main (thanks Gustavo Niemeyer),
+* gob: make recursive map and slice types work, and other fixes.
+ tentative support for GobEncoder/GobDecoder interfaces.
+* gobuilder: add -package flag to build external packages and -v for verbose.
+* gofmt: exclude test file that is not legal Go.
+* goinstall: protect against malicious filenames (thanks Roger Peppe).
+* goyacc: provide -p flag to set prefix for names, documentation update.
+* http: add cookie support (thanks Petar Maymounkov),
+ allow handlers to send non-chunked responses,
+ export ParseHTTPVersion,
+ expose Client's Transport,
+ use WriteProxy,
+ rename ClientTransport to Transport.
+* http/cgi: new package.
+* http/httptest: new package.
+* image: add a decoding test for common file formats.
+* io/ioutil: add TempDir.
+* mime/multipart: Header changed from map to MIMEHeader
+* path/filepath: new OS-specific path support (thanks Gustavo Niemeyer).
+* reflect: add PtrTo, add Value.Addr (old Addr is now UnsafeAddr).
+* runtime: use kernel-supplied compare-and-swap on linux/arm.
+* spec: minor clarification of scope rule for functions.
+* sync/atomic: new package to expose atomic operations.
+* syscall: regenerate zerrors_freebsd_amd64.go (thanks Mikio Hara),
+ work around FreeBSD execve kernel bug (thanks Devon H. O'Dell).
+* template: document the delimiters.
+* testing: run GC before each benchmark run (thanks Roger Peppe).
+* unsafe: fix the documentation.
+* websocket: use httptest.Server for tests (thanks Robert Hencke).
+* xml: permit nested directives (thanks Chris Dollin).
+</pre>
+
+<h3 id="2011-02-24">2011-02-24</h3>
+
+<pre>
+This release includes changes to the http package and a small language change.
+Your code will require changes if it manipulates http Headers or omits the
+condition in if statements.
+
+The new http.Header type replaces map[string]string in the Header and Trailer
+fields of http.Request and http.Response.
+A Header value can be manipulated via its Get, Set, Add, and Del methods.
+See http://golang.org/pkg/http/#Header
+
+The condition is now mandatory in if statements.
+Previously it would default to true, as in switch and for statements.
+This code is now illegal:
+ if x := foo(); {
+ // code that is always executed
+ }
+The same effect can be achieved like this:
+ if x := foo(); true {
+ // code
+ }
+Or, in a simpler form:
+ {
+ x := foo()
+ // code
+ }
+
+Other changes:
+* 6l: new -Hwindowsgui flag allows to build windows gui pe (thanks Alex Brainman),
+ pe fixes (thanks Wei Guangjing).
+* 8l, 6l: allow for more os threads to be created on Windows (thanks Alex Brainman),
+* build: reduce the use of subshells in recursive make, and
+ remove unused NaCl conditional from make.bash (thanks Dave Cheney).
+* codereview: fix clpatch with empty diffs (thanks Gustavo Niemeyer).
+* compress/bzip2: add package.
+* compress/lzw: implement a decoder.
+* crypto/openpgp: add package.
+* crypto/rand: add read buffer to speed up small requests (thanks Albert Strasheim).
+* crypto/rsa: left-pad OAEP results when needed.
+* crypto/tls: make protocol negotiation failure fatal.
+* fmt: stop giving characters to the Scan method of Scanner when we hit a newline in Scanln.
+* gc: interface error message fixes,
+ make string const comparison unsigned (thanks Jeff R. Allen).
+* go spec: minor clarification on channel types.
+* go/ast, parser: condition in if statement is mandatory.
+* gob: compute information about a user's type once.
+ protect against pure recursive types.
+* godoc: accept symbolic links as path names provided to -path,
+ add robots.txt, log errors when reading filter files.
+* html: tokenize HTML comments.
+* http: add proxy support (thanks Yasuhiro Matsumoto),
+ implement with net/textproto (thanks Petar Maymounkov),
+ send full URL in proxy requests,
+ introduce start of Client and ClientTransport.
+* image/png: support for more formats (thanks Mikael Tillenius).
+* json: only use alphanumeric tags,
+ use base64 to encode []byte (thanks Roger Peppe).
+* ld: detect stack overflow due to NOSPLIT, drop rpath, support weak symbols.
+* misc/dashboard/builder: talk to hg with utf-8 encoding.
+* misc/dashboard: notify golang-dev on build failure.
+* net: *netFD.Read to return os.EOF on eof under windows (thanks Alex Brainman),
+ add IPv4 multicast to UDPConn (thanks Dave Cheney),
+ more accurate IPv4-in-IPv6 API test (thanks Mikio Hara),
+ reject invalid net:proto network names (thanks Olivier Antoine).
+* 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 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,
+ record $GOROOT_FINAL for runtime.GOROOT.
+* spec: delete incorrect mention of selector working on pointer to interface type.
+* sync: add Cond (thanks Gustavo Niemeyer).
+* syscall: add MCL_* flags for mlockall (thanks Albert Strasheim),
+ implement chmod() for win32 (thanks Yasuhiro Matsumoto).
+* test/bench: update timings for new GC.
+* testing: rename cmdline flags to avoid conflicts (thanks Gustavo Niemeyer).
+* textproto: introduce Header type (thanks Petar Maymounkov).
+* websocket: use new interface to access Header.
+</pre>
+
+<h3 id="2011-02-15">2011-02-15</h3>
+
+<pre>
+This release includes changes to the io, os, and template packages.
You may need to update your code.
The io.ReadByter and io.ReadRuner interface types have been renamed to
io.ByteReader and io.RuneReader respectively.
+The os package's ForkExec function has been superseded by the new StartProcess
+function and an API built around the Process type:
+ http://golang.org/pkg/os/#Process
+
The order of arguments to template.Execute has been reversed to be consistent
the notion of "destination first", as with io.Copy, fmt.Fprint, and others.
diff --git a/doc/devel/roadmap.html b/doc/devel/roadmap.html
index 9a3c4eaba..97d8a08b8 100644
--- a/doc/devel/roadmap.html
+++ b/doc/devel/roadmap.html
@@ -47,6 +47,8 @@ App Engine support.
Improved CGO including some mechanism for calling back from C to Go.
<li>
Improved implementation documentation.
+<li>
+Comprehensive support for internationalization.
</ul>
<h4 id="Gc_roadmap">
diff --git a/doc/effective_go.html b/doc/effective_go.html
index 8f94f467b..a32179298 100644
--- a/doc/effective_go.html
+++ b/doc/effective_go.html
@@ -194,9 +194,13 @@ Comments do not need extra formatting such as banners of stars.
The generated output may not even be presented in a fixed-width font, so don't depend
on spacing for alignment&mdash;<code>godoc</code>, like <code>gofmt</code>,
takes care of that.
-Finally, the comments are uninterpreted plain text, so HTML and other
+The comments are uninterpreted plain text, so HTML and other
annotations such as <code>_this_</code> will reproduce <i>verbatim</i> and should
not be used.
+Depending on the context, <code>godoc</code> might not even
+reformat comments, so make sure they look good straight up:
+use correct spelling, punctuation, and sentence structure,
+fold long lines, and so on.
</p>
<p>
diff --git a/doc/gccgo_contribute.html b/doc/gccgo_contribute.html
index cab6967f3..8eeb3a5c5 100644
--- a/doc/gccgo_contribute.html
+++ b/doc/gccgo_contribute.html
@@ -45,7 +45,7 @@ a <code>gcc-interface</code> subdirectory.
</p>
<p>
-The runtime library for <code>gccgo</code> is mostly the same as the
+The run-time library for <code>gccgo</code> is mostly the same as the
library in <a href="http://code.google.com/p/go">the main Go
repository</a>. The library code in the Go repository is periodically
copied into the <code>gofrontend</code> and the <code>gcc</code>
diff --git a/doc/gccgo_install.html b/doc/gccgo_install.html
index 2ab6dcdae..159fab7bb 100644
--- a/doc/gccgo_install.html
+++ b/doc/gccgo_install.html
@@ -116,7 +116,7 @@ gccgo -o file file.o
<p>
To run the resulting file, you will need to tell the program where to
-find the Go runtime library. This can be done either by setting
+find the compiled Go packages. This can be done either by setting
<code>LD_LIBRARY_PATH</code> in your environment:
<pre>
diff --git a/doc/go_faq.html b/doc/go_faq.html
index 3f9c1d246..4be811068 100644
--- a/doc/go_faq.html
+++ b/doc/go_faq.html
@@ -508,6 +508,71 @@ Regarding operator overloading, it seems more a convenience than an absolute
requirement. Again, things are simpler without it.
</p>
+<h3 id="implements_interface">
+Why doesn't Go have "implements" declarations?</h3>
+
+<p>
+A Go type satisfies an interface by implementing the methods of that interface,
+nothing more. This property allows interfaces to be defined and used without
+having to modify existing code. It enables a kind of "duck typing" that
+promotes separation of concerns and improves code re-use, and makes it easier
+to build on patterns that emerge as the code develops.
+The semantics of interfaces is one of the main reasons for Go's nimble,
+lightweight feel.
+</p>
+
+<p>
+See the <a href="#inheritance">question on type inheritance</a> for more detail.
+</p>
+
+<h3 id="guarantee_satisfies_interface">
+How can I guarantee my type satisfies an interface?</h3>
+
+<p>
+You can ask the compiler to check that the type <code>T</code> implements the
+interface <code>I</code> by attempting an assignment:
+</p>
+
+<pre>
+type T struct{}
+var _ I = T{}
+</pre>
+
+<p>
+If <code>T</code> doesn't implement <code>I</code>, the mistake will be caught
+at compile time.
+</p>
+
+<p>
+If you wish the users of an interface to explicitly declare that they implement
+it, you can add a method with a descriptive name to the interface's method set.
+For example:
+</p>
+
+<pre>
+type Fooer interface {
+ Foo()
+ ImplementsFooer()
+}
+</pre>
+
+<p>
+A type must then implement the <code>ImplementsFooer</code> method to be a
+<code>Fooer</code>, clearly documenting the fact.
+</p>
+
+<pre>
+type Bar struct{}
+func (b Bar) ImplementsFooer() {}
+func (b Bar) Foo() {}
+</pre>
+
+<p>
+Most code doesn't make use of such constraints, since they limit the utility of
+the interface idea. Sometimes, though, they're necessary to resolve ambiguities
+among similar interfaces.
+</p>
+
<h2 id="values">Values</h2>
@@ -677,6 +742,28 @@ floating-point numbers.
The default size of a floating-point constant is <code>float64</code>.
</p>
+<h3 id="stack_or_heap">
+How do I know whether a variable is allocated on the heap or the stack?</h3>
+
+<p>
+From a correctness standpoint, you don't need to know.
+Each variable in Go exists as long as there are references to it.
+The storage location chosen by the implementation is irrelevant to the
+semantics of the language.
+
+<p>
+The storage location does have an effect on writing efficient programs.
+When possible, the Go compilers will allocate variables that are
+local to a function in that function's stack frame. However, if the
+compiler cannot prove that the variable is not referenced after the
+function returns, then the compiler must allocate the variable on the
+garbage-collected heap to avoid dangling pointer errors.
+
+<p>
+In the current compilers, the analysis is crude: if a variable has its address
+taken, that variable is allocated on the heap. We are working to improve this
+analysis so that more data is kept on the stack.
+
<h2 id="Concurrency">Concurrency</h2>
<h3 id="What_operations_are_atomic_What_about_mutexes">
@@ -708,7 +795,7 @@ Why doesn't my multi-goroutine program use multiple CPUs?</h3>
<p>
Under the gc compilers you must set <code>GOMAXPROCS</code> to allow the
-runtime to utilise more than one OS thread. Under <code>gccgo</code> an OS
+run-time support to utilise more than one OS thread. Under <code>gccgo</code> an OS
thread will be created for each goroutine, and <code>GOMAXPROCS</code> is
effectively equal to the number of running goroutines.
</p>
@@ -716,7 +803,7 @@ effectively equal to the number of running goroutines.
<p>
Programs that perform concurrent computation should benefit from an increase in
<code>GOMAXPROCS</code>. (See the <a
-href="http://golang.org/pkg/runtime/#GOMAXPROCS">runtime package
+href="http://golang.org/pkg/runtime/#GOMAXPROCS"><code>runtime</code> package's
documentation</a>.)
</p>
@@ -737,8 +824,8 @@ penalty involved in sending data between threads.
</p>
<p>
-The Go runtime's scheduler is not as good as it needs to be. In future, it
-should recognise such cases and optimize its use of OS threads. For now,
+Go's goroutine scheduler is not as good as it needs to be. In future, it
+should recognize such cases and optimize its use of OS threads. For now,
<code>GOMAXPROCS</code> should be set on a per-application basis.
</p>
@@ -920,13 +1007,13 @@ parser are already available in <a href="/pkg/go/"><code>/pkg/go</code></a>.)
We also considered using LLVM for <code>6g</code> but we felt it was too large and
slow to meet our performance goals.
-<h3 id="How_is_the_runtime_implemented">
-How is the runtime implemented?</h3>
+<h3 id="How_is_the_run_time_support_implemented">
+How is the run-time support implemented?</h3>
<p>
-Again due to bootstrapping issues, the runtime is mostly in C (with a
+Again due to bootstrapping issues, the run-time code is mostly in C (with a
tiny bit of assembler) although Go is capable of implementing most of
-it now. <code>Gccgo</code>'s runtime uses <code>glibc</code>.
+it now. <code>Gccgo</code>'s run-time support uses <code>glibc</code>.
<code>Gc</code> uses a custom library, to keep the footprint under
control; it is
compiled with a version of the Plan 9 C compiler that supports
@@ -934,6 +1021,21 @@ segmented stacks for goroutines.
Work is underway to provide the same stack management in
<code>gccgo</code>.
+<h3 id="Why_is_my_trivial_program_such_a_large_binary">
+Why is my trivial program such a large binary?</h3>
+
+<p>
+The gc tool chain (<code>5l</code>, <code>6l</code>, and <code>8l</code>) only
+generate statically linked binaries. All Go binaries therefore include the Go
+run-time, along with the run-time type information necessary to support dynamic
+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
+that includes more powerful run-time support. We believe that with some effort
+the size of Go binaries can be reduced.
+
<h2 id="Performance">Performance</h2>
<h3 id="Why_does_Go_perform_badly_on_benchmark_x">
diff --git a/doc/go_for_cpp_programmers.html b/doc/go_for_cpp_programmers.html
index 608ab147b..7168f1d05 100644
--- a/doc/go_for_cpp_programmers.html
+++ b/doc/go_for_cpp_programmers.html
@@ -555,7 +555,7 @@ When you want the equivalent of a virtual function, use an interface.
A variable which has an interface type may be converted to have a
different interface type using a special construct called a type assertion.
This is implemented dynamically
-at runtime, like C++ <code>dynamic_cast</code>. Unlike
+at run time, like C++ <code>dynamic_cast</code>. Unlike
<code>dynamic_cast</code>, there does
not need to be any declared relationship between the two interfaces.
@@ -589,7 +589,7 @@ must unbox using a type assertion to recover
values of the contained type. As the typing is dynamic rather
than static, there is no equivalent of the way that a C++ template may
inline the relevant operations. The operations are fully type-checked
-at runtime, but all operations will involve a function call.
+at run time, but all operations will involve a function call.
<pre>
type iterator interface {
diff --git a/doc/go_spec.html b/doc/go_spec.html
index a95ed704a..85dfc44bd 100644
--- a/doc/go_spec.html
+++ b/doc/go_spec.html
@@ -1,5 +1,5 @@
<!-- title The Go Programming Language Specification -->
-<!-- subtitle Version of February 8, 2011 -->
+<!-- subtitle Version of March 3, 2011 -->
<!--
TODO
@@ -1227,9 +1227,11 @@ make(chan int, 100)
<p>
The capacity, in number of elements, sets the size of the buffer in the channel. If the
-capacity is greater than zero, the channel is asynchronous: provided the
-buffer is not full, sends can succeed without blocking. If the capacity is zero
-or absent, the communication succeeds only when both a sender and receiver are ready.
+capacity is greater than zero, the channel is asynchronous: communication operations
+succeed without blocking if the buffer is not full (sends) or not empty (receives),
+and elements are received in the order they are sent.
+If the capacity is zero or absent, the communication succeeds only when both a sender and
+receiver are ready.
</p>
<p>
@@ -1429,8 +1431,8 @@ Go is lexically scoped using blocks:
<li>The scope of a predeclared identifier is the universe block.</li>
<li>The scope of an identifier denoting a constant, type, variable,
- or function declared at top level (outside any function) is the
- package block.</li>
+ or function (but not method) declared at top level (outside any
+ function) is the package block.</li>
<li>The scope of an imported package identifier is the file block
of the file containing the import declaration.</li>
@@ -2265,7 +2267,7 @@ If there is not exactly one <code>f</code> with shallowest depth, the selector
expression is illegal.
</li>
<li>
-For a variable <code>x</code> of type <code>I</code> or <code>*I</code>
+For a variable <code>x</code> of type <code>I</code>
where <code>I</code> is an interface type,
<code>x.f</code> denotes the actual method with name <code>f</code> of the value assigned
to <code>x</code> if there is such a method.
@@ -2742,7 +2744,7 @@ and finally <code>||</code> (logical or):
Precedence Operator
5 * / % &lt;&lt; &gt;&gt; &amp; &amp;^
4 + - | ^
- 3 == != &lt; &lt;= > >=
+ 3 == != &lt; &lt;= &gt; &gt;=
2 &amp;&amp;
1 ||
</pre>
@@ -2758,7 +2760,7 @@ For instance, <code>x / y * z</code> is the same as <code>(x / y) * z</code>.
x &lt;= f()
^a &gt;&gt; b
f() || g()
-x == y+1 &amp;&amp; &lt;-chan_ptr > 0
+x == y+1 &amp;&amp; &lt;-chan_ptr &gt; 0
</pre>
@@ -3684,17 +3686,16 @@ complex, or string constant.
"If" statements specify the conditional execution of two branches
according to the value of a boolean expression. If the expression
evaluates to true, the "if" branch is executed, otherwise, if
-present, the "else" branch is executed. A missing condition
-is equivalent to <code>true</code>.
+present, the "else" branch is executed.
</p>
<pre class="ebnf">
-IfStmt = "if" [ SimpleStmt ";" ] [ Expression ] Block [ "else" Statement ] .
+IfStmt = "if" [ SimpleStmt ";" ] Expression Block [ "else" Statement ] .
</pre>
<pre>
-if x > 0 {
- return true;
+if x &gt; max {
+ x = max
}
</pre>
@@ -3706,7 +3707,7 @@ executes before the expression is evaluated.
<pre>
if x := f(); x &lt; y {
return x
-} else if x > z {
+} else if x &gt; z {
return z
} else {
return y
@@ -4697,7 +4698,7 @@ func protect(g func()) {
defer func() {
log.Println("done") // Println executes normally even in there is a panic
if x := recover(); x != nil {
- log.Printf("runtime panic: %v", x)
+ log.Printf("run time panic: %v", x)
}
}
log.Println("start")
@@ -4794,7 +4795,7 @@ The PackageName is used in <a href="#Qualified_identifiers">qualified identifier
to access the exported identifiers of the package within the importing source file.
It is declared in the <a href="#Blocks">file block</a>.
If the PackageName is omitted, it defaults to the identifier specified in the
-<a href="#Package_clauses">package clause</a> of the imported package.
+<a href="#Package_clause">package clause</a> of the imported package.
If an explicit period (<code>.</code>) appears instead of a name, all the
package's exported identifiers will be declared in the current file's
file block and can be accessed without a qualifier.
@@ -5151,7 +5152,6 @@ 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: The <code>append</code> built-in function is not yet implemented.</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 d8fa8b468..816e6e654 100644
--- a/doc/install.html
+++ b/doc/install.html
@@ -54,7 +54,7 @@ architectures.
</dl>
<p>
-Except for things like low-level operating system interface code, the runtime
+Except for things like low-level operating system interface code, the run-time
support is the same in all ports and includes a mark-and-sweep garbage collector
(a fancier one is in the works), efficient array and string slicing,
support for segmented stacks, and a strong goroutine implementation.
@@ -163,8 +163,7 @@ The compiler is 6g.
</pre>
<p>
-where <var>N</var> is a number that varies from release to release
-and the details on the last few lines will reflect the operating system,
+where the details on the last few lines reflect the operating system,
architecture, and root directory used during the install.
</p>
@@ -419,9 +418,9 @@ to override the defaults.
<code>$GOARM</code> (arm, default=6)
</dt>
<dd>
- The ARM architecture version the runtime libraries should target.
+ The ARM architecture version the run-time libraries should target.
ARMv6 cores have more efficient synchronization primitives. Setting
- <code>$GOARM</code> to 5 will compile the runtime libraries using
+ <code>$GOARM</code> to 5 will compile the run-time libraries using
just SWP instructions that work on older architectures as well.
Running v6 code on an older core will cause an illegal instruction trap.
</dd>
diff --git a/doc/talks/go_talk-20091030.pdf b/doc/talks/go_talk-20091030.pdf
deleted file mode 100644
index 5139ff2bd..000000000
--- a/doc/talks/go_talk-20091030.pdf
+++ /dev/null
Binary files differ