lab.nexedi.com will be down from Thursday, 20 March 2025, 07:30:00 UTC for a duration of approximately 2 hours

Commit 018e89fa authored by Oling Cat's avatar Oling Cat Committed by Andrew Gerrand

doc/go_spec: remove extra space, align tags, and change a tab to a space.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7198048
parent 6a9e956f
...@@ -208,7 +208,7 @@ easier to understand what happens when things combine. ...@@ -208,7 +208,7 @@ easier to understand what happens when things combine.
<h3 id="Is_Google_using_go_internally"> Is Google using Go internally?</h3> <h3 id="Is_Google_using_go_internally"> Is Google using Go internally?</h3>
<p> <p>
Yes. There are now several Go programs deployed in Yes. There are now several Go programs deployed in
production inside Google. A public example is the server behind production inside Google. A public example is the server behind
<a href="http://golang.org">http://golang.org</a>. <a href="http://golang.org">http://golang.org</a>.
It's just the <a href="/cmd/godoc"><code>godoc</code></a> It's just the <a href="/cmd/godoc"><code>godoc</code></a>
...@@ -224,14 +224,14 @@ There are two Go compiler implementations, <code>gc</code> ...@@ -224,14 +224,14 @@ There are two Go compiler implementations, <code>gc</code>
(the <code>6g</code> program and friends) and <code>gccgo</code>. (the <code>6g</code> program and friends) and <code>gccgo</code>.
<code>Gc</code> uses a different calling convention and linker and can <code>Gc</code> uses a different calling convention and linker and can
therefore only be linked with C programs using the same convention. therefore only be linked with C programs using the same convention.
There is such a C compiler but no C++ compiler. There is such a C compiler but no C++ compiler.
<code>Gccgo</code> is a GCC front-end that can, with care, be linked with <code>Gccgo</code> is a GCC front-end that can, with care, be linked with
GCC-compiled C or C++ programs. GCC-compiled C or C++ programs.
</p> </p>
<p> <p>
The <a href="/cmd/cgo/">cgo</a> program provides the mechanism for a The <a href="/cmd/cgo/">cgo</a> program provides the mechanism for a
&ldquo;foreign function interface&rdquo; to allow safe calling of &ldquo;foreign function interface&rdquo; to allow safe calling of
C libraries from Go code. SWIG extends this capability to C++ libraries. C libraries from Go code. SWIG extends this capability to C++ libraries.
</p> </p>
...@@ -597,7 +597,7 @@ func (b Bar) Foo() {} ...@@ -597,7 +597,7 @@ func (b Bar) Foo() {}
</pre> </pre>
<p> <p>
Most code doesn't make use of such constraints, since they limit the utility of 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 the interface idea. Sometimes, though, they're necessary to resolve ambiguities
among similar interfaces. among similar interfaces.
</p> </p>
...@@ -934,7 +934,7 @@ When the project launched, ...@@ -934,7 +934,7 @@ When the project launched,
Google Code supported only Subversion and Mercurial. Google Code supported only Subversion and Mercurial.
Mercurial was a better choice because of its plugin mechanism Mercurial was a better choice because of its plugin mechanism
that allowed us to create the "codereview" plugin to connect that allowed us to create the "codereview" plugin to connect
the project to the excellent code review tools at the project to the excellent code review tools at
<a href="http://codereview.appspot.com">codereview.appspot.com</a>. <a href="http://codereview.appspot.com">codereview.appspot.com</a>.
</p> </p>
...@@ -971,7 +971,7 @@ slice value doesn't copy the data it points to. Copying an interface value ...@@ -971,7 +971,7 @@ slice value doesn't copy the data it points to. Copying an interface value
makes a copy of the thing stored in the interface value. If the interface makes a copy of the thing stored in the interface value. If the interface
value holds a struct, copying the interface value makes a copy of the value holds a struct, copying the interface value makes a copy of the
struct. If the interface value holds a pointer, copying the interface value struct. If the interface value holds a pointer, copying the interface value
makes a copy of the pointer, but again not the data it points to. makes a copy of the pointer, but again not the data it points to.
</p> </p>
<h3 id="methods_on_values_or_pointers"> <h3 id="methods_on_values_or_pointers">
...@@ -1148,7 +1148,7 @@ Why doesn't my multi-goroutine program use multiple CPUs?</h3> ...@@ -1148,7 +1148,7 @@ Why doesn't my multi-goroutine program use multiple CPUs?</h3>
You must set the <code>GOMAXPROCS</code> shell environment variable You must set the <code>GOMAXPROCS</code> shell environment variable
or use the similarly-named <a href="/pkg/runtime/#GOMAXPROCS"><code>function</code></a> or use the similarly-named <a href="/pkg/runtime/#GOMAXPROCS"><code>function</code></a>
of the runtime package to allow the of the runtime package to allow the
run-time support to utilize more than one OS thread. run-time support to utilize more than one OS thread.
</p> </p>
<p> <p>
...@@ -1161,7 +1161,7 @@ Why does using <code>GOMAXPROCS</code> &gt; 1 sometimes make my program ...@@ -1161,7 +1161,7 @@ Why does using <code>GOMAXPROCS</code> &gt; 1 sometimes make my program
slower?</h3> slower?</h3>
<p> <p>
It depends on the nature of your program. It depends on the nature of your program.
Problems that are intrinsically sequential cannot be sped up by adding Problems that are intrinsically sequential cannot be sped up by adding
more goroutines. more goroutines.
Concurrency only becomes parallelism when the problem is Concurrency only becomes parallelism when the problem is
...@@ -1250,18 +1250,18 @@ func main() { ...@@ -1250,18 +1250,18 @@ func main() {
// wait for all goroutines to complete before exiting // wait for all goroutines to complete before exiting
for _ = range values { for _ = range values {
&lt;-done &lt;-done
} }
} }
</pre> </pre>
<p> <p>
One might mistakenly expect to see <code>a, b, c</code> as the output. One might mistakenly expect to see <code>a, b, c</code> as the output.
What you'll probably see instead is <code>c, c, c</code>. This is because What you'll probably see instead is <code>c, c, c</code>. This is because
each iteration of the loop uses the same instance of the variable <code>v</code>, so each iteration of the loop uses the same instance of the variable <code>v</code>, so
each closure shares that single variable. When the closure runs, it prints the each closure shares that single variable. When the closure runs, it prints the
value of <code>v</code> at the time <code>fmt.Println</code> is executed, value of <code>v</code> at the time <code>fmt.Println</code> is executed,
but <code>v</code> may have been modified since the goroutine was launched. but <code>v</code> may have been modified since the goroutine was launched.
To help detect this and other problems before they happen, run To help detect this and other problems before they happen, run
<a href="http://golang.org/cmd/go/#hdr-Run_go_tool_vet_on_packages"><code>go vet</code></a>. <a href="http://golang.org/cmd/go/#hdr-Run_go_tool_vet_on_packages"><code>go vet</code></a>.
</p> </p>
...@@ -1282,7 +1282,7 @@ One way is to pass the variable as an argument to the closure: ...@@ -1282,7 +1282,7 @@ One way is to pass the variable as an argument to the closure:
</pre> </pre>
<p> <p>
In this example, the value of <code>v</code> is passed as an argument to the In this example, the value of <code>v</code> is passed as an argument to the
anonymous function. That value is then accessible inside the function as anonymous function. That value is then accessible inside the function as
the variable <code>u</code>. the variable <code>u</code>.
</p> </p>
...@@ -1478,7 +1478,7 @@ For these reasons, Go allows neither. ...@@ -1478,7 +1478,7 @@ For these reasons, Go allows neither.
<p> <p>
When developing code, it's common to create these situations When developing code, it's common to create these situations
temporarily and it can be annoying to have to edit them out before the temporarily and it can be annoying to have to edit them out before the
program will compile. program will compile.
</p> </p>
<p> <p>
...@@ -1525,13 +1525,13 @@ Why does Go perform badly on benchmark X?</h3> ...@@ -1525,13 +1525,13 @@ Why does Go perform badly on benchmark X?</h3>
<p> <p>
One of Go's design goals is to approach the performance of C for comparable One of Go's design goals is to approach the performance of C for comparable
programs, yet on some benchmarks it does quite poorly, including several programs, yet on some benchmarks it does quite poorly, including several
in <a href="/test/bench/shootout/">test/bench/shootout</a>. The slowest depend on libraries in <a href="/test/bench/shootout/">test/bench/shootout</a>. The slowest depend on libraries
for which versions of comparable performance are not available in Go. for which versions of comparable performance are not available in Go.
For instance, <a href="/test/bench/shootout/pidigits.go">pidigits.go</a> For instance, <a href="/test/bench/shootout/pidigits.go">pidigits.go</a>
depends on a multi-precision math package, and the C depends on a multi-precision math package, and the C
versions, unlike Go's, use <a href="http://gmplib.org/">GMP</a> (which is versions, unlike Go's, use <a href="http://gmplib.org/">GMP</a> (which is
written in optimized assembler). written in optimized assembler).
Benchmarks that depend on regular expressions Benchmarks that depend on regular expressions
(<a href="/test/bench/shootout/regex-dna.go">regex-dna.go</a>, for instance) are (<a href="/test/bench/shootout/regex-dna.go">regex-dna.go</a>, for instance) are
essentially comparing Go's native <a href="/pkg/regexp">regexp package</a> to essentially comparing Go's native <a href="/pkg/regexp">regexp package</a> to
...@@ -1550,7 +1550,7 @@ indicate. ...@@ -1550,7 +1550,7 @@ indicate.
<p> <p>
Still, there is room for improvement. The compilers are good but could be Still, there is room for improvement. The compilers are good but could be
better, many libraries need major performance work, and the garbage collector better, many libraries need major performance work, and the garbage collector
isn't fast enough yet. (Even if it were, taking care not to generate unnecessary isn't fast enough yet. (Even if it were, taking care not to generate unnecessary
garbage can have a huge effect.) garbage can have a huge effect.)
</p> </p>
......
...@@ -2506,7 +2506,7 @@ If <code>a</code> is not a map: ...@@ -2506,7 +2506,7 @@ If <code>a</code> is not a map:
<li>the index <code>x</code> must be an integer value; it is <i>in range</i> if <code>0 &lt;= x &lt; len(a)</code>, <li>the index <code>x</code> must be an integer value; it is <i>in range</i> if <code>0 &lt;= x &lt; len(a)</code>,
otherwise it is <i>out of range</i></li> otherwise it is <i>out of range</i></li>
<li>a <a href="#Constants">constant</a> index must be non-negative <li>a <a href="#Constants">constant</a> index must be non-negative
and representable by a value of type <code>int</code> and representable by a value of type <code>int</code>
</ul> </ul>
<p> <p>
...@@ -2518,7 +2518,7 @@ where <code>A</code> is an <a href="#Array_types">array type</a>: ...@@ -2518,7 +2518,7 @@ where <code>A</code> is an <a href="#Array_types">array type</a>:
<li>if <code>a</code> is <code>nil</code> or if <code>x</code> is out of range at run time, <li>if <code>a</code> is <code>nil</code> or if <code>x</code> is out of range at run time,
a <a href="#Run_time_panics">run-time panic</a> occurs</li> a <a href="#Run_time_panics">run-time panic</a> occurs</li>
<li><code>a[x]</code> is the array element at index <code>x</code> and the type of <li><code>a[x]</code> is the array element at index <code>x</code> and the type of
<code>a[x]</code> is the element type of <code>A</code></li> <code>a[x]</code> is the element type of <code>A</code></li>
</ul> </ul>
<p> <p>
...@@ -2528,7 +2528,7 @@ For <code>a</code> of type <code>S</code> where <code>S</code> is a <a href="#Sl ...@@ -2528,7 +2528,7 @@ For <code>a</code> of type <code>S</code> where <code>S</code> is a <a href="#Sl
<li>if the slice is <code>nil</code> or if <code>x</code> is out of range at run time, <li>if the slice is <code>nil</code> or if <code>x</code> is out of range at run time,
a <a href="#Run_time_panics">run-time panic</a> occurs</li> a <a href="#Run_time_panics">run-time panic</a> occurs</li>
<li><code>a[x]</code> is the slice element at index <code>x</code> and the type of <li><code>a[x]</code> is the slice element at index <code>x</code> and the type of
<code>a[x]</code> is the element type of <code>S</code></li> <code>a[x]</code> is the element type of <code>S</code></li>
</ul> </ul>
<p> <p>
...@@ -2541,7 +2541,7 @@ where <code>T</code> is a <a href="#String_types">string type</a>: ...@@ -2541,7 +2541,7 @@ where <code>T</code> is a <a href="#String_types">string type</a>:
<li>if <code>x</code> is out of range at run time, <li>if <code>x</code> is out of range at run time,
a <a href="#Run_time_panics">run-time panic</a> occurs</li> a <a href="#Run_time_panics">run-time panic</a> occurs</li>
<li><code>a[x]</code> is the byte at index <code>x</code> and the type of <li><code>a[x]</code> is the byte at index <code>x</code> and the type of
<code>a[x]</code> is <code>byte</code></li> <code>a[x]</code> is <code>byte</code></li>
<li><code>a[x]</code> may not be assigned to</li> <li><code>a[x]</code> may not be assigned to</li>
</ul> </ul>
...@@ -2551,14 +2551,14 @@ where <code>M</code> is a <a href="#Map_types">map type</a>: ...@@ -2551,14 +2551,14 @@ where <code>M</code> is a <a href="#Map_types">map type</a>:
</p> </p>
<ul> <ul>
<li><code>x</code>'s type must be <li><code>x</code>'s type must be
<a href="#Assignability">assignable</a> <a href="#Assignability">assignable</a>
to the key type of <code>M</code></li> to the key type of <code>M</code></li>
<li>if the map contains an entry with key <code>x</code>, <li>if the map contains an entry with key <code>x</code>,
<code>a[x]</code> is the map value with key <code>x</code> <code>a[x]</code> is the map value with key <code>x</code>
and the type of <code>a[x]</code> is the value type of <code>M</code></li> and the type of <code>a[x]</code> is the value type of <code>M</code></li>
<li>if the map is <code>nil</code> or does not contain such an entry, <li>if the map is <code>nil</code> or does not contain such an entry,
<code>a[x]</code> is the <a href="#The_zero_value">zero value</a> <code>a[x]</code> is the <a href="#The_zero_value">zero value</a>
for the value type of <code>M</code></li> for the value type of <code>M</code></li>
</ul> </ul>
<p> <p>
...@@ -5008,7 +5008,7 @@ a <a href="#Run_time_panics">run-time panic</a> occurs. ...@@ -5008,7 +5008,7 @@ a <a href="#Run_time_panics">run-time panic</a> occurs.
s := make([]int, 10, 100) // slice with len(s) == 10, cap(s) == 100 s := make([]int, 10, 100) // slice with len(s) == 10, cap(s) == 100
s := make([]int, 1e3) // slice with len(s) == cap(s) == 1000 s := make([]int, 1e3) // slice with len(s) == cap(s) == 1000
s := make([]int, 1&lt;&lt;63) // illegal: len(s) is not representable by a value of type int s := make([]int, 1&lt;&lt;63) // illegal: len(s) is not representable by a value of type int
s := make([]int, 10, 0) // illegal: len(s) > cap(s) s := make([]int, 10, 0) // illegal: len(s) > cap(s)
c := make(chan int, 10) // channel with a buffer size of 10 c := make(chan int, 10) // channel with a buffer size of 10
m := make(map[string]int, 100) // map with initial space for 100 elements m := make(map[string]int, 100) // map with initial space for 100 elements
</pre> </pre>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment