This commit is contained in:
Mark McGranaghan 2015-02-24 19:13:33 -08:00
parent 446bd9fb2c
commit 518a807773
17 changed files with 65 additions and 33 deletions

View File

@ -1,2 +1,2 @@
a22c44511e84451cca813659f3803fb7ae48dab0 e2ba0461c090789168c712cc7ed0f66aab09a8c8
9xlvGqQjhl NASEOq2R3n

View File

@ -1,2 +1,2 @@
ae75526fdd970c450fa3ed52c70cf400a45d0770 b527bbb76a42dd4bae541b73a7377b7e83e79905
iEAD2cYC-h neqdJ51KLN

View File

@ -1,2 +1,2 @@
19cac21e4a057e8335ce78a30de9a43c2b18d522 ae669923c20e5ebf4a7b4b11b8fdf2972accf9e2
2EXoOWfGf_ 9Nky-Dn49f

View File

@ -1,2 +1,2 @@
4187a4268be1cd85fdd6e9a211d1e4f534666ad6 89b78f3378e1a574ddfd0260a0404a962852eff8
p_ykufAYRj g-aqMz0Ivf

View File

@ -1,2 +1,2 @@
62b0562c92dd84ecb9408df4c517031d75b1e337 f7ce9724ab51b3e90b8d04cf88eaaa8cf2dfd50e
C0_kuFx3ET X973CNW5aa

View File

@ -1,2 +1,2 @@
0ebd0a44997fe20d3fa0caa8b5f2cfa96ff1db13 7cde6b9af5cf6c47606001dd54eee468a6c61dbb
7bnr2EXlxK YeSiBTfhFq

View File

@ -1,2 +1,2 @@
fece72ed980c2ee55b3f1d5d8e8d83aed81dc814 5f39ae6d8f26d59a688a9a9d7d13a5c1d0f7a08b
qayRuqXHym JJAAFGxHVq

View File

@ -1,2 +1,2 @@
52b9bc757a1de989f28665c86ac1f84e17fc0ffc 1f9962260f5c92efe57db0b96099b3dd06c90333
SGS6wIVnDd BFw556nWcM

View File

@ -42,7 +42,7 @@ command-line flag.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="http://play.golang.org/p/9xlvGqQjhl"><img title="Run code" src="play.png" class="run" /></a> <a href="http://play.golang.org/p/NASEOq2R3n"><img title="Run code" src="play.png" class="run" /></a>
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span> <div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
</pre></div> </pre></div>
@ -145,7 +145,7 @@ to execute the command-line parsing.</p>
<td class="docs"> <td class="docs">
<p>Here we&rsquo;ll just dump out the parsed options and <p>Here we&rsquo;ll just dump out the parsed options and
any trailing positional arguments. Note that we any trailing positional arguments. Note that we
need to dereference the points with e.g. <code>*wordPtr</code> need to dereference the pointers with e.g. <code>*wordPtr</code>
to get the actual option values.</p> to get the actual option values.</p>
</td> </td>

View File

@ -121,7 +121,7 @@ get the key and value. Here we print all the keys.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Running the program shows that we pick up the value <p>Running the program shows that we pick up the value
value for <code>FOO</code> that we set in the program, but that for <code>FOO</code> that we set in the program, but that
<code>BAR</code> is empty.</p> <code>BAR</code> is empty.</p>
</td> </td>

View File

@ -47,7 +47,7 @@ function.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="http://play.golang.org/p/iEAD2cYC-h"><img title="Run code" src="play.png" class="run" /></a> <a href="http://play.golang.org/p/neqdJ51KLN"><img title="Run code" src="play.png" class="run" /></a>
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span> <div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
</pre></div> </pre></div>
@ -132,7 +132,7 @@ environment.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Here&rsquo;s the actual <code>os.Exec</code> call. If this call is <p>Here&rsquo;s the actual <code>syscall.Exec</code> call. If this call is
successful, the execution of our process will end successful, the execution of our process will end
here and be replaced by the <code>/bin/ls -a -l -h</code> here and be replaced by the <code>/bin/ls -a -l -h</code>
process. If there is an error we&rsquo;ll get a return process. If there is an error we&rsquo;ll get a return

View File

@ -40,7 +40,7 @@ functions with a few different examples.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="http://play.golang.org/p/2EXoOWfGf_"><img title="Run code" src="play.png" class="run" /></a> <a href="http://play.golang.org/p/9Nky-Dn49f"><img title="Run code" src="play.png" class="run" /></a>
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span> <div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
</pre></div> </pre></div>
@ -89,6 +89,24 @@ expression.</p>
</td> </td>
</tr> </tr>
<tr>
<td class="docs">
<p>When you have multiple consecutive parameters of
the same type, you may omit the type name for the
like-typed parameters up to the final parameter that
declares the type.</p>
</td>
<td class="code leading">
<div class="highlight"><pre><span class="kd">func</span> <span class="nx">plusPlus</span><span class="p">(</span><span class="nx">a</span><span class="p">,</span> <span class="nx">b</span><span class="p">,</span> <span class="nx">c</span> <span class="kt">int</span><span class="p">)</span> <span class="kt">int</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">a</span> <span class="o">+</span> <span class="nx">b</span> <span class="o">+</span> <span class="nx">c</span>
<span class="p">}</span>
</pre></div>
</td>
</tr>
<tr> <tr>
<td class="docs"> <td class="docs">
@ -107,10 +125,23 @@ expression.</p>
<code>name(args)</code>.</p> <code>name(args)</code>.</p>
</td> </td>
<td class="code"> <td class="code leading">
<div class="highlight"><pre> <span class="nx">res</span> <span class="o">:=</span> <span class="nx">plus</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> <div class="highlight"><pre> <span class="nx">res</span> <span class="o">:=</span> <span class="nx">plus</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nx">Println</span><span class="p">(</span><span class="s">&quot;1+2 =&quot;</span><span class="p">,</span> <span class="nx">res</span><span class="p">)</span> <span class="nx">fmt</span><span class="p">.</span><span class="nx">Println</span><span class="p">(</span><span class="s">&quot;1+2 =&quot;</span><span class="p">,</span> <span class="nx">res</span><span class="p">)</span>
</pre></div>
</td>
</tr>
<tr>
<td class="docs">
</td>
<td class="code">
<div class="highlight"><pre> <span class="nx">res</span> <span class="p">=</span> <span class="nx">plusPlus</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nx">Println</span><span class="p">(</span><span class="s">&quot;1+2+3 =&quot;</span><span class="p">,</span> <span class="nx">res</span><span class="p">)</span>
<span class="p">}</span> <span class="p">}</span>
</pre></div> </pre></div>
@ -129,6 +160,7 @@ expression.</p>
<div class="highlight"><pre><span class="gp">$</span> go run functions.go <div class="highlight"><pre><span class="gp">$</span> go run functions.go
<span class="go">1+2 = 3</span> <span class="go">1+2 = 3</span>
<span class="go">1+2+3 = 6</span>
</pre></div> </pre></div>
</td> </td>

View File

@ -40,7 +40,7 @@ straight-forward.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="http://play.golang.org/p/p_ykufAYRj"><img title="Run code" src="play.png" class="run" /></a> <a href="http://play.golang.org/p/g-aqMz0Ivf"><img title="Run code" src="play.png" class="run" /></a>
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span> <div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
</pre></div> </pre></div>
@ -128,7 +128,7 @@ branches.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Note that you don&rsquo;t need parentheses around conditions <p>Note that you don&rsquo;t need parentheses around conditions
in Go, but that the brackets are required.</p> in Go, but that the braces are required.</p>
</td> </td>
<td class="code empty"> <td class="code empty">

View File

@ -41,7 +41,7 @@ generation.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="http://play.golang.org/p/C0_kuFx3ET"><img title="Run code" src="play.png" class="run" /></a> <a href="http://play.golang.org/p/X973CNW5aa"><img title="Run code" src="play.png" class="run" /></a>
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span> <div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
</pre></div> </pre></div>
@ -136,7 +136,7 @@ give it a well-known seed.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>Call the resulting <code>rand.Source</code> just like the <p>Call the resulting <code>rand.Rand</code> just like the
functions on the <code>rand</code> package.</p> functions on the <code>rand</code> package.</p>
</td> </td>

View File

@ -41,7 +41,7 @@ in Go.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="http://play.golang.org/p/7bnr2EXlxK"><img title="Run code" src="play.png" class="run" /></a> <a href="http://play.golang.org/p/YeSiBTfhFq"><img title="Run code" src="play.png" class="run" /></a>
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span> <div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
</pre></div> </pre></div>
@ -132,7 +132,7 @@ a match test like we saw earlier.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>The also finds the first match but returns the <p>This also finds the first match but returns the
start and end indexes for the match instead of the start and end indexes for the match instead of the
matching text.</p> matching text.</p>

View File

@ -41,7 +41,7 @@ common string formatting tasks.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="http://play.golang.org/p/qayRuqXHym"><img title="Run code" src="play.png" class="run" /></a> <a href="http://play.golang.org/p/JJAAFGxHVq"><img title="Run code" src="play.png" class="run" /></a>
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span> <div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
</pre></div> </pre></div>
@ -269,7 +269,7 @@ different versions of) scientific notation.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p>As with integers as seen earlier, <code>%x</code> renders <p>As with integers seen earlier, <code>%x</code> renders
the string in base-16, with two output characters the string in base-16, with two output characters
per byte of input.</p> per byte of input.</p>

View File

@ -40,7 +40,7 @@ pattern-based layouts.</p>
</td> </td>
<td class="code leading"> <td class="code leading">
<a href="http://play.golang.org/p/SGS6wIVnDd"><img title="Run code" src="play.png" class="run" /></a> <a href="http://play.golang.org/p/BFw556nWcM"><img title="Run code" src="play.png" class="run" /></a>
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span> <div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
</pre></div> </pre></div>
@ -107,7 +107,7 @@ constant.</p>
<tr> <tr>
<td class="docs"> <td class="docs">
<p><code>Format</code> and <code>Parse</code> uses example-based layouts. Usually <p><code>Format</code> and <code>Parse</code> use example-based layouts. Usually
you&rsquo;ll use a constant from <code>time</code> for these layouts, but you&rsquo;ll use a constant from <code>time</code> for these layouts, but
you can also supply custom layouts. Layouts must use the you can also supply custom layouts. Layouts must use the
reference time <code>Mon Jan 2 15:04:05 MST 2006</code> to show the reference time <code>Mon Jan 2 15:04:05 MST 2006</code> to show the