18.10 其他
如何在程序出錯時終止程序:
if err != nil {
fmt.Printf(“Program stopping with error %v”, err)
os.Exit(1)
}
或者:
if err != nil {
panic(“ERROR occurred: “ + err.Error())
}
鏈接
- 目錄
- 上一節:網絡和網頁應用
- 下一節:出於性能考慮的最佳實踐和建議
如何在程序出錯時終止程序:
if err != nil {
fmt.Printf(“Program stopping with error %v”, err)
os.Exit(1)
}
或者:
if err != nil {
panic(“ERROR occurred: “ + err.Error())
}