Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
0532f4d3
Commit
0532f4d3
authored
Mar 21, 2012
by
Shenghou Ma
Committed by
Robert Griesemer
Mar 21, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doc/effective_go: minor corrections
R=golang-dev, gri CC=golang-dev
https://golang.org/cl/5848063
parent
2ceb653b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
doc/effective_go.html
doc/effective_go.html
+12
-12
No files found.
doc/effective_go.html
View file @
0532f4d3
...
@@ -771,7 +771,7 @@ error code secreted away in a volatile location.
...
@@ -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:
“
Yes, you wrote some
can return a count
<i>
and
</i>
an error:
“
Yes, you wrote some
bytes but not all of them because you filled the device
”
.
bytes but not all of them because you filled the device
”
.
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.
...
@@ -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 s
lices cannot be used as map keys,
supports equality)
, structs and arrays. S
lices cannot be used as map keys,
because equality is not defined on th
ose types
.
because equality is not defined on th
em
.
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))
...
@@ -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
...
@@ -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.
...
@@ -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
—
threads, coroutines, processes, and so on
—
convey
terms
—
threads, coroutines, processes, and so on
—
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
...
@@ -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
...
@@ -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>
PathError
s
</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.
...
@@ -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/te
xt/te
mplate/"
>
documentation
</a>
for the template package for a more thorough discussion.
for the template package for a more thorough discussion.
</p>
</p>
<p>
<p>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment