<h3 id="Is_Google_using_go_internally"> Is Google using Go internally?</h3>
<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
<a href="http://golang.org">http://golang.org</a>.
It's just the <a href="/cmd/godoc"><code>godoc</code></a>
(the <code>6g</code> program and friends) and <code>gccgo</code>.
<code>Gc</code> uses a different calling convention and linker and can
therefore only be linked with C programs using the same convention.
-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
-GCC-compiled C or C++ programs.
+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
+GCC-compiled C or C++ programs.
</p>
<p>
-The <a href="/cmd/cgo/">cgo</a> program provides the mechanism for a
-“foreign function interface” to allow safe calling of
+The <a href="/cmd/cgo/">cgo</a> program provides the mechanism for a
+“foreign function interface” to allow safe calling of
C libraries from Go code. SWIG extends this capability to C++ libraries.
</p>
</pre>
<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
among similar interfaces.
</p>
Google Code supported only Subversion and Mercurial.
Mercurial was a better choice because of its plugin mechanism
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>.
</p>
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
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>
<h3 id="methods_on_values_or_pointers">
You must set the <code>GOMAXPROCS</code> shell environment variable
or use the similarly-named <a href="/pkg/runtime/#GOMAXPROCS"><code>function</code></a>
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>
slower?</h3>
<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
more goroutines.
Concurrency only becomes parallelism when the problem is
// wait for all goroutines to complete before exiting
for _ = range values {
- <-done
+ <-done
}
}
</pre>
<p>
-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
+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
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,
-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
<a href="http://golang.org/cmd/go/#hdr-Run_go_tool_vet_on_packages"><code>go vet</code></a>.
</p>
</pre>
<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
the variable <code>u</code>.
</p>
<p>
When developing code, it's common to create these situations
temporarily and it can be annoying to have to edit them out before the
-program will compile.
+program will compile.
</p>
<p>
<p>
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
-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.
+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
+for which versions of comparable performance are not available in Go.
For instance, <a href="/test/bench/shootout/pidigits.go">pidigits.go</a>
depends on a multi-precision math package, and the C
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
(<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
<p>
Still, there is room for improvement. The compilers are good but could be
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.)
</p>
<li>the index <code>x</code> must be an integer value; it is <i>in range</i> if <code>0 <= x < len(a)</code>,
otherwise it is <i>out of range</i></li>
<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>
<p>
<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>
<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>
<p>
<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>
<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>
<p>
<li>if <code>x</code> is out of range at run time,
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
- <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>
</ul>
</p>
<ul>
<li><code>x</code>'s type must be
- <a href="#Assignability">assignable</a>
- to the key type of <code>M</code></li>
+ <a href="#Assignability">assignable</a>
+ to the key type of <code>M</code></li>
<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>
- and the type of <code>a[x]</code> is the value type of <code>M</code></li>
+ <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>
<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>
- for the value type of <code>M</code></li>
+ <code>a[x]</code> is the <a href="#The_zero_value">zero value</a>
+ for the value type of <code>M</code></li>
</ul>
<p>
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, 1<<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
m := make(map[string]int, 100) // map with initial space for 100 elements
</pre>