Clarify the panic example with a comment about unreachable code
Fixes #390
This commit is contained in:
parent
91c8ceec2c
commit
2acace92c0
@ -1,6 +1,11 @@
|
|||||||
# Running this program will cause it to panic, print
|
# Running this program will cause it to panic, print
|
||||||
# an error message and goroutine traces, and exit with
|
# an error message and goroutine traces, and exit with
|
||||||
# a non-zero status.
|
# a non-zero status.
|
||||||
|
|
||||||
|
# When first panic in `main` fires, the program exits
|
||||||
|
# without reaching the rest of the code. If you'd like
|
||||||
|
# to see the program try to create a temp file, comment
|
||||||
|
# the first panic out.
|
||||||
$ go run panic.go
|
$ go run panic.go
|
||||||
panic: a problem
|
panic: a problem
|
||||||
|
|
||||||
|
16
public/panic
generated
16
public/panic
generated
@ -117,6 +117,20 @@ returns an error value that we don’t know how to
|
|||||||
an error message and goroutine traces, and exit with
|
an error message and goroutine traces, and exit with
|
||||||
a non-zero status.</p>
|
a non-zero status.</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td class="code empty leading">
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="docs">
|
||||||
|
<p>When first panic in <code>main</code> fires, the program exits
|
||||||
|
without reaching the rest of the code. If you’d like
|
||||||
|
to see the program try to create a temp file, comment
|
||||||
|
the first panic out.</p>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td class="code leading">
|
<td class="code leading">
|
||||||
|
|
||||||
@ -166,7 +180,7 @@ to use error-indicating return values wherever possible.</p>
|
|||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
var codeLines = [];
|
var codeLines = [];
|
||||||
codeLines.push('');codeLines.push('package main\u000A');codeLines.push('import \"os\"\u000A');codeLines.push('func main() {\u000A');codeLines.push(' panic(\"a problem\")\u000A');codeLines.push(' _, err :\u003D os.Create(\"/tmp/file\")\u000A if err !\u003D nil {\u000A panic(err)\u000A }\u000A}\u000A');codeLines.push('');codeLines.push('');codeLines.push('');
|
codeLines.push('');codeLines.push('package main\u000A');codeLines.push('import \"os\"\u000A');codeLines.push('func main() {\u000A');codeLines.push(' panic(\"a problem\")\u000A');codeLines.push(' _, err :\u003D os.Create(\"/tmp/file\")\u000A if err !\u003D nil {\u000A panic(err)\u000A }\u000A}\u000A');codeLines.push('');codeLines.push('');codeLines.push('');codeLines.push('');
|
||||||
</script>
|
</script>
|
||||||
<script src="site.js" async></script>
|
<script src="site.js" async></script>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user