1
0
mirror of https://github.com/golang/go synced 2024-11-21 21:14:47 -07:00

doc/effective_go: minor corrections

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5848063
This commit is contained in:
Shenghou Ma 2012-03-21 09:33:55 -07:00 committed by Robert Griesemer
parent 2ceb653b8b
commit 0532f4d382

View File

@ -771,7 +771,7 @@ error code secreted away in a volatile location.
In Go, <code>Write</code> In Go, <code>Write</code>
can return a count <i>and</i> an error: &ldquo;Yes, you wrote some can return a count <i>and</i> an error: &ldquo;Yes, you wrote some
bytes but not all of them because you filled the device&rdquo;. bytes but not all of them because you filled the device&rdquo;.
The signature of <code>*File.Write</code> in package <code>os</code> is: The signature of <code>File.Write</code> in package <code>os</code> is:
</p> </p>
<pre> <pre>
@ -1327,9 +1327,9 @@ values of different types.
The key can be of any type for which the equality operator is defined, The key can be of any type for which the equality operator is defined,
such as integers, such as integers,
floating point and complex numbers, floating point and complex numbers,
strings, pointers, and interfaces (as long as the dynamic type strings, pointers, interfaces (as long as the dynamic type
supports equality). Structs, arrays and slices cannot be used as map keys, supports equality), structs and arrays. Slices cannot be used as map keys,
because equality is not defined on those types. because equality is not defined on them.
Like slices, maps are a reference type. If you pass a map to a function Like slices, maps are a reference type. If you pass a map to a function
that changes the contents of the map, the changes will be visible that changes the contents of the map, the changes will be visible
in the caller. in the caller.
@ -1452,7 +1452,7 @@ fmt.Println(fmt.Sprint("Hello ", 23))
</pre> </pre>
<p> <p>
As mentioned in As mentioned in
the <a href="http://code.google.com/p/go-tour/">Tour</a>, <code>fmt.Fprint</code> the <a href="http://tour.golang.org">Tour</a>, <code>fmt.Fprint</code>
and friends take as a first argument any object and friends take as a first argument any object
that implements the <code>io.Writer</code> interface; the variables <code>os.Stdout</code> that implements the <code>io.Writer</code> interface; the variables <code>os.Stdout</code>
and <code>os.Stderr</code> are familiar instances. and <code>os.Stderr</code> are familiar instances.
@ -1920,7 +1920,7 @@ A similar approach allows the streaming cipher algorithms
in the various <code>crypto</code> packages to be in the various <code>crypto</code> packages to be
separated from the block ciphers they chain together. separated from the block ciphers they chain together.
The <code>Block</code> interface The <code>Block</code> interface
in the <code>crypto/cipher</code>package specifies the in the <code>crypto/cipher</code> package specifies the
behavior of a block cipher, which provides encryption behavior of a block cipher, which provides encryption
of a single block of data. of a single block of data.
Then, by analogy with the <code>bufio</code> package, Then, by analogy with the <code>bufio</code> package,
@ -2331,7 +2331,7 @@ it can also be seen as a type-safe generalization of Unix pipes.
They're called <em>goroutines</em> because the existing They're called <em>goroutines</em> because the existing
terms&mdash;threads, coroutines, processes, and so on&mdash;convey terms&mdash;threads, coroutines, processes, and so on&mdash;convey
inaccurate connotations. A goroutine has a simple model: it is a inaccurate connotations. A goroutine has a simple model: it is a
function executing in parallel with other goroutines in the same function executing concurrently with other goroutines in the same
address space. It is lightweight, costing little more than the address space. It is lightweight, costing little more than the
allocation of stack space. allocation of stack space.
And the stacks start small, so they are cheap, and grow And the stacks start small, so they are cheap, and grow
@ -2352,7 +2352,7 @@ exits, silently. (The effect is similar to the Unix shell's
background.) background.)
</p> </p>
<pre> <pre>
go list.Sort() // run list.Sort in parallel; don't wait for it. go list.Sort() // run list.Sort concurrently; don't wait for it.
</pre> </pre>
<p> <p>
A function literal can be handy in a goroutine invocation. A function literal can be handy in a goroutine invocation.
@ -2697,14 +2697,14 @@ it is much more informative than the plain
<p> <p>
When feasible, error strings should identify their origin, such as by having When feasible, error strings should identify their origin, such as by having
a prefix naming the package that generated the error. For example, in package a prefix naming the package that generated the error. For example, in package
image, the string representation for a decoding error due to an unknown format <code>image</code>, the string representation for a decoding error due to an
is "image: unknown format". unknown format is "image: unknown format".
</p> </p>
<p> <p>
Callers that care about the precise error details can Callers that care about the precise error details can
use a type switch or a type assertion to look for specific use a type switch or a type assertion to look for specific
errors and extract details. For <code>PathErrors</code> errors and extract details. For <code>PathError</code>s
this might include examining the internal <code>Err</code> this might include examining the internal <code>Err</code>
field for recoverable failures. field for recoverable failures.
</p> </p>
@ -2985,7 +2985,7 @@ for safe display on the web page.
</p> </p>
<p> <p>
The rest of the template string is just the HTML to show when the page loads. The rest of the template string is just the HTML to show when the page loads.
If this is too quick an explanation, see the <a href="/pkg/template/">documentation</a> If this is too quick an explanation, see the <a href="/pkg/text/template/">documentation</a>
for the template package for a more thorough discussion. for the template package for a more thorough discussion.
</p> </p>
<p> <p>