-<!-- Let's Go -->
+<!-- A Tutorial for the Go Programming Language -->
<h2>Introduction</h2>
<p>
This document is a tutorial introduction to the basics of the Go programming
makes its first appearance in <code>sum</code>. It works on strings, arrays,
slices, maps, and channels.
<p>
+By the way, another thing that works on strings, arrays, slices, maps
+and channels is the <code>range</code> clause on <code>for</code> loops. Instead of writing
+<p>
+<pre>
+ for i := 0; i < len(a); i++ { ... }
+</pre>
+<p>
+to loop over the elements of a slice (or map or ...) , we could write
+<p>
+<pre>
+ for i, v := range a { ... }
+</pre>
+<p>
+This assigns <code>i</code> to the index and <code>v</code> to the value of the successive
+elements of the target of the range. See
+<a href='/doc/effective_go.html'>Effective Go</a>
+for more examples of its use.
+<p>
<p>
<h2>An Interlude about Allocation</h2>
<p>
</pre>
<p>
There are a number of new things in these few lines. First, <code>Open</code> returns
-multiple values, an <code>File</code> and an error (more about errors in a moment).
+multiple values, a <code>File</code> and an error (more about errors in a moment).
We declare the
multi-value return as a parenthesized list of declarations; syntactically
they look just like a second parameter list. The function
-<!-- Let's Go -->
+<!-- A Tutorial for the Go Programming Language -->
Introduction
----
makes its first appearance in "sum". It works on strings, arrays,
slices, maps, and channels.
+By the way, another thing that works on strings, arrays, slices, maps
+and channels is the "range" clause on "for" loops. Instead of writing
+
+ for i := 0; i < len(a); i++ { ... }
+
+to loop over the elements of a slice (or map or ...) , we could write
+
+ for i, v := range a { ... }
+
+This assigns "i" to the index and "v" to the value of the successive
+elements of the target of the range. See
+<a href='/doc/effective_go.html'>Effective Go</a>
+for more examples of its use.
+
An Interlude about Allocation
----
--PROG progs/file.go /func.Open/ /^}/
There are a number of new things in these few lines. First, "Open" returns
-multiple values, an "File" and an error (more about errors in a moment).
+multiple values, a "File" and an error (more about errors in a moment).
We declare the
multi-value return as a parenthesized list of declarations; syntactically
they look just like a second parameter list. The function