13.0-13.10

This commit is contained in:
Unknwon
2015-11-25 01:23:32 -05:00
parent b439076d21
commit 3aa7fb8bcf
14 changed files with 54 additions and 102 deletions

View File

@@ -14,7 +14,6 @@ func main() {
panic("A severe error occurred: stopping the program!")
fmt.Println("Ending the program")
}
```
输出如下:
@@ -33,7 +32,6 @@ runtime.goexit /go/src/pkg/runtime/proc.c:148
runtime.goexit()
---- Error run E:/Go/GoBoek/code examples/chapter 13/panic.exe with code Crashed
---- Program exited with code -1073741783
```
一个检查程序是否被已知用户启动的具体例子:
@@ -46,7 +44,6 @@ func check() {
panic(Unknown user: no value for $USER)
}
}
```
可以在导入包的 init() 函数中检查这些。
@@ -57,8 +54,7 @@ func check() {
if err != nil {
panic(ERROR occurred: + err.Error())
}
```
```
<u>Go panicking</u>
@@ -68,7 +64,6 @@ if err != nil {
不能随意地用 panic 中止程序,必须尽力补救错误让程序能继续执行。
## 链接
- [目录](directory.md)